diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2021-04-27 01:31:51 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2021-04-27 01:32:05 +0200 |
commit | 39a3ef51b54272dea4018002080a104c21c6bb97 (patch) | |
tree | fe3458a0a834f96fbf7bc6c9209790652d48777a /networking/tls_sp_c32.c | |
parent | a2bc52dd447816a887e508c6a1210ec43b38b03d (diff) | |
download | busybox-w32-39a3ef51b54272dea4018002080a104c21c6bb97.tar.gz busybox-w32-39a3ef51b54272dea4018002080a104c21c6bb97.tar.bz2 busybox-w32-39a3ef51b54272dea4018002080a104c21c6bb97.zip |
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>
Diffstat (limited to 'networking/tls_sp_c32.c')
-rw-r--r-- | networking/tls_sp_c32.c | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/networking/tls_sp_c32.c b/networking/tls_sp_c32.c index 8059f6e10..64c53b006 100644 --- a/networking/tls_sp_c32.c +++ b/networking/tls_sp_c32.c | |||
@@ -72,18 +72,6 @@ static const sp_digit p256_mod[10] = { | |||
72 | 72 | ||
73 | #define p256_mp_mod ((sp_digit)0x000001) | 73 | #define p256_mp_mod ((sp_digit)0x000001) |
74 | 74 | ||
75 | /* The base point of curve P256. */ | ||
76 | static const sp_point p256_base = { | ||
77 | /* X ordinate */ | ||
78 | { 0x098c296,0x04e5176,0x33a0f4a,0x204b7ac,0x277037d,0x0e9103c,0x3ce6e56,0x1091fe2,0x1f2e12c,0x01ac5f4 }, | ||
79 | /* Y ordinate */ | ||
80 | { 0x3bf51f5,0x1901a0d,0x1ececbb,0x15dacc5,0x22bce33,0x303e785,0x27eb4a7,0x1fe6e3b,0x2e2fe1a,0x013f8d0 }, | ||
81 | /* Z ordinate */ | ||
82 | { 0x0000001,0x0000000,0x0000000,0x0000000,0x0000000,0x0000000,0x0000000,0x0000000,0x0000000,0x0000000 }, | ||
83 | /* infinity */ | ||
84 | 0 | ||
85 | }; | ||
86 | |||
87 | /* Write r as big endian to byte aray. | 75 | /* Write r as big endian to byte aray. |
88 | * Fixed length number of bytes written: 32 | 76 | * Fixed length number of bytes written: 32 |
89 | * | 77 | * |
@@ -798,6 +786,24 @@ static void sp_256_ecc_mulmod_10(sp_point* r, const sp_point* g, const sp_digit* | |||
798 | */ | 786 | */ |
799 | static void sp_256_ecc_mulmod_base_10(sp_point* r, sp_digit* k /*, int map*/) | 787 | static void sp_256_ecc_mulmod_base_10(sp_point* r, sp_digit* k /*, int map*/) |
800 | { | 788 | { |
789 | /* Since this function is called only once, save space: | ||
790 | * don't have "static const sp_point p256_base = {...}", | ||
791 | * it would have more zeros than data. | ||
792 | */ | ||
793 | static const sp_digit base_x[] = { | ||
794 | 0x098c296,0x04e5176,0x33a0f4a,0x204b7ac,0x277037d,0x0e9103c,0x3ce6e56,0x1091fe2,0x1f2e12c,0x01ac5f4 | ||
795 | }; | ||
796 | static const sp_digit base_y[] = { | ||
797 | 0x3bf51f5,0x1901a0d,0x1ececbb,0x15dacc5,0x22bce33,0x303e785,0x27eb4a7,0x1fe6e3b,0x2e2fe1a,0x013f8d0 | ||
798 | }; | ||
799 | sp_point p256_base; | ||
800 | |||
801 | memset(&p256_base, 0, sizeof(p256_base)); | ||
802 | memcpy(p256_base.x, base_x, sizeof(base_x)); | ||
803 | memcpy(p256_base.y, base_y, sizeof(base_y)); | ||
804 | p256_base.z[0] = 1; | ||
805 | /*p256_base.infinity = 0;*/ | ||
806 | |||
801 | sp_256_ecc_mulmod_10(r, &p256_base, k /*, map*/); | 807 | sp_256_ecc_mulmod_10(r, &p256_base, k /*, map*/); |
802 | } | 808 | } |
803 | 809 | ||