Commit Graph

18 Commits

Author SHA1 Message Date
Denys Vlasenko
81f9a0035b tls: tweak sp_256_ecc_gen_k_10 for smaller code
function                                             old     new   delta
curve_P256_compute_pubkey_and_premaster              194     191      -3

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-04-27 18:48:43 +02:00
Denys Vlasenko
840ae69615 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>
2021-04-27 13:32:19 +02:00
Denys Vlasenko
646e856294 tls: shrink sp_256_mod_mul_norm_10
function                                             old     new   delta
sp_256_mod_mul_norm_10                              1439    1405     -34

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-04-27 13:09:44 +02:00
Denys Vlasenko
48a18d15df tls: shrink p256_base more
function                                             old     new   delta
static.p256_base_bin                                   -      64     +64
sp_256_point_from_bin2x32                              -      62     +62
static.base_y                                         40       -     -40
static.base_x                                         40       -     -40
curve_P256_compute_pubkey_and_premaster              291     194     -97
------------------------------------------------------------------------------
(add/remove: 2/2 grow/shrink: 0/1 up/down: 126/-177)          Total: -51 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-04-27 12:24:21 +02:00
Denys Vlasenko
39a3ef51b5 tls: shrink p256_base
function                                             old     new   delta
curve_P256_compute_pubkey_and_premaster              196     291     +95
static.base_y                                          -      40     +40
static.base_x                                          -      40     +40
p256_base                                            244       -    -244
------------------------------------------------------------------------------
(add/remove: 2/1 grow/shrink: 1/0 up/down: 175/-244)          Total: -69 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-04-27 01:32:05 +02:00
Denys Vlasenko
a2bc52dd44 tls: reorder P256 functions to make more sense
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-04-27 01:21:26 +02:00
Denys Vlasenko
e52e43c72f tls: whitespace fixes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-04-27 00:40:40 +02:00
Denys Vlasenko
9a40be433d tls: get rid of constant-time add/sub operations
function                                             old     new   delta
sp_256_sub_10                                          -      22     +22
static.sp_256_mont_reduce_10                         176     178      +2
sp_256_mod_mul_norm_10                              1440    1439      -1
sp_256_proj_point_dbl_10                             453     446      -7
sp_256_ecc_mulmod_10                                1229    1216     -13
static.sp_256_mont_sub_10                             52      30     -22
static.sp_256_cond_sub_10                             32       -     -32
------------------------------------------------------------------------------
(add/remove: 1/1 grow/shrink: 1/4 up/down: 24/-75)            Total: -51 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-04-26 21:58:04 +02:00
Denys Vlasenko
120401249a tls: fix whitespace in P256 code
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-04-26 20:24:34 +02:00
Denys Vlasenko
93b886f54b tls: shrink sp_256_mont_inv_10
function                                             old     new   delta
sp_256_ecc_mulmod_10                                1237    1251     +14
p256_mod_2                                            32       -     -32
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 1/0 up/down: 14/-32)            Total: -18 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-04-26 18:05:53 +02:00
Denys Vlasenko
6381f3d4f6 tls: stop passing temporary buffer address in P256 code
function                                             old     new   delta
sp_256_proj_point_dbl_10                             435     453     +18
sp_256_ecc_mulmod_10                                1300    1237     -63
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/1 up/down: 18/-63)            Total: -45 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-04-26 17:41:43 +02:00
Denys Vlasenko
772e18775e tls: shrink sp_256_proj_point_dbl_10
function                                             old     new   delta
sp_256_ecc_mulmod_10                                1329    1300     -29

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-04-26 17:25:27 +02:00
Denys Vlasenko
b3b1713a58 tls: in P256 replace constant-time compares with usual ones
function                                             old     new   delta
sp_256_cmp_10                                          -      24     +24
sp_256_ecc_mulmod_10                                1332    1329      -3
sp_256_cmp_equal_10                                   30       -     -30
static.sp_256_cmp_10                                  43       -     -43
------------------------------------------------------------------------------
(add/remove: 1/2 grow/shrink: 0/1 up/down: 24/-76)            Total: -52 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-04-26 16:53:53 +02:00
Denys Vlasenko
4d3a5c135c tls: simplify sp_256_proj_point_dbl_10
function                                             old     new   delta
sp_256_proj_point_dbl_10                             490     435     -55

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-04-26 15:21:38 +02:00
Denys Vlasenko
03ab2a90bb tls: simplify array manipulations in sp_256_ecc_mulmod_10
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-04-26 14:55:46 +02:00
Denys Vlasenko
166363f47d tls: get rid of address obfuscation trick in P256
function                                             old     new   delta
addr_mask                                              8       -      -8
sp_256_ecc_mulmod_10                                1363    1330     -33
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 0/1 up/down: 0/-41)             Total: -41 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-04-26 14:40:21 +02:00
Denys Vlasenko
074b33bf16 tls: simplify sp_256_ecc_gen_k_10, cosmetic changes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-04-26 14:33:38 +02:00
Denys Vlasenko
f18a1fd6f3 tls: implement secp256r1 elliptic curve (aka P256)
function                                             old     new   delta
sp_256_mod_mul_norm_10                                 -    1439   +1439
sp_256_ecc_mulmod_10                                   -    1363   +1363
sp_256_proj_point_dbl_10                               -     490    +490
p256_base                                              -     244    +244
static.sp_256_mont_sqr_10                              -     234    +234
static.sp_256_mont_mul_10                              -     214    +214
curve_P256_compute_pubkey_and_premaster                -     197    +197
static.sp_256_mont_reduce_10                           -     176    +176
static.sp_256_from_bin                                 -     149    +149
sp_256_to_bin                                          -     148    +148
tls_handshake                                       2046    2146    +100
static.sp_256_mul_add_10                               -      82     +82
.rodata                                           103275  103336     +61
static.sp_256_mont_sub_10                              -      52     +52
static.sp_256_mont_dbl_10                              -      52     +52
static.sp_256_cmp_10                                   -      43     +43
p256_mod                                               -      40     +40
static.sp_256_cond_sub_10                              -      32     +32
p256_mod_2                                             -      32     +32
sp_256_norm_10                                         -      31     +31
sp_256_cmp_equal_10                                    -      30     +30
sp_256_add_10                                          -      22     +22
addr_mask                                              -       8      +8
------------------------------------------------------------------------------
(add/remove: 22/0 grow/shrink: 2/0 up/down: 5239/0)          Total: 5239 bytes
   text	   data	    bss	    dec	    hex	filename
1018192	    559	   5020	1023771	  f9f1b	busybox_old
1023431	    559	   5020	1029010	  fb392	busybox_unstripped

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2021-04-26 13:30:09 +02:00