aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2021-11-28 02:56:02 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2021-11-28 02:56:02 +0100
commit1b93c7c4ecc47318905b6e6f801732b7dd31e0ee (patch)
tree8ead2f50376333e29fb0442bf68992ead55c39e6
parent0b13ab66f43fc1a9437361cfcd33b485422eb0ae (diff)
downloadbusybox-w32-1b93c7c4ecc47318905b6e6f801732b7dd31e0ee.tar.gz
busybox-w32-1b93c7c4ecc47318905b6e6f801732b7dd31e0ee.tar.bz2
busybox-w32-1b93c7c4ecc47318905b6e6f801732b7dd31e0ee.zip
tls: P256: pad struct sp_point to 64 bits (on 64-bit arches)
function old new delta curve_P256_compute_pubkey_and_premaster 198 190 -8 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--networking/tls_sp_c32.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/networking/tls_sp_c32.c b/networking/tls_sp_c32.c
index 4c8f08d4e..37e1cfa1c 100644
--- a/networking/tls_sp_c32.c
+++ b/networking/tls_sp_c32.c
@@ -49,14 +49,19 @@ typedef int32_t signed_sp_digit;
49 */ 49 */
50 50
51typedef struct sp_point { 51typedef struct sp_point {
52 sp_digit x[8]; 52 sp_digit x[8]
53#if ULONG_MAX > 0xffffffff
54 /* Make sp_point[] arrays to not be 64-bit misaligned */
55 ALIGNED(8)
56#endif
57 ;
53 sp_digit y[8]; 58 sp_digit y[8];
54 sp_digit z[8]; 59 sp_digit z[8];
55 int infinity; 60 int infinity;
56} sp_point; 61} sp_point;
57 62
58/* The modulus (prime) of the curve P256. */ 63/* The modulus (prime) of the curve P256. */
59static const sp_digit p256_mod[8] = { 64static const sp_digit p256_mod[8] ALIGNED(8) = {
60 0xffffffff,0xffffffff,0xffffffff,0x00000000, 65 0xffffffff,0xffffffff,0xffffffff,0x00000000,
61 0x00000000,0x00000000,0x00000001,0xffffffff, 66 0x00000000,0x00000000,0x00000001,0xffffffff,
62}; 67};
@@ -903,7 +908,7 @@ static void sp_512to256_mont_reduce_8(sp_digit* r, sp_digit* a/*, const sp_digit
903 * a First number to multiply in Montogmery form. 908 * a First number to multiply in Montogmery form.
904 * b Second number to multiply in Montogmery form. 909 * b Second number to multiply in Montogmery form.
905 * m Modulus (prime). 910 * m Modulus (prime).
906 * mp Montogmery mulitplier. 911 * mp Montogmery multiplier.
907 */ 912 */
908static void sp_256_mont_mul_8(sp_digit* r, const sp_digit* a, const sp_digit* b 913static void sp_256_mont_mul_8(sp_digit* r, const sp_digit* a, const sp_digit* b
909 /*, const sp_digit* m, sp_digit mp*/) 914 /*, const sp_digit* m, sp_digit mp*/)
@@ -920,7 +925,7 @@ static void sp_256_mont_mul_8(sp_digit* r, const sp_digit* a, const sp_digit* b
920 * r Result of squaring. 925 * r Result of squaring.
921 * a Number to square in Montogmery form. 926 * a Number to square in Montogmery form.
922 * m Modulus (prime). 927 * m Modulus (prime).
923 * mp Montogmery mulitplier. 928 * mp Montogmery multiplier.
924 */ 929 */
925static void sp_256_mont_sqr_8(sp_digit* r, const sp_digit* a 930static void sp_256_mont_sqr_8(sp_digit* r, const sp_digit* a
926 /*, const sp_digit* m, sp_digit mp*/) 931 /*, const sp_digit* m, sp_digit mp*/)
@@ -1145,7 +1150,6 @@ static NOINLINE void sp_256_proj_point_add_8(sp_point* r, sp_point* p, sp_point*
1145 return; 1150 return;
1146 } 1151 }
1147 1152
1148
1149 if (p->infinity || q->infinity) { 1153 if (p->infinity || q->infinity) {
1150 *r = p->infinity ? *q : *p; /* struct copy */ 1154 *r = p->infinity ? *q : *p; /* struct copy */
1151 return; 1155 return;