forked from wolfSSL/wolfssl
AES SIV: Allocate memory for AES as late as possbile
AES will be initialized if memory allocation succeeded.
This commit is contained in:
@@ -12345,15 +12345,6 @@ static WARN_UNUSED_RESULT int AesSivCipher(
|
||||
ret = BAD_FUNC_ARG;
|
||||
}
|
||||
|
||||
#ifdef WOLFSSL_SMALL_STACK
|
||||
if (ret == 0) {
|
||||
aes = (Aes*)XMALLOC(sizeof(Aes), NULL, DYNAMIC_TYPE_AES);
|
||||
if (aes == NULL) {
|
||||
ret = MEMORY_E;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (ret == 0) {
|
||||
if (enc == 1) {
|
||||
ret = S2V(key, keySz / 2, assoc, assocSz, nonce, nonceSz, data,
|
||||
@@ -12370,6 +12361,15 @@ static WARN_UNUSED_RESULT int AesSivCipher(
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef WOLFSSL_SMALL_STACK
|
||||
if (ret == 0) {
|
||||
aes = (Aes*)XMALLOC(sizeof(Aes), NULL, DYNAMIC_TYPE_AES);
|
||||
if (aes == NULL) {
|
||||
ret = MEMORY_E;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (ret == 0) {
|
||||
ret = wc_AesInit(aes, NULL, INVALID_DEVID);
|
||||
if (ret != 0) {
|
||||
|
Reference in New Issue
Block a user