aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2021-10-01 13:51:39 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2021-10-01 13:51:39 +0200
commit7714518f1a97b6facd58a877afaafa130149192d (patch)
tree9cb0c215e5de06587998d37a32436196ed5f2f9d
parentac36e7007480e2d2d68d9d333c026ba4527086df (diff)
downloadbusybox-w32-7714518f1a97b6facd58a877afaafa130149192d.tar.gz
busybox-w32-7714518f1a97b6facd58a877afaafa130149192d.tar.bz2
busybox-w32-7714518f1a97b6facd58a877afaafa130149192d.zip
tls: code shrink P256 code
function old new delta sp_256_to_bin 148 120 -28 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--networking/tls_sp_c32.c26
1 files changed, 12 insertions, 14 deletions
diff --git a/networking/tls_sp_c32.c b/networking/tls_sp_c32.c
index 73dae6c7b..353dacdc4 100644
--- a/networking/tls_sp_c32.c
+++ b/networking/tls_sp_c32.c
@@ -70,6 +70,16 @@ static const sp_digit p256_mod[10] = {
70 70
71#define p256_mp_mod ((sp_digit)0x000001) 71#define p256_mp_mod ((sp_digit)0x000001)
72 72
73/* Normalize the values in each word to 26 bits. */
74static void sp_256_norm_10(sp_digit* a)
75{
76 int i;
77 for (i = 0; i < 9; i++) {
78 a[i+1] += a[i] >> 26;
79 a[i] &= 0x3ffffff;
80 }
81}
82
73/* Write r as big endian to byte aray. 83/* Write r as big endian to byte aray.
74 * Fixed length number of bytes written: 32 84 * Fixed length number of bytes written: 32
75 * 85 *
@@ -80,10 +90,8 @@ static void sp_256_to_bin(sp_digit* r, uint8_t* a)
80{ 90{
81 int i, j, s = 0, b; 91 int i, j, s = 0, b;
82 92
83 for (i = 0; i < 9; i++) { 93 sp_256_norm_10(r);
84 r[i+1] += r[i] >> 26; 94
85 r[i] &= 0x3ffffff;
86 }
87 j = 256 / 8 - 1; 95 j = 256 / 8 - 1;
88 a[j] = 0; 96 a[j] = 0;
89 for (i = 0; i < 10 && j >= 0; i++) { 97 for (i = 0; i < 10 && j >= 0; i++) {
@@ -171,16 +179,6 @@ static int sp_256_cmp_equal_10(const sp_digit* a, const sp_digit* b)
171 return sp_256_cmp_10(a, b) == 0; 179 return sp_256_cmp_10(a, b) == 0;
172} 180}
173 181
174/* Normalize the values in each word to 26 bits. */
175static void sp_256_norm_10(sp_digit* a)
176{
177 int i;
178 for (i = 0; i < 9; i++) {
179 a[i+1] += a[i] >> 26;
180 a[i] &= 0x3ffffff;
181 }
182}
183
184/* Add b to a into r. (r = a + b) */ 182/* Add b to a into r. (r = a + b) */
185static void sp_256_add_10(sp_digit* r, const sp_digit* a, const sp_digit* b) 183static void sp_256_add_10(sp_digit* r, const sp_digit* a, const sp_digit* b)
186{ 184{