diff options
| author | Denys Vlasenko <vda.linux@googlemail.com> | 2021-04-26 18:05:53 +0200 |
|---|---|---|
| committer | Denys Vlasenko <vda.linux@googlemail.com> | 2021-04-26 18:05:53 +0200 |
| commit | 93b886f54bf85ca38f372ddd521f7c5bdbdc5d08 (patch) | |
| tree | 5188e4160e4a9a5f50dacb2712a9ff109c5ef54e | |
| parent | 6381f3d4f6d9ac111c2be7cfba041e8b7a28f9f9 (diff) | |
| download | busybox-w32-93b886f54bf85ca38f372ddd521f7c5bdbdc5d08.tar.gz busybox-w32-93b886f54bf85ca38f372ddd521f7c5bdbdc5d08.tar.bz2 busybox-w32-93b886f54bf85ca38f372ddd521f7c5bdbdc5d08.zip | |
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>
| -rw-r--r-- | networking/tls_sp_c32.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/networking/tls_sp_c32.c b/networking/tls_sp_c32.c index c71f716d6..97b2d3de9 100644 --- a/networking/tls_sp_c32.c +++ b/networking/tls_sp_c32.c | |||
| @@ -554,11 +554,18 @@ static void sp_256_mont_sqr_10(sp_digit* r, const sp_digit* a, const sp_digit* m | |||
| 554 | * r Inverse result. | 554 | * r Inverse result. |
| 555 | * a Number to invert. | 555 | * a Number to invert. |
| 556 | */ | 556 | */ |
| 557 | #if 0 | ||
| 557 | /* Mod-2 for the P256 curve. */ | 558 | /* Mod-2 for the P256 curve. */ |
| 558 | static const uint32_t p256_mod_2[8] = { | 559 | static const uint32_t p256_mod_2[8] = { |
| 559 | 0xfffffffd,0xffffffff,0xffffffff,0x00000000, | 560 | 0xfffffffd,0xffffffff,0xffffffff,0x00000000, |
| 560 | 0x00000000,0x00000000,0x00000001,0xffffffff, | 561 | 0x00000000,0x00000000,0x00000001,0xffffffff, |
| 561 | }; | 562 | }; |
| 563 | //Bit pattern: | ||
| 564 | //2 2 2 2 2 2 2 1...1 | ||
| 565 | //5 5 4 3 2 1 0 9...0 9...1 | ||
| 566 | //543210987654321098765432109876543210987654321098765432109876543210...09876543210...09876543210 | ||
| 567 | //111111111111111111111111111111110000000000000000000000000000000100...00000111111...11111111101 | ||
| 568 | #endif | ||
| 562 | static void sp_256_mont_inv_10(sp_digit* r, sp_digit* a) | 569 | static void sp_256_mont_inv_10(sp_digit* r, sp_digit* a) |
| 563 | { | 570 | { |
| 564 | sp_digit t[2*10]; //can be just [10]? | 571 | sp_digit t[2*10]; //can be just [10]? |
| @@ -567,7 +574,8 @@ static void sp_256_mont_inv_10(sp_digit* r, sp_digit* a) | |||
| 567 | memcpy(t, a, sizeof(sp_digit) * 10); | 574 | memcpy(t, a, sizeof(sp_digit) * 10); |
| 568 | for (i = 254; i >= 0; i--) { | 575 | for (i = 254; i >= 0; i--) { |
| 569 | sp_256_mont_sqr_10(t, t, p256_mod, p256_mp_mod); | 576 | sp_256_mont_sqr_10(t, t, p256_mod, p256_mp_mod); |
| 570 | if (p256_mod_2[i / 32] & ((sp_digit)1 << (i % 32))) | 577 | /*if (p256_mod_2[i / 32] & ((sp_digit)1 << (i % 32)))*/ |
| 578 | if (i >= 224 || i == 192 || (i <= 95 && i != 1)) | ||
| 571 | sp_256_mont_mul_10(t, t, a, p256_mod, p256_mp_mod); | 579 | sp_256_mont_mul_10(t, t, a, p256_mod, p256_mp_mod); |
| 572 | } | 580 | } |
| 573 | memcpy(r, t, sizeof(sp_digit) * 10); | 581 | memcpy(r, t, sizeof(sp_digit) * 10); |
