diff options
author | Denys Vlasenko | 2021-04-27 01:31:51 +0200 |
---|---|---|
committer | Denys Vlasenko | 2021-04-27 01:32:05 +0200 |
commit | 39a3ef51b54272dea4018002080a104c21c6bb97 (patch) | |
tree | fe3458a0a834f96fbf7bc6c9209790652d48777a /networking | |
parent | a2bc52dd447816a887e508c6a1210ec43b38b03d (diff) | |
download | busybox-39a3ef51b54272dea4018002080a104c21c6bb97.zip busybox-39a3ef51b54272dea4018002080a104c21c6bb97.tar.gz |
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')
-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 8059f6e..64c53b0 100644 --- a/networking/tls_sp_c32.c +++ b/networking/tls_sp_c32.c @@ -72,18 +72,6 @@ static const sp_digit p256_mod[10] = { #define p256_mp_mod ((sp_digit)0x000001) -/* The base point of curve P256. */ -static const sp_point p256_base = { - /* X ordinate */ - { 0x098c296,0x04e5176,0x33a0f4a,0x204b7ac,0x277037d,0x0e9103c,0x3ce6e56,0x1091fe2,0x1f2e12c,0x01ac5f4 }, - /* Y ordinate */ - { 0x3bf51f5,0x1901a0d,0x1ececbb,0x15dacc5,0x22bce33,0x303e785,0x27eb4a7,0x1fe6e3b,0x2e2fe1a,0x013f8d0 }, - /* Z ordinate */ - { 0x0000001,0x0000000,0x0000000,0x0000000,0x0000000,0x0000000,0x0000000,0x0000000,0x0000000,0x0000000 }, - /* infinity */ - 0 -}; - /* Write r as big endian to byte aray. * Fixed length number of bytes written: 32 * @@ -798,6 +786,24 @@ static void sp_256_ecc_mulmod_10(sp_point* r, const sp_point* g, const sp_digit* */ static void sp_256_ecc_mulmod_base_10(sp_point* r, sp_digit* k /*, int map*/) { + /* Since this function is called only once, save space: + * don't have "static const sp_point p256_base = {...}", + * it would have more zeros than data. + */ + static const sp_digit base_x[] = { + 0x098c296,0x04e5176,0x33a0f4a,0x204b7ac,0x277037d,0x0e9103c,0x3ce6e56,0x1091fe2,0x1f2e12c,0x01ac5f4 + }; + static const sp_digit base_y[] = { + 0x3bf51f5,0x1901a0d,0x1ececbb,0x15dacc5,0x22bce33,0x303e785,0x27eb4a7,0x1fe6e3b,0x2e2fe1a,0x013f8d0 + }; + sp_point p256_base; + + memset(&p256_base, 0, sizeof(p256_base)); + memcpy(p256_base.x, base_x, sizeof(base_x)); + memcpy(p256_base.y, base_y, sizeof(base_y)); + p256_base.z[0] = 1; + /*p256_base.infinity = 0;*/ + sp_256_ecc_mulmod_10(r, &p256_base, k /*, map*/); } |