diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2021-11-28 11:10:00 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2021-11-28 11:15:34 +0100 |
commit | cfb615781df5c7439fe0060a85e6b6a56d10dc7f (patch) | |
tree | ebe1994c221f733ac1d42b02b3f4e71ad37946ad | |
parent | bfefa6ab6cf30507009cca7182c7302900fb5534 (diff) | |
download | busybox-w32-cfb615781df5c7439fe0060a85e6b6a56d10dc7f.tar.gz busybox-w32-cfb615781df5c7439fe0060a85e6b6a56d10dc7f.tar.bz2 busybox-w32-cfb615781df5c7439fe0060a85e6b6a56d10dc7f.zip |
tls: P256: simplify sp_256_mont_inv_8 (no need for a temporary)
function old new delta
sp_256_ecc_mulmod_8 543 517 -26
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | networking/tls_sp_c32.c | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/networking/tls_sp_c32.c b/networking/tls_sp_c32.c index 37e1cfa1c..9bd5c6832 100644 --- a/networking/tls_sp_c32.c +++ b/networking/tls_sp_c32.c | |||
@@ -938,7 +938,7 @@ static void sp_256_mont_sqr_8(sp_digit* r, const sp_digit* a | |||
938 | /* Invert the number, in Montgomery form, modulo the modulus (prime) of the | 938 | /* Invert the number, in Montgomery form, modulo the modulus (prime) of the |
939 | * P256 curve. (r = 1 / a mod m) | 939 | * P256 curve. (r = 1 / a mod m) |
940 | * | 940 | * |
941 | * r Inverse result. | 941 | * r Inverse result. Must not coincide with a. |
942 | * a Number to invert. | 942 | * a Number to invert. |
943 | */ | 943 | */ |
944 | #if 0 | 944 | #if 0 |
@@ -952,17 +952,15 @@ static void sp_256_mont_sqr_8(sp_digit* r, const sp_digit* a | |||
952 | #endif | 952 | #endif |
953 | static void sp_256_mont_inv_8(sp_digit* r, sp_digit* a) | 953 | static void sp_256_mont_inv_8(sp_digit* r, sp_digit* a) |
954 | { | 954 | { |
955 | sp_digit t[8]; | ||
956 | int i; | 955 | int i; |
957 | 956 | ||
958 | memcpy(t, a, sizeof(sp_digit) * 8); | 957 | memcpy(r, a, sizeof(sp_digit) * 8); |
959 | for (i = 254; i >= 0; i--) { | 958 | for (i = 254; i >= 0; i--) { |
960 | sp_256_mont_sqr_8(t, t /*, p256_mod, p256_mp_mod*/); | 959 | sp_256_mont_sqr_8(r, r /*, p256_mod, p256_mp_mod*/); |
961 | /*if (p256_mod_2[i / 32] & ((sp_digit)1 << (i % 32)))*/ | 960 | /*if (p256_mod_2[i / 32] & ((sp_digit)1 << (i % 32)))*/ |
962 | if (i >= 224 || i == 192 || (i <= 95 && i != 1)) | 961 | if (i >= 224 || i == 192 || (i <= 95 && i != 1)) |
963 | sp_256_mont_mul_8(t, t, a /*, p256_mod, p256_mp_mod*/); | 962 | sp_256_mont_mul_8(r, r, a /*, p256_mod, p256_mp_mod*/); |
964 | } | 963 | } |
965 | memcpy(r, t, sizeof(sp_digit) * 8); | ||
966 | } | 964 | } |
967 | 965 | ||
968 | /* Multiply a number by Montogmery normalizer mod modulus (prime). | 966 | /* Multiply a number by Montogmery normalizer mod modulus (prime). |