diff options
author | Denys Vlasenko | 2021-10-05 20:00:50 +0200 |
---|---|---|
committer | Denys Vlasenko | 2021-10-05 20:01:38 +0200 |
commit | 3b411ebbfc749f9f12b0eb739cb5ba3ec052197e (patch) | |
tree | da81f1546b78d25f4ac63e612e76cb27aa4c2db3 /networking/tls.c | |
parent | 55578f2fb7c05357fb0b1ce84b616ba8ffd6d907 (diff) | |
download | busybox-3b411ebbfc749f9f12b0eb739cb5ba3ec052197e.zip busybox-3b411ebbfc749f9f12b0eb739cb5ba3ec052197e.tar.gz |
tls: replace "26-bit" P256 code with 32-bit one.
function old new delta
sp_256_ecc_mulmod_8 - 1171 +1171
sp_256_mod_mul_norm_8 - 834 +834
sp_256_proj_point_dbl_8 - 374 +374
sp_256_mont_reduce_8 - 268 +268
sp_256_mont_mul_8 - 151 +151
sp_256_sub_8 - 76 +76
sp_256_add_8 - 76 +76
sp_256_cmp_8 - 38 +38
static.sp_256_mont_dbl_8 - 31 +31
static.sp_256_mont_sub_8 - 29 +29
sp_256_to_bin_8 - 28 +28
sp_256_point_from_bin2x32 50 73 +23
sp_256_mont_sqr_8 - 7 +7
sp_256_mont_sqr_10 7 - -7
p256_mod 40 32 -8
curve_P256_compute_pubkey_and_premaster 186 167 -19
sp_256_sub_10 22 - -22
sp_256_add_10 22 - -22
sp_256_cmp_10 24 - -24
sp_256_norm_10 31 - -31
static.sp_256_mont_sub_10 49 - -49
static.sp_256_mont_dbl_10 52 - -52
static.sp_256_mul_add_10 82 - -82
sp_256_from_bin_10 119 - -119
sp_256_to_bin_10 120 - -120
sp_256_mont_reduce_10 178 - -178
sp_256_mont_mul_10 214 - -214
sp_256_proj_point_dbl_10 451 - -451
sp_256_ecc_mulmod_10 1216 - -1216
sp_256_mod_mul_norm_10 1305 - -1305
------------------------------------------------------------------------------
(add/remove: 12/15 grow/shrink: 1/2 up/down: 3106/-3919) Total: -813 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'networking/tls.c')
-rw-r--r-- | networking/tls.c | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/networking/tls.c b/networking/tls.c index 4f0e2b6..675ef4b 100644 --- a/networking/tls.c +++ b/networking/tls.c @@ -2334,7 +2334,6 @@ void FAST_FUNC tls_run_copy_loop(tls_state_t *tls, unsigned flags) // e.g. at the very beginning of wget_main() // { -//kbuild:lib-$(CONFIG_TLS) += tls_sp_c32_new.o uint8_t ecc_pub_key32[2 * 32]; uint8_t pubkey2x32[2 * 32]; uint8_t premaster32[32]; @@ -2345,14 +2344,14 @@ void FAST_FUNC tls_run_copy_loop(tls_state_t *tls, unsigned flags) // memset(ecc_pub_key32, 0x00, sizeof(ecc_pub_key32)); // ecc_pub_key32[18] = 0xab; //Random key: - tls_get_random(ecc_pub_key32, sizeof(ecc_pub_key32)); +// tls_get_random(ecc_pub_key32, sizeof(ecc_pub_key32)); //Biased random (almost all zeros or almost all ones): -// srand(time(NULL) ^ getpid()); -// if (rand() & 1) -// memset(ecc_pub_key32, 0x00, sizeof(ecc_pub_key32)); -// else -// memset(ecc_pub_key32, 0xff, sizeof(ecc_pub_key32)); -// ecc_pub_key32[rand() & 0x3f] = rand(); + srand(time(NULL) ^ getpid()); + if (rand() & 1) + memset(ecc_pub_key32, 0x00, sizeof(ecc_pub_key32)); + else + memset(ecc_pub_key32, 0xff, sizeof(ecc_pub_key32)); + ecc_pub_key32[rand() & 0x3f] = rand(); xmove_fd(xopen("p256.OLD", O_WRONLY | O_CREAT | O_TRUNC), 2); curve_P256_compute_pubkey_and_premaster( |