forked from wolfSSL/wolfssl
use dynamic buffer for AES-NI encrypt
This commit is contained in:
@@ -2958,10 +2958,13 @@ static INLINE int Encrypt(CYASSL* ssl, byte* out, const byte* input, word32 sz)
|
|||||||
case aes:
|
case aes:
|
||||||
#ifdef CYASSL_AESNI
|
#ifdef CYASSL_AESNI
|
||||||
if ((word)input % 16) {
|
if ((word)input % 16) {
|
||||||
byte buff[MAX_RECORD_SIZE + MAX_COMP_EXTRA+MAX_MSG_EXTRA];
|
byte* tmp = (byte*)XMALLOC(sz, ssl->heap,
|
||||||
XMEMCPY(buff, input, sz);
|
DYNAMIC_TYPE_TMP_BUFFER);
|
||||||
AesCbcEncrypt(ssl->encrypt.aes, buff, buff, sz);
|
if (tmp == NULL) return MEMORY_E;
|
||||||
XMEMCPY(out, buff, sz);
|
XMEMCPY(tmp, input, sz);
|
||||||
|
AesCbcEncrypt(ssl->encrypt.aes, tmp, tmp, sz);
|
||||||
|
XMEMCPY(out, tmp, sz);
|
||||||
|
XFREE(tmp, ssl->heap, DYNAMIC_TYPE_TMP_BUFFER);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user