Fix for building with NO_PUBLIC_GCM_SET_IV when ChaCha20/Poly1305 is enabled. Cleanup use of not used STD_PERI_LIB.

This commit is contained in:
David Garske
2020-05-22 08:24:57 -07:00
parent 3529d9a40d
commit 8791573dfe
4 changed files with 18 additions and 29 deletions

View File

@@ -13103,10 +13103,10 @@ static int DoDtlsHandShakeMsg(WOLFSSL* ssl, byte* input, word32* inOutIdx,
#ifdef HAVE_AEAD #ifdef HAVE_AEAD
#if !defined(NO_PUBLIC_GCM_SET_IV) && \ #if (!defined(NO_PUBLIC_GCM_SET_IV) && \
(((defined(HAVE_FIPS) || defined(HAVE_SELFTEST)) && \ ((defined(HAVE_FIPS) || defined(HAVE_SELFTEST)) && \
(!defined(HAVE_FIPS_VERSION) || (HAVE_FIPS_VERSION < 2))) || \ (!defined(HAVE_FIPS_VERSION) || (HAVE_FIPS_VERSION < 2)))) || \
(defined(HAVE_POLY1305) && defined(HAVE_CHACHA))) (defined(HAVE_POLY1305) && defined(HAVE_CHACHA))
static WC_INLINE void AeadIncrementExpIV(WOLFSSL* ssl) static WC_INLINE void AeadIncrementExpIV(WOLFSSL* ssl)
{ {
int i; int i;

View File

@@ -331,7 +331,7 @@
} }
HAL_CRYP_DeInit(&hcryp); HAL_CRYP_DeInit(&hcryp);
#else /* STD_PERI_LIB */ #else /* Standard Peripheral Library */
ret = wc_Stm32_Aes_Init(aes, &cryptInit, &keyInit); ret = wc_Stm32_Aes_Init(aes, &cryptInit, &keyInit);
if (ret != 0) if (ret != 0)
return ret; return ret;
@@ -415,7 +415,7 @@
} }
HAL_CRYP_DeInit(&hcryp); HAL_CRYP_DeInit(&hcryp);
#else /* STD_PERI_LIB */ #else /* Standard Peripheral Library */
ret = wc_Stm32_Aes_Init(aes, &cryptInit, &keyInit); ret = wc_Stm32_Aes_Init(aes, &cryptInit, &keyInit);
if (ret != 0) if (ret != 0)
return ret; return ret;
@@ -3065,7 +3065,7 @@ int wc_AesSetIV(Aes* aes, const byte* iv)
} }
#endif /* HAVE_AES_DECRYPT */ #endif /* HAVE_AES_DECRYPT */
#else /* STD_PERI_LIB */ #else /* Standard Peripheral Library */
int wc_AesCbcEncrypt(Aes* aes, byte* out, const byte* in, word32 sz) int wc_AesCbcEncrypt(Aes* aes, byte* out, const byte* in, word32 sz)
{ {
int ret; int ret;
@@ -3781,7 +3781,7 @@ int wc_AesSetIV(Aes* aes, const byte* iv)
} }
HAL_CRYP_DeInit(&hcryp); HAL_CRYP_DeInit(&hcryp);
#else /* STD_PERI_LIB */ #else /* Standard Peripheral Library */
ret = wc_Stm32_Aes_Init(aes, &cryptInit, &keyInit); ret = wc_Stm32_Aes_Init(aes, &cryptInit, &keyInit);
if (ret != 0) { if (ret != 0) {
wolfSSL_CryptHwMutexUnLock(); wolfSSL_CryptHwMutexUnLock();
@@ -6065,7 +6065,7 @@ static int wc_AesGcmEncrypt_STM32(Aes* aes, byte* out, const byte* in, word32 sz
ret = AES_GCM_AUTH_E; ret = AES_GCM_AUTH_E;
HAL_CRYP_DeInit(&hcryp); HAL_CRYP_DeInit(&hcryp);
#else /* STD_PERI_LIB */ #else /* Standard Peripheral Library */
ByteReverseWords(keyCopy, (word32*)aes->key, keySize); ByteReverseWords(keyCopy, (word32*)aes->key, keySize);
status = CRYP_AES_GCM(MODE_ENCRYPT, (uint8_t*)ctr, status = CRYP_AES_GCM(MODE_ENCRYPT, (uint8_t*)ctr,
(uint8_t*)keyCopy, keySize * 8, (uint8_t*)keyCopy, keySize * 8,
@@ -6277,15 +6277,9 @@ int wc_AesGcmEncrypt(Aes* aes, byte* out, const byte* in, word32 sz,
#endif /* WOLFSSL_ASYNC_CRYPT */ #endif /* WOLFSSL_ASYNC_CRYPT */
#ifdef STM32_CRYPTO_AES_GCM #ifdef STM32_CRYPTO_AES_GCM
/* The STM standard peripheral library API's doesn't support partial blocks */
#ifdef STD_PERI_LIB
if (partial == 0)
#endif
{
return wc_AesGcmEncrypt_STM32( return wc_AesGcmEncrypt_STM32(
aes, out, in, sz, iv, ivSz, aes, out, in, sz, iv, ivSz,
authTag, authTagSz, authIn, authInSz); authTag, authTagSz, authIn, authInSz);
}
#endif /* STM32_CRYPTO_AES_GCM */ #endif /* STM32_CRYPTO_AES_GCM */
#ifdef WOLFSSL_AESNI #ifdef WOLFSSL_AESNI
@@ -6507,7 +6501,7 @@ static int wc_AesGcmDecrypt_STM32(Aes* aes, byte* out,
HAL_CRYP_DeInit(&hcryp); HAL_CRYP_DeInit(&hcryp);
#else /* STD_PERI_LIB */ #else /* Standard Peripheral Library */
ByteReverseWords(keyCopy, (word32*)aes->key, aes->keylen); ByteReverseWords(keyCopy, (word32*)aes->key, aes->keylen);
/* Input size and auth size need to be the actual sizes, even though /* Input size and auth size need to be the actual sizes, even though
@@ -6732,14 +6726,9 @@ int wc_AesGcmDecrypt(Aes* aes, byte* out, const byte* in, word32 sz,
#ifdef STM32_CRYPTO_AES_GCM #ifdef STM32_CRYPTO_AES_GCM
/* The STM standard peripheral library API's doesn't support partial blocks */ /* The STM standard peripheral library API's doesn't support partial blocks */
#ifdef STD_PERI_LIB
if (partial == 0)
#endif
{
return wc_AesGcmDecrypt_STM32( return wc_AesGcmDecrypt_STM32(
aes, out, in, sz, iv, ivSz, aes, out, in, sz, iv, ivSz,
authTag, authTagSz, authIn, authInSz); authTag, authTagSz, authIn, authInSz);
}
#endif /* STM32_CRYPTO_AES_GCM */ #endif /* STM32_CRYPTO_AES_GCM */
#ifdef WOLFSSL_AESNI #ifdef WOLFSSL_AESNI

View File

@@ -299,7 +299,7 @@ int wc_Stm32_Aes_Init(Aes* aes, CRYP_HandleTypeDef* hcryp)
return 0; return 0;
} }
#else /* STD_PERI_LIB */ #else /* Standard Peripheral Library */
int wc_Stm32_Aes_Init(Aes* aes, CRYP_InitTypeDef* cryptInit, int wc_Stm32_Aes_Init(Aes* aes, CRYP_InitTypeDef* cryptInit,
CRYP_KeyInitTypeDef* keyInit) CRYP_KeyInitTypeDef* keyInit)

View File

@@ -122,7 +122,7 @@ int wc_Stm32_Hash_Final(STM32_HASH_Context* stmCtx, word32 algo,
struct Aes; struct Aes;
#ifdef WOLFSSL_STM32_CUBEMX #ifdef WOLFSSL_STM32_CUBEMX
int wc_Stm32_Aes_Init(struct Aes* aes, CRYP_HandleTypeDef* hcryp); int wc_Stm32_Aes_Init(struct Aes* aes, CRYP_HandleTypeDef* hcryp);
#else /* STD_PERI_LIB */ #else /* Standard Peripheral Library */
int wc_Stm32_Aes_Init(struct Aes* aes, CRYP_InitTypeDef* cryptInit, int wc_Stm32_Aes_Init(struct Aes* aes, CRYP_InitTypeDef* cryptInit,
CRYP_KeyInitTypeDef* keyInit); CRYP_KeyInitTypeDef* keyInit);
#endif /* WOLFSSL_STM32_CUBEMX */ #endif /* WOLFSSL_STM32_CUBEMX */