Skip to content

Commit af63867

Browse files
committed
AES GCM ARM32 alignment fix
Don't use xorbufout in GMULT. Force the table to be aligned.
1 parent 1149522 commit af63867

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

wolfcrypt/src/aes.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5039,7 +5039,7 @@ void GHASH(Gcm* gcm, const byte* a, word32 aSz, const byte* c,
50395039
/* end GCM_SMALL */
50405040
#elif defined(GCM_TABLE)
50415041

5042-
static const byte R[256][2] = {
5042+
ALIGN16 static const byte R[256][2] = {
50435043
{0x00, 0x00}, {0x01, 0xc2}, {0x03, 0x84}, {0x02, 0x46},
50445044
{0x07, 0x08}, {0x06, 0xca}, {0x04, 0x8c}, {0x05, 0x4e},
50455045
{0x0e, 0x10}, {0x0f, 0xd2}, {0x0d, 0x94}, {0x0c, 0x56},
@@ -5134,6 +5134,7 @@ static void GMULT(byte *x, byte m[256][AES_BLOCK_SIZE])
51345134
byte a;
51355135
word32* pZ;
51365136
word32* pm;
5137+
word32* px = (word32*)(x);
51375138
int i;
51385139

51395140
pZ = (word32*)(Z + 15 + 1);
@@ -5156,7 +5157,10 @@ static void GMULT(byte *x, byte m[256][AES_BLOCK_SIZE])
51565157
Z[i] = R[a][0];
51575158
Z[i+1] ^= R[a][1];
51585159
}
5159-
xorbufout(x, Z+1, m[x[0]], AES_BLOCK_SIZE);
5160+
pZ = (word32*)(Z + 1);
5161+
pm = (word32*)(m[x[0]]);
5162+
px[0] = pZ[0] ^ pm[0]; px[1] = pZ[1] ^ pm[1];
5163+
px[2] = pZ[2] ^ pm[2]; px[3] = pZ[3] ^ pm[3];
51605164
#else
51615165
byte Z[AES_BLOCK_SIZE + AES_BLOCK_SIZE];
51625166
byte a;

0 commit comments

Comments
 (0)