mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-07-29 18:27:29 +02:00
ARMv8 ASM AES-CBC: Fix parameter validation
This commit is contained in:
@ -461,10 +461,20 @@ int wc_AesSetIV(Aes* aes, const byte* iv)
|
||||
{
|
||||
word32 numBlocks = sz / AES_BLOCK_SIZE;
|
||||
|
||||
if (aes == NULL || out == NULL || (in == NULL && sz > 0)) {
|
||||
if (aes == NULL || out == NULL || in == NULL) {
|
||||
return BAD_FUNC_ARG;
|
||||
}
|
||||
|
||||
if (sz == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef WOLFSSL_AES_CBC_LENGTH_CHECKS
|
||||
if (sz % AES_BLOCK_SIZE) {
|
||||
return BAD_LENGTH_E;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* do as many block size ops as possible */
|
||||
if (numBlocks > 0) {
|
||||
word32* key = aes->key;
|
||||
@ -665,11 +675,22 @@ int wc_AesSetIV(Aes* aes, const byte* iv)
|
||||
{
|
||||
word32 numBlocks = sz / AES_BLOCK_SIZE;
|
||||
|
||||
if (aes == NULL || out == NULL || (in == NULL && sz > 0)
|
||||
|| sz % AES_BLOCK_SIZE != 0) {
|
||||
if (aes == NULL || out == NULL || in == NULL) {
|
||||
return BAD_FUNC_ARG;
|
||||
}
|
||||
|
||||
if (sz == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (sz % AES_BLOCK_SIZE) {
|
||||
#ifdef WOLFSSL_AES_CBC_LENGTH_CHECKS
|
||||
return BAD_LENGTH_E;
|
||||
#else
|
||||
return BAD_FUNC_ARG;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* do as many block size ops as possible */
|
||||
if (numBlocks > 0) {
|
||||
word32* key = aes->key;
|
||||
@ -3043,10 +3064,20 @@ int wc_AesGcmDecrypt(Aes* aes, byte* out, const byte* in, word32 sz,
|
||||
{
|
||||
word32 numBlocks = sz / AES_BLOCK_SIZE;
|
||||
|
||||
if (aes == NULL || out == NULL || (in == NULL && sz > 0)) {
|
||||
if (aes == NULL || out == NULL || in == NULL) {
|
||||
return BAD_FUNC_ARG;
|
||||
}
|
||||
|
||||
if (sz == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef WOLFSSL_AES_CBC_LENGTH_CHECKS
|
||||
if (sz % AES_BLOCK_SIZE) {
|
||||
return BAD_LENGTH_E;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* do as many block size ops as possible */
|
||||
if (numBlocks > 0) {
|
||||
word32* keyPt = aes->key;
|
||||
@ -3275,11 +3306,22 @@ int wc_AesGcmDecrypt(Aes* aes, byte* out, const byte* in, word32 sz,
|
||||
{
|
||||
word32 numBlocks = sz / AES_BLOCK_SIZE;
|
||||
|
||||
if (aes == NULL || out == NULL || (in == NULL && sz > 0)
|
||||
|| sz % AES_BLOCK_SIZE != 0) {
|
||||
if (aes == NULL || out == NULL || in == NULL) {
|
||||
return BAD_FUNC_ARG;
|
||||
}
|
||||
|
||||
if (sz == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (sz % AES_BLOCK_SIZE) {
|
||||
#ifdef WOLFSSL_AES_CBC_LENGTH_CHECKS
|
||||
return BAD_LENGTH_E;
|
||||
#else
|
||||
return BAD_FUNC_ARG;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* do as many block size ops as possible */
|
||||
if (numBlocks > 0) {
|
||||
word32* keyPt = aes->key;
|
||||
|
Reference in New Issue
Block a user