mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-07-29 18:27:29 +02:00
Minor improvements to the STM32 CubeMX AES-GCM logic.
This commit is contained in:
@ -8224,7 +8224,7 @@ static WC_INLINE int wc_AesGcmEncrypt_STM32(Aes* aes, byte* out, const byte* in,
|
||||
}
|
||||
XMEMCPY(outPadded, in, sz);
|
||||
|
||||
if ((authInSz % AES_BLOCK_SIZE) != 0) {
|
||||
if (authInSz == 0 || (authInSz % AES_BLOCK_SIZE) != 0) {
|
||||
/* Need to pad the AAD to a full block with zeros. */
|
||||
authPadSz = ((authInSz / AES_BLOCK_SIZE) + 1) * AES_BLOCK_SIZE;
|
||||
authInPadded = (byte*)XMALLOC(authPadSz, aes->heap,
|
||||
@ -8446,8 +8446,8 @@ int wc_AesGcmEncrypt(Aes* aes, byte* out, const byte* in, word32 sz,
|
||||
defined(WOLFSSL_STM32F7) || \
|
||||
defined(WOLFSSL_STM32L4))
|
||||
|
||||
/* additional argument checks - STM32 HW only supports 12 byte IV */
|
||||
if (ivSz == GCM_NONCE_MID_SZ) {
|
||||
/* STM32 HW only supports 12 byte IV and 16 byte auth */
|
||||
if (ivSz == GCM_NONCE_MID_SZ && authInSz == AES_BLOCK_SIZE) {
|
||||
return wc_AesGcmEncrypt_STM32(aes, out, in, sz, iv, ivSz,
|
||||
authTag, authTagSz, authIn, authInSz);
|
||||
}
|
||||
@ -8611,7 +8611,7 @@ static WC_INLINE int wc_AesGcmDecrypt_STM32(Aes* aes, byte* out,
|
||||
}
|
||||
XMEMCPY(outPadded, in, sz);
|
||||
|
||||
if ((authInSz % AES_BLOCK_SIZE) != 0) {
|
||||
if (authInSz == 0 || (authInSz % AES_BLOCK_SIZE) != 0) {
|
||||
/* Need to pad the AAD to a full block with zeros. */
|
||||
authPadSz = ((authInSz / AES_BLOCK_SIZE) + 1) * AES_BLOCK_SIZE;
|
||||
authInPadded = (byte*)XMALLOC(authPadSz, aes->heap,
|
||||
@ -8848,8 +8848,8 @@ int wc_AesGcmDecrypt(Aes* aes, byte* out, const byte* in, word32 sz,
|
||||
defined(WOLFSSL_STM32F7) || \
|
||||
defined(WOLFSSL_STM32L4))
|
||||
|
||||
/* additional argument checks - STM32 HW only supports 12 byte IV */
|
||||
if (ivSz == GCM_NONCE_MID_SZ) {
|
||||
/* STM32 HW only supports 12 byte IV and 16 byte auth */
|
||||
if (ivSz == GCM_NONCE_MID_SZ && authInSz == AES_BLOCK_SIZE) {
|
||||
return wc_AesGcmDecrypt_STM32(aes, out, in, sz, iv, ivSz,
|
||||
authTag, authTagSz, authIn, authInSz);
|
||||
}
|
||||
|
@ -769,7 +769,8 @@ initDefaultName();
|
||||
printf( "AES256 test passed!\n");
|
||||
#endif
|
||||
#ifdef HAVE_AESGCM
|
||||
#if !defined(WOLFSSL_AFALG) && !defined(WOLFSSL_DEVCRYPTO) && !defined(STM32_CRYPTO)
|
||||
#if !defined(WOLFSSL_AFALG) && !defined(WOLFSSL_DEVCRYPTO) && \
|
||||
!defined(STM32_CRYPTO)
|
||||
if ( (ret = aesgcm_test()) != 0)
|
||||
return err_sys("AES-GCM test failed!\n", ret);
|
||||
else
|
||||
@ -6630,8 +6631,8 @@ static int aesgcm_default_test_helper(byte* key, int keySz, byte* iv, int ivSz,
|
||||
byte* plain, int plainSz, byte* cipher, int cipherSz,
|
||||
byte* aad, int aadSz, byte* tag, int tagSz)
|
||||
{
|
||||
Aes enc;
|
||||
Aes dec;
|
||||
Aes enc;
|
||||
Aes dec;
|
||||
|
||||
byte resultT[AES_BLOCK_SIZE];
|
||||
byte resultP[AES_BLOCK_SIZE * 3];
|
||||
|
Reference in New Issue
Block a user