Skip to content

Commit

Permalink
AES GCM stream: arm asm fix when --enable-opensslextra
Browse files Browse the repository at this point in the history
aadLen is now in gcm field of Aes.
  • Loading branch information
SparkiDev committed Jul 10, 2023
1 parent f2809c5 commit 360b61a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
6 changes: 3 additions & 3 deletions wolfcrypt/src/port/af_alg/afalg_aes.c
Original file line number Diff line number Diff line change
Expand Up @@ -669,7 +669,7 @@ int wc_AesGcmEncrypt(Aes* aes, byte* out, const byte* in, word32 sz,
XMEMSET(initalCounter, 0, AES_BLOCK_SIZE);
XMEMCPY(initalCounter, iv, ivSz);
initalCounter[AES_BLOCK_SIZE - 1] = 1;
GHASH(aes, authIn, authInSz, out, sz, authTag, authTagSz);
GHASH(&aes->gcm, authIn, authInSz, out, sz, authTag, authTagSz);
ret = wc_AesEncryptDirect(aes, scratch, initalCounter);
if (ret < 0) {
return ret;
Expand Down Expand Up @@ -822,7 +822,7 @@ int wc_AesGcmDecrypt(Aes* aes, byte* out, const byte* in, word32 sz,
XMEMCPY(initalCounter, iv, ivSz);
initalCounter[AES_BLOCK_SIZE - 1] = 1;
tag = buf;
GHASH(aes, NULL, 0, in, sz, tag, AES_BLOCK_SIZE);
GHASH(&aes->gcm, NULL, 0, in, sz, tag, AES_BLOCK_SIZE);
ret = wc_AesEncryptDirect(aes, scratch, initalCounter);
if (ret < 0)
return ret;
Expand Down Expand Up @@ -874,7 +874,7 @@ int wc_AesGcmDecrypt(Aes* aes, byte* out, const byte* in, word32 sz,

/* check on tag */
if (authIn != NULL && authInSz > 0) {
GHASH(aes, authIn, authInSz, in, sz, tag, AES_BLOCK_SIZE);
GHASH(&aes->gcm, authIn, authInSz, in, sz, tag, AES_BLOCK_SIZE);
ret = wc_AesEncryptDirect(aes, scratch, initalCounter);
if (ret < 0)
return ret;
Expand Down
8 changes: 4 additions & 4 deletions wolfcrypt/src/port/arm/armv8-aes.c
Original file line number Diff line number Diff line change
Expand Up @@ -4721,13 +4721,13 @@ static void AesGcmInit_C(Aes* aes, const byte* iv, word32 ivSz)
else {
/* Counter is GHASH of IV. */
#ifdef OPENSSL_EXTRA
word32 aadTemp = aes->aadLen;
aes->aadLen = 0;
word32 aadTemp = aes->gcm.aadLen;
aes->gcm.aadLen = 0;
#endif
GHASH(&aes->gcm, NULL, 0, iv, ivSz, counter, AES_BLOCK_SIZE);
GMULT(counter, aes->gcm.H);
#ifdef OPENSSL_EXTRA
aes->aadLen = aadTemp;
aes->gcm.aadLen = aadTemp;
#endif
}

Expand Down Expand Up @@ -4816,7 +4816,7 @@ static void AesGcmFinal_C(Aes* aes, byte* authTag, word32 authTagSz)
xorbuf(authTag, AES_INITCTR(aes), authTagSz);
#ifdef OPENSSL_EXTRA
/* store AAD size for next call */
aes->aadLen = aes->aSz;
aes->gcm.aadLen = aes->aSz;
#endif
/* Zeroize last block to protect sensitive data. */
ForceZero(AES_LASTBLOCK(aes), AES_BLOCK_SIZE);
Expand Down
8 changes: 4 additions & 4 deletions wolfcrypt/src/port/xilinx/xil-aesgcm.c
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ static WC_INLINE int handle_aad( Aes* aes,
byte initalCounter[AES_BLOCK_SIZE] = { 0 };
XMEMCPY(initalCounter, iv, AEAD_NONCE_SZ);
initalCounter[AES_BLOCK_SIZE - 1] = 1;
GHASH(aes, authIn, authInSz, data, sz, authTag, AES_GCM_AUTH_SZ);
GHASH(&aes->gcm, authIn, authInSz, data, sz, authTag, AES_GCM_AUTH_SZ);
ret = wc_AesEncryptDirect(aes, scratch, initalCounter);
if (ret == 0)
xorbuf(authTag, scratch, AES_GCM_AUTH_SZ);
Expand Down Expand Up @@ -558,7 +558,7 @@ int wc_AesGcmEncrypt(Aes* aes, byte* out,
XMEMSET(initalCounter, 0, AES_BLOCK_SIZE);
XMEMCPY(initalCounter, iv, ivSz);
initalCounter[AES_BLOCK_SIZE - 1] = 1;
GHASH(aes, authIn, authInSz, out, sz, authTag, authTagSz);
GHASH(&aes->gcm, authIn, authInSz, out, sz, authTag, authTagSz);
ret = wc_AesEncryptDirect(aes, scratch, initalCounter);
if (ret < 0)
return ret;
Expand Down Expand Up @@ -597,7 +597,7 @@ int wc_AesGcmDecrypt(Aes* aes, byte* out,
XMEMCPY(initalCounter, iv, ivSz);
initalCounter[AES_BLOCK_SIZE - 1] = 1;
tag = buf;
GHASH(aes, NULL, 0, in, sz, tag, AES_GCM_AUTH_SZ);
GHASH(&aes->gcm, NULL, 0, in, sz, tag, AES_GCM_AUTH_SZ);
ret = wc_AesEncryptDirect(aes, scratch, initalCounter);
if (ret < 0)
return ret;
Expand All @@ -614,7 +614,7 @@ int wc_AesGcmDecrypt(Aes* aes, byte* out,

/* account for additional data */
if (authIn != NULL && authInSz > 0) {
GHASH(aes, authIn, authInSz, in, sz, tag, AES_GCM_AUTH_SZ);
GHASH(&aes->gcm, authIn, authInSz, in, sz, tag, AES_GCM_AUTH_SZ);
ret = wc_AesEncryptDirect(aes, scratch, initalCounter);
if (ret < 0)
return ret;
Expand Down

0 comments on commit 360b61a

Please sign in to comment.