Skip to content

Commit 5e4baf8

Browse files
Merge pull request #6786 from SparkiDev/aes_gcm_align_arm_fix
AES GCM ARM32 alignment fix
2 parents 7f562f8 + af63867 commit 5e4baf8

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
@@ -5192,7 +5192,7 @@ void GHASH(Gcm* gcm, const byte* a, word32 aSz, const byte* c,
51925192
/* end GCM_SMALL */
51935193
#elif defined(GCM_TABLE)
51945194

5195-
static const byte R[256][2] = {
5195+
ALIGN16 static const byte R[256][2] = {
51965196
{0x00, 0x00}, {0x01, 0xc2}, {0x03, 0x84}, {0x02, 0x46},
51975197
{0x07, 0x08}, {0x06, 0xca}, {0x04, 0x8c}, {0x05, 0x4e},
51985198
{0x0e, 0x10}, {0x0f, 0xd2}, {0x0d, 0x94}, {0x0c, 0x56},
@@ -5287,6 +5287,7 @@ static void GMULT(byte *x, byte m[256][AES_BLOCK_SIZE])
52875287
byte a;
52885288
word32* pZ;
52895289
word32* pm;
5290+
word32* px = (word32*)(x);
52905291
int i;
52915292

52925293
pZ = (word32*)(Z + 15 + 1);
@@ -5309,7 +5310,10 @@ static void GMULT(byte *x, byte m[256][AES_BLOCK_SIZE])
53095310
Z[i] = R[a][0];
53105311
Z[i+1] ^= R[a][1];
53115312
}
5312-
xorbufout(x, Z+1, m[x[0]], AES_BLOCK_SIZE);
5313+
pZ = (word32*)(Z + 1);
5314+
pm = (word32*)(m[x[0]]);
5315+
px[0] = pZ[0] ^ pm[0]; px[1] = pZ[1] ^ pm[1];
5316+
px[2] = pZ[2] ^ pm[2]; px[3] = pZ[3] ^ pm[3];
53135317
#else
53145318
byte Z[AES_BLOCK_SIZE + AES_BLOCK_SIZE];
53155319
byte a;

0 commit comments

Comments
 (0)