aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2019-01-10 20:18:02 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2019-01-10 20:18:02 +0100
commit3109d1f9659ffad76f3cf2c547cc425ed34ae96c (patch)
treebe23fe6c6430064418387f2364718e6ede6fdee2
parent6ca8e347fed8c24655df692f22694baf7c572770 (diff)
downloadbusybox-w32-3109d1f9659ffad76f3cf2c547cc425ed34ae96c.tar.gz
busybox-w32-3109d1f9659ffad76f3cf2c547cc425ed34ae96c.tar.bz2
busybox-w32-3109d1f9659ffad76f3cf2c547cc425ed34ae96c.zip
tls: code shrink
function old new delta lm_add 82 78 -4 curve25519 793 786 -7 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-11) Total: -11 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--networking/tls_fe.c18
1 files changed, 7 insertions, 11 deletions
diff --git a/networking/tls_fe.c b/networking/tls_fe.c
index f235082f5..10971bbff 100644
--- a/networking/tls_fe.c
+++ b/networking/tls_fe.c
@@ -43,17 +43,13 @@ typedef uint32_t word32;
43#if 0 //UNUSED 43#if 0 //UNUSED
44static void fprime_copy(byte *x, const byte *a) 44static void fprime_copy(byte *x, const byte *a)
45{ 45{
46 int i; 46 memcpy(x, a, F25519_SIZE);
47 for (i = 0; i < F25519_SIZE; i++)
48 x[i] = a[i];
49} 47}
50#endif 48#endif
51 49
52static void lm_copy(byte* x, const byte* a) 50static void lm_copy(byte* x, const byte* a)
53{ 51{
54 int i; 52 memcpy(x, a, F25519_SIZE);
55 for (i = 0; i < F25519_SIZE; i++)
56 x[i] = a[i];
57} 53}
58 54
59#if 0 //UNUSED 55#if 0 //UNUSED
@@ -200,7 +196,7 @@ static void fe_load(byte *x, word32 c)
200static void fe_normalize(byte *x) 196static void fe_normalize(byte *x)
201{ 197{
202 byte minusp[F25519_SIZE]; 198 byte minusp[F25519_SIZE];
203 word16 c; 199 unsigned c;
204 int i; 200 int i;
205 201
206 /* Reduce using 2^255 = 19 mod p */ 202 /* Reduce using 2^255 = 19 mod p */
@@ -219,13 +215,13 @@ static void fe_normalize(byte *x)
219 */ 215 */
220 c = 19; 216 c = 19;
221 217
222 for (i = 0; i + 1 < F25519_SIZE; i++) { 218 for (i = 0; i < F25519_SIZE - 1; i++) {
223 c += x[i]; 219 c += x[i];
224 minusp[i] = (byte)c; 220 minusp[i] = (byte)c;
225 c >>= 8; 221 c >>= 8;
226 } 222 }
227 223
228 c += ((word16)x[i]) - 128; 224 c += ((unsigned)x[i]) - 128;
229 minusp[31] = (byte)c; 225 minusp[31] = (byte)c;
230 226
231 /* Load x-p if no underflow */ 227 /* Load x-p if no underflow */
@@ -234,13 +230,13 @@ static void fe_normalize(byte *x)
234 230
235static void lm_add(byte* r, const byte* a, const byte* b) 231static void lm_add(byte* r, const byte* a, const byte* b)
236{ 232{
237 word16 c = 0; 233 unsigned c = 0;
238 int i; 234 int i;
239 235
240 /* Add */ 236 /* Add */
241 for (i = 0; i < F25519_SIZE; i++) { 237 for (i = 0; i < F25519_SIZE; i++) {
242 c >>= 8; 238 c >>= 8;
243 c += ((word16)a[i]) + ((word16)b[i]); 239 c += ((unsigned)a[i]) + ((unsigned)b[i]);
244 r[i] = (byte)c; 240 r[i] = (byte)c;
245 } 241 }
246 242