Skip to content

Commit ba47f7f

Browse files
committed
AES-GCM small ARM asm: add back implementation
Implementation of GCM mult with length for ARM asm and small GCM was added to armv8-aes.c but got lost when code pulled back to aes.c.
1 parent 59f4fa5 commit ba47f7f

File tree

1 file changed

+29
-2
lines changed

1 file changed

+29
-2
lines changed

wolfcrypt/src/aes.c

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7459,8 +7459,35 @@ void GHASH(Gcm* gcm, const byte* a, word32 aSz, const byte* c,
74597459
#endif /* WOLFSSL_AESGCM_STREAM */
74607460

74617461
#ifdef WOLFSSL_ARMASM
7462-
#define GCM_GMULT_LEN(gcm, x, a, len) \
7463-
GCM_gmult_len(x, (const byte**)((gcm)->M0), a, len)
7462+
static void GCM_gmult_len(byte* x, const byte* h, const unsigned char* a,
7463+
unsigned long len)
7464+
{
7465+
byte Z[AES_BLOCK_SIZE];
7466+
byte V[AES_BLOCK_SIZE];
7467+
int i;
7468+
int j;
7469+
7470+
while (len >= AES_BLOCK_SIZE) {
7471+
xorbuf(x, a, AES_BLOCK_SIZE);
7472+
XMEMSET(Z, 0, AES_BLOCK_SIZE);
7473+
XMEMCPY(V, x, AES_BLOCK_SIZE);
7474+
for (i = 0; i < AES_BLOCK_SIZE; i++) {
7475+
byte y = h[i];
7476+
for (j = 0; j < 8; j++) {
7477+
if (y & 0x80) {
7478+
xorbuf(Z, V, AES_BLOCK_SIZE);
7479+
}
7480+
RIGHTSHIFTX(V);
7481+
y = y << 1;
7482+
}
7483+
}
7484+
XMEMCPY(x, Z, AES_BLOCK_SIZE);
7485+
len -= AES_BLOCK_SIZE;
7486+
a += AES_BLOCK_SIZE;
7487+
}
7488+
}
7489+
7490+
#define GCM_GMULT_LEN(gcm, x, a, len) GCM_gmult_len(x, (gcm)->H, a, len)
74647491
#endif
74657492

74667493
#elif defined(GCM_TABLE)

0 commit comments

Comments
 (0)