summaryrefslogtreecommitdiff
path: root/networking
diff options
context:
space:
mode:
authorDenys Vlasenko2021-04-27 13:31:26 +0200
committerDenys Vlasenko2021-04-27 13:32:19 +0200
commit840ae696157ae271417953916de861e48a800e2b (patch)
treeaaa547e449de4db70779a852d8340ed6a077e706 /networking
parent646e85629497ee364e97101de4402d7141919144 (diff)
downloadbusybox-840ae696157ae271417953916de861e48a800e2b.zip
busybox-840ae696157ae271417953916de861e48a800e2b.tar.gz
tls: shrink sp_256_mod_mul_norm_10 more
function old new delta sp_256_mod_mul_norm_10 1439 1305 -134 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'networking')
-rw-r--r--networking/tls_sp_c32.c36
1 files changed, 18 insertions, 18 deletions
diff --git a/networking/tls_sp_c32.c b/networking/tls_sp_c32.c
index c5e887a..2b1ae14 100644
--- a/networking/tls_sp_c32.c
+++ b/networking/tls_sp_c32.c
@@ -557,24 +557,24 @@ static void sp_256_mod_mul_norm_10(sp_digit* r, const sp_digit* a)
t[3] -= o;
t[6] -= o;
t[7] += o;
- t[1] += t[0] >> 32; t[0] &= 0xffffffff;
- t[2] += t[1] >> 32; t[1] &= 0xffffffff;
- t[3] += t[2] >> 32; t[2] &= 0xffffffff;
- t[4] += t[3] >> 32; t[3] &= 0xffffffff;
- t[5] += t[4] >> 32; t[4] &= 0xffffffff;
- t[6] += t[5] >> 32; t[5] &= 0xffffffff;
- t[7] += t[6] >> 32; t[6] &= 0xffffffff;
-
- r[0] = 0x3ffffff & ((sp_digit)(t[0]));
- r[1] = 0x3ffffff & ((sp_digit)(t[0] >> 26) | ((sp_digit)t[1] << 6));
- r[2] = 0x3ffffff & ((sp_digit)(t[1] >> 20) | ((sp_digit)t[2] << 12));
- r[3] = 0x3ffffff & ((sp_digit)(t[2] >> 14) | ((sp_digit)t[3] << 18));
- r[4] = 0x3ffffff & ((sp_digit)(t[3] >> 8) | ((sp_digit)t[4] << 24));
- r[5] = 0x3ffffff & ((sp_digit)t[4] >> 2); /* small shift, ok to cast t[4] to narrower type */
- r[6] = 0x3ffffff & ((sp_digit)(t[4] >> 28) | ((sp_digit)t[5] << 4));
- r[7] = 0x3ffffff & ((sp_digit)(t[5] >> 22) | ((sp_digit)t[6] << 10));
- r[8] = 0x3ffffff & ((sp_digit)(t[6] >> 16) | ((sp_digit)t[7] << 16));
- r[9] = ((sp_digit)(t[7] >> 10));
+ t[1] += t[0] >> 32; //t[0] &= 0xffffffff;
+ t[2] += t[1] >> 32; //t[1] &= 0xffffffff;
+ t[3] += t[2] >> 32; //t[2] &= 0xffffffff;
+ t[4] += t[3] >> 32; //t[3] &= 0xffffffff;
+ t[5] += t[4] >> 32; //t[4] &= 0xffffffff;
+ t[6] += t[5] >> 32; //t[5] &= 0xffffffff;
+ t[7] += t[6] >> 32; //t[6] &= 0xffffffff; - (uint32_t)t[i] casts below accomplish masking
+
+ r[0] = 0x3ffffff & ((sp_digit)((uint32_t)t[0]));
+ r[1] = 0x3ffffff & ((sp_digit)((uint32_t)t[0] >> 26) | ((sp_digit)t[1] << 6));
+ r[2] = 0x3ffffff & ((sp_digit)((uint32_t)t[1] >> 20) | ((sp_digit)t[2] << 12));
+ r[3] = 0x3ffffff & ((sp_digit)((uint32_t)t[2] >> 14) | ((sp_digit)t[3] << 18));
+ r[4] = 0x3ffffff & ((sp_digit)((uint32_t)t[3] >> 8) | ((sp_digit)t[4] << 24));
+ r[5] = 0x3ffffff & ((sp_digit)((uint32_t)t[4] >> 2));
+ r[6] = 0x3ffffff & ((sp_digit)((uint32_t)t[4] >> 28) | ((sp_digit)t[5] << 4));
+ r[7] = 0x3ffffff & ((sp_digit)((uint32_t)t[5] >> 22) | ((sp_digit)t[6] << 10));
+ r[8] = 0x3ffffff & ((sp_digit)((uint32_t)t[6] >> 16) | ((sp_digit)t[7] << 16));
+ r[9] = ((sp_digit)((uint32_t)t[7] >> 10));
}
/* Map the Montgomery form projective co-ordinate point to an affine point.