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>
diff --git a/networking/tls_sp_c32.c b/networking/tls_sp_c32.c
index 4c8f08d..37e1cfa 100644
--- a/networking/tls_sp_c32.c
+++ b/networking/tls_sp_c32.c
@@ -49,14 +49,19 @@
*/
typedef struct sp_point {
- sp_digit x[8];
+ sp_digit x[8]
+#if ULONG_MAX > 0xffffffff
+ /* Make sp_point[] arrays to not be 64-bit misaligned */
+ ALIGNED(8)
+#endif
+ ;
sp_digit y[8];
sp_digit z[8];
int infinity;
} sp_point;
/* The modulus (prime) of the curve P256. */
-static const sp_digit p256_mod[8] = {
+static const sp_digit p256_mod[8] ALIGNED(8) = {
0xffffffff,0xffffffff,0xffffffff,0x00000000,
0x00000000,0x00000000,0x00000001,0xffffffff,
};
@@ -903,7 +908,7 @@
* a First number to multiply in Montogmery form.
* b Second number to multiply in Montogmery form.
* m Modulus (prime).
- * mp Montogmery mulitplier.
+ * mp Montogmery multiplier.
*/
static void sp_256_mont_mul_8(sp_digit* r, const sp_digit* a, const sp_digit* b
/*, const sp_digit* m, sp_digit mp*/)
@@ -920,7 +925,7 @@
* r Result of squaring.
* a Number to square in Montogmery form.
* m Modulus (prime).
- * mp Montogmery mulitplier.
+ * mp Montogmery multiplier.
*/
static void sp_256_mont_sqr_8(sp_digit* r, const sp_digit* a
/*, const sp_digit* m, sp_digit mp*/)
@@ -1145,7 +1150,6 @@
return;
}
-
if (p->infinity || q->infinity) {
*r = p->infinity ? *q : *p; /* struct copy */
return;