forked from wolfSSL/wolfssl
adjust macro guards for additional functions
This commit is contained in:
@ -3373,6 +3373,7 @@ int wc_AesSetIV(Aes* aes, const byte* iv)
|
||||
#endif /* NEED_AES_CTR_SOFT */
|
||||
|
||||
#endif /* WOLFSSL_AES_COUNTER */
|
||||
#endif /* !WOLFSSL_ARMASM */
|
||||
|
||||
|
||||
/*
|
||||
@ -3409,6 +3410,9 @@ static WC_INLINE void IncCtr(byte* ctr, word32 ctrSz)
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef WOLFSSL_ARMASM
|
||||
/* implementation is located in wolfcrypt/src/port/arm/armv8-aes.c */
|
||||
#else /* software + AESNI implementation */
|
||||
|
||||
#if !defined(FREESCALE_LTC_AES_GCM)
|
||||
static WC_INLINE void IncrementGcmCounter(byte* inOutCtr)
|
||||
@ -9021,8 +9025,11 @@ int wc_AesGcmDecrypt(Aes* aes, byte* out, const byte* in, word32 sz,
|
||||
#endif
|
||||
#endif /* HAVE_AES_DECRYPT || HAVE_AESGCM_DECRYPT */
|
||||
#endif /* (WOLFSSL_XILINX_CRYPT) */
|
||||
#endif /* end of block for AESGCM implementation selection */
|
||||
|
||||
|
||||
/* Common to all, abstract functions that build off of lower level AESGCM
|
||||
* functions */
|
||||
#ifndef WC_NO_RNG
|
||||
|
||||
int wc_AesGcmSetExtIV(Aes* aes, const byte* iv, word32 ivSz)
|
||||
@ -9199,10 +9206,16 @@ WOLFSSL_API int wc_GmacUpdate(Gmac* gmac, const byte* iv, word32 ivSz,
|
||||
|
||||
int wc_AesCcmSetKey(Aes* aes, const byte* key, word32 keySz)
|
||||
{
|
||||
if (!((keySz == 16) || (keySz == 24) || (keySz == 32)))
|
||||
return BAD_FUNC_ARG;
|
||||
|
||||
return wc_AesSetKey(aes, key, keySz, NULL, AES_ENCRYPTION);
|
||||
}
|
||||
|
||||
#if defined(HAVE_COLDFIRE_SEC)
|
||||
#ifdef WOLFSSL_ARMASM
|
||||
/* implementation located in wolfcrypt/src/port/arm/armv8-aes.c */
|
||||
|
||||
#elif defined(HAVE_COLDFIRE_SEC)
|
||||
#error "Coldfire SEC doesn't currently support AES-CCM mode"
|
||||
|
||||
#elif defined(WOLFSSL_IMX6_CAAM) && !defined(NO_IMX6_CAAM_AES)
|
||||
@ -9508,7 +9521,9 @@ int wc_AesCcmDecrypt(Aes* aes, byte* out, const byte* in, word32 inSz,
|
||||
}
|
||||
|
||||
#endif /* HAVE_AES_DECRYPT */
|
||||
#endif /* software AES CCM */
|
||||
|
||||
/* abstract functions that call lower level AESCCM functions */
|
||||
#ifndef WC_NO_RNG
|
||||
|
||||
int wc_AesCcmSetNonce(Aes* aes, const byte* nonce, word32 nonceSz)
|
||||
@ -9572,7 +9587,6 @@ int wc_AesCcmEncrypt_ex(Aes* aes, byte* out, const byte* in, word32 sz,
|
||||
}
|
||||
|
||||
#endif /* WC_NO_RNG */
|
||||
#endif /* software AES CCM */
|
||||
|
||||
#endif /* HAVE_AESCCM */
|
||||
|
||||
@ -9641,7 +9655,6 @@ int wc_AesGetKeySize(Aes* aes, word32* keySize)
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif /* !WOLFSSL_ARMASM */
|
||||
#endif /* !WOLFSSL_TI_CRYPT */
|
||||
|
||||
#ifdef HAVE_AES_ECB
|
||||
|
@ -299,24 +299,6 @@ int wc_AesSetIV(Aes* aes, const byte* iv)
|
||||
}
|
||||
|
||||
|
||||
/* set the heap hint for aes struct */
|
||||
int wc_AesInit(Aes* aes, void* heap, int devId)
|
||||
{
|
||||
if (aes == NULL)
|
||||
return BAD_FUNC_ARG;
|
||||
|
||||
aes->heap = heap;
|
||||
(void)devId;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void wc_AesFree(Aes* aes)
|
||||
{
|
||||
(void)aes;
|
||||
}
|
||||
|
||||
|
||||
#ifdef __aarch64__
|
||||
/* AES CCM/GCM use encrypt direct but not decrypt */
|
||||
#if defined(HAVE_AESCCM) || defined(HAVE_AESGCM) || \
|
||||
@ -4364,18 +4346,6 @@ int wc_AesGcmDecrypt(Aes* aes, byte* out, const byte* in, word32 sz,
|
||||
/* Software version of AES-CCM from wolfcrypt/src/aes.c
|
||||
* Gets some speed up from hardware acceleration of wc_AesEncrypt */
|
||||
|
||||
int wc_AesCcmSetKey(Aes* aes, const byte* key, word32 keySz)
|
||||
{
|
||||
byte nonce[AES_BLOCK_SIZE];
|
||||
|
||||
if (!((keySz == 16) || (keySz == 24) || (keySz == 32)))
|
||||
return BAD_FUNC_ARG;
|
||||
|
||||
XMEMSET(nonce, 0, sizeof(nonce));
|
||||
return wc_AesSetKey(aes, key, keySz, nonce, AES_ENCRYPTION);
|
||||
}
|
||||
|
||||
|
||||
static void roll_x(Aes* aes, const byte* in, word32 inSz, byte* out)
|
||||
{
|
||||
/* process the bulk of the data */
|
||||
@ -4611,20 +4581,6 @@ int wc_AesCcmDecrypt(Aes* aes, byte* out, const byte* in, word32 inSz,
|
||||
|
||||
|
||||
#ifdef HAVE_AESGCM /* common GCM functions 32 and 64 bit */
|
||||
WOLFSSL_API int wc_GmacSetKey(Gmac* gmac, const byte* key, word32 len)
|
||||
{
|
||||
return wc_AesGcmSetKey(&gmac->aes, key, len);
|
||||
}
|
||||
|
||||
|
||||
WOLFSSL_API int wc_GmacUpdate(Gmac* gmac, const byte* iv, word32 ivSz,
|
||||
const byte* authIn, word32 authInSz,
|
||||
byte* authTag, word32 authTagSz)
|
||||
{
|
||||
return wc_AesGcmEncrypt(&gmac->aes, NULL, NULL, 0, iv, ivSz,
|
||||
authTag, authTagSz, authIn, authInSz);
|
||||
}
|
||||
|
||||
int wc_AesGcmSetKey(Aes* aes, const byte* key, word32 len)
|
||||
{
|
||||
int ret;
|
||||
@ -4694,32 +4650,5 @@ int wc_AesGcmSetKey(Aes* aes, const byte* key, word32 len)
|
||||
}
|
||||
#endif /* HAVE_AES_DECRYPT */
|
||||
#endif /* WOLFSSL_AES_DIRECT */
|
||||
|
||||
int wc_AesGetKeySize(Aes* aes, word32* keySize)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
if (aes == NULL || keySize == NULL) {
|
||||
return BAD_FUNC_ARG;
|
||||
}
|
||||
|
||||
switch (aes->rounds) {
|
||||
case 10:
|
||||
*keySize = 16;
|
||||
break;
|
||||
case 12:
|
||||
*keySize = 24;
|
||||
break;
|
||||
case 14:
|
||||
*keySize = 32;
|
||||
break;
|
||||
default:
|
||||
*keySize = 0;
|
||||
ret = BAD_FUNC_ARG;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif /* NO_AES */
|
||||
|
||||
|
Reference in New Issue
Block a user