forked from wolfSSL/wolfssl
add AesSetKeyDirect for Ctr and Direct when also using aesni
This commit is contained in:
@@ -1027,6 +1027,13 @@ static void AesEncrypt(Aes* aes, const byte* inBlock, byte* outBlock)
|
|||||||
CYASSL_MSG("AesEncrypt encountered improper key, set it up");
|
CYASSL_MSG("AesEncrypt encountered improper key, set it up");
|
||||||
return; /* stop instead of segfaulting, set up your keys! */
|
return; /* stop instead of segfaulting, set up your keys! */
|
||||||
}
|
}
|
||||||
|
#ifdef CYASSL_AESNI
|
||||||
|
if (haveAESNI) {
|
||||||
|
CYASSL_MSG("AesEncrypt encountered aesni keysetup, don't use direct");
|
||||||
|
return; /* just stop now */
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* map byte array block to cipher state
|
* map byte array block to cipher state
|
||||||
* and add initial round key:
|
* and add initial round key:
|
||||||
@@ -1165,6 +1172,13 @@ static void AesDecrypt(Aes* aes, const byte* inBlock, byte* outBlock)
|
|||||||
CYASSL_MSG("AesDecrypt encountered improper key, set it up");
|
CYASSL_MSG("AesDecrypt encountered improper key, set it up");
|
||||||
return; /* stop instead of segfaulting, set up your keys! */
|
return; /* stop instead of segfaulting, set up your keys! */
|
||||||
}
|
}
|
||||||
|
#ifdef CYASSL_AESNI
|
||||||
|
if (haveAESNI) {
|
||||||
|
CYASSL_MSG("AesEncrypt encountered aesni keysetup, don't use direct");
|
||||||
|
return; /* just stop now */
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* map byte array block to cipher state
|
* map byte array block to cipher state
|
||||||
* and add initial round key:
|
* and add initial round key:
|
||||||
@@ -1381,6 +1395,18 @@ void AesDecryptDirect(Aes* aes, byte* out, const byte* in)
|
|||||||
#endif /* CYASSL_AES_DIRECT */
|
#endif /* CYASSL_AES_DIRECT */
|
||||||
|
|
||||||
|
|
||||||
|
#if defined(CYASSL_AES_DIRECT) || defined(CYASSL_AES_COUNTER)
|
||||||
|
|
||||||
|
/* AES-CTR and AES-DIRECT need to use this for key setup, no aesni yet */
|
||||||
|
int AesSetKeyDirect(Aes* aes, const byte* userKey, word32 keylen,
|
||||||
|
const byte* iv, int dir)
|
||||||
|
{
|
||||||
|
return AesSetKeyLocal(aes, userKey, keylen, iv, dir);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* CYASSL_AES_DIRECT || CYASSL_AES_COUNTER */
|
||||||
|
|
||||||
|
|
||||||
#ifdef CYASSL_AES_COUNTER
|
#ifdef CYASSL_AES_COUNTER
|
||||||
|
|
||||||
/* Increment AES counter */
|
/* Increment AES counter */
|
||||||
|
@@ -87,7 +87,8 @@ CYASSL_API void AesCbcDecrypt(Aes* aes, byte* out, const byte* in, word32 sz);
|
|||||||
CYASSL_API void AesCtrEncrypt(Aes* aes, byte* out, const byte* in, word32 sz);
|
CYASSL_API void AesCtrEncrypt(Aes* aes, byte* out, const byte* in, word32 sz);
|
||||||
CYASSL_API void AesEncryptDirect(Aes* aes, byte* out, const byte* in);
|
CYASSL_API void AesEncryptDirect(Aes* aes, byte* out, const byte* in);
|
||||||
CYASSL_API void AesDecryptDirect(Aes* aes, byte* out, const byte* in);
|
CYASSL_API void AesDecryptDirect(Aes* aes, byte* out, const byte* in);
|
||||||
|
CYASSL_API int AesSetKeyDirect(Aes* aes, const byte* key, word32 len,
|
||||||
|
const byte* iv, int dir);
|
||||||
#ifdef HAVE_AESGCM
|
#ifdef HAVE_AESGCM
|
||||||
CYASSL_API void AesGcmSetKey(Aes* aes, const byte* key, word32 len,
|
CYASSL_API void AesGcmSetKey(Aes* aes, const byte* key, word32 len,
|
||||||
const byte* implicitIV);
|
const byte* implicitIV);
|
||||||
|
Reference in New Issue
Block a user