diff options
-rw-r--r-- | networking/tls_sp_c32.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/networking/tls_sp_c32.c b/networking/tls_sp_c32.c index 7c6229ffd..99f9c6839 100644 --- a/networking/tls_sp_c32.c +++ b/networking/tls_sp_c32.c | |||
@@ -96,11 +96,13 @@ static void sp_256_to_bin_10(sp_digit* r, uint8_t* a) | |||
96 | a[j] = 0; | 96 | a[j] = 0; |
97 | for (i = 0; i < 10 && j >= 0; i++) { | 97 | for (i = 0; i < 10 && j >= 0; i++) { |
98 | b = 0; | 98 | b = 0; |
99 | a[j--] |= r[i] << s; b += 8 - s; | 99 | a[j--] |= r[i] << s; |
100 | b += 8 - s; | ||
100 | if (j < 0) | 101 | if (j < 0) |
101 | break; | 102 | break; |
102 | while (b < 26) { | 103 | while (b < 26) { |
103 | a[j--] = r[i] >> b; b += 8; | 104 | a[j--] = r[i] >> b; |
105 | b += 8; | ||
104 | if (j < 0) | 106 | if (j < 0) |
105 | break; | 107 | break; |
106 | } | 108 | } |
@@ -297,6 +299,7 @@ static void sp_256_mont_sub_10(sp_digit* r, const sp_digit* a, const sp_digit* b | |||
297 | if (r[9] >> 22) | 299 | if (r[9] >> 22) |
298 | sp_256_add_10(r, r, m); | 300 | sp_256_add_10(r, r, m); |
299 | sp_256_norm_10(r); | 301 | sp_256_norm_10(r); |
302 | r[9] &= 0x03fffff; /* truncate to 22 bits */ | ||
300 | } | 303 | } |
301 | 304 | ||
302 | /* Double a Montgomery form number (r = a + a % m) */ | 305 | /* Double a Montgomery form number (r = a + a % m) */ |
@@ -864,8 +867,8 @@ static void sp_ecc_secret_gen_256(const sp_digit priv[10], const uint8_t *pub2x3 | |||
864 | dump_hex(" %s\n", pub2x32 + 32, 32); | 867 | dump_hex(" %s\n", pub2x32 + 32, 32); |
865 | 868 | ||
866 | sp_256_point_from_bin2x32(point, pub2x32); | 869 | sp_256_point_from_bin2x32(point, pub2x32); |
867 | dump_hex("point->x %s\n", point->x, sizeof(point->x)); | 870 | dump_512("point->x %s\n", point->x); |
868 | dump_hex("point->y %s\n", point->y, sizeof(point->y)); | 871 | dump_512("point->y %s\n", point->y); |
869 | 872 | ||
870 | sp_256_ecc_mulmod_10(point, point, priv); | 873 | sp_256_ecc_mulmod_10(point, point, priv); |
871 | 874 | ||