mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-08-03 20:54:41 +02:00
AESNI support with EVP AES
This commit is contained in:
@@ -1959,6 +1959,9 @@ int wc_AesSetKey(Aes* aes, const byte* userKey, word32 keylen,
|
|||||||
checkAESNI = 1;
|
checkAESNI = 1;
|
||||||
}
|
}
|
||||||
if (haveAESNI) {
|
if (haveAESNI) {
|
||||||
|
#ifdef WOLFSSL_AES_COUNTER
|
||||||
|
aes->left = 0;
|
||||||
|
#endif /* WOLFSSL_AES_COUNTER */
|
||||||
aes->use_aesni = 1;
|
aes->use_aesni = 1;
|
||||||
if (iv)
|
if (iv)
|
||||||
XMEMCPY(aes->reg, iv, AES_BLOCK_SIZE);
|
XMEMCPY(aes->reg, iv, AES_BLOCK_SIZE);
|
||||||
|
@@ -7195,7 +7195,7 @@ int openssl_test(void)
|
|||||||
(unsigned char*)ctr192Key, (unsigned char*)ctr192Iv, 0) == 0)
|
(unsigned char*)ctr192Key, (unsigned char*)ctr192Iv, 0) == 0)
|
||||||
return -3316;
|
return -3316;
|
||||||
printf("EVP_Cipher\n");
|
printf("EVP_Cipher\n");
|
||||||
if (EVP_Cipher(&en, (byte*)cipherBuff, (byte*)ctr192Plain, AES_BLOCK_SIZE*4) == 0)
|
if (EVP_Cipher(&en, (byte*)cipherBuff, (byte*)ctr192Plain, AES_BLOCK_SIZE) == 0)
|
||||||
return -3317;
|
return -3317;
|
||||||
EVP_CIPHER_CTX_init(&de);
|
EVP_CIPHER_CTX_init(&de);
|
||||||
if (EVP_CipherInit(&de, EVP_aes_192_ctr(),
|
if (EVP_CipherInit(&de, EVP_aes_192_ctr(),
|
||||||
@@ -7203,7 +7203,7 @@ int openssl_test(void)
|
|||||||
return -3318;
|
return -3318;
|
||||||
|
|
||||||
XMEMSET(plainBuff, 0, sizeof(plainBuff));
|
XMEMSET(plainBuff, 0, sizeof(plainBuff));
|
||||||
if (EVP_Cipher(&de, (byte*)plainBuff, (byte*)cipherBuff, AES_BLOCK_SIZE*4) == 0)
|
if (EVP_Cipher(&de, (byte*)plainBuff, (byte*)cipherBuff, AES_BLOCK_SIZE) == 0)
|
||||||
return -3319;
|
return -3319;
|
||||||
|
|
||||||
if (XMEMCMP(plainBuff, ctr192Plain, sizeof(ctr192Plain)))
|
if (XMEMCMP(plainBuff, ctr192Plain, sizeof(ctr192Plain)))
|
||||||
@@ -7215,7 +7215,7 @@ int openssl_test(void)
|
|||||||
if (EVP_CipherInit(&en, EVP_aes_256_ctr(),
|
if (EVP_CipherInit(&en, EVP_aes_256_ctr(),
|
||||||
(unsigned char*)ctr256Key, (unsigned char*)ctr256Iv, 0) == 0)
|
(unsigned char*)ctr256Key, (unsigned char*)ctr256Iv, 0) == 0)
|
||||||
return -3322;
|
return -3322;
|
||||||
if (EVP_Cipher(&en, (byte*)cipherBuff, (byte*)ctr256Plain, AES_BLOCK_SIZE*4) == 0)
|
if (EVP_Cipher(&en, (byte*)cipherBuff, (byte*)ctr256Plain, AES_BLOCK_SIZE) == 0)
|
||||||
return -3323;
|
return -3323;
|
||||||
EVP_CIPHER_CTX_init(&de);
|
EVP_CIPHER_CTX_init(&de);
|
||||||
if (EVP_CipherInit(&de, EVP_aes_256_ctr(),
|
if (EVP_CipherInit(&de, EVP_aes_256_ctr(),
|
||||||
@@ -7223,7 +7223,7 @@ int openssl_test(void)
|
|||||||
return -3324;
|
return -3324;
|
||||||
|
|
||||||
XMEMSET(plainBuff, 0, sizeof(plainBuff));
|
XMEMSET(plainBuff, 0, sizeof(plainBuff));
|
||||||
if (EVP_Cipher(&de, (byte*)plainBuff, (byte*)cipherBuff, AES_BLOCK_SIZE*4) == 0)
|
if (EVP_Cipher(&de, (byte*)plainBuff, (byte*)cipherBuff, AES_BLOCK_SIZE) == 0)
|
||||||
return -3325;
|
return -3325;
|
||||||
|
|
||||||
if (XMEMCMP(plainBuff, ctr256Plain, sizeof(ctr256Plain)))
|
if (XMEMCMP(plainBuff, ctr256Plain, sizeof(ctr256Plain)))
|
||||||
|
@@ -159,14 +159,16 @@ typedef struct WOLFSSL_EVP_CIPHER_CTX {
|
|||||||
unsigned char enc; /* if encrypt side, then true */
|
unsigned char enc; /* if encrypt side, then true */
|
||||||
unsigned char cipherType;
|
unsigned char cipherType;
|
||||||
#ifndef NO_AES
|
#ifndef NO_AES
|
||||||
unsigned char iv[AES_BLOCK_SIZE]; /* working iv pointer into cipher */
|
/* working iv pointer into cipher */
|
||||||
|
ALIGN16 unsigned char iv[AES_BLOCK_SIZE];
|
||||||
#elif !defined(NO_DES3)
|
#elif !defined(NO_DES3)
|
||||||
unsigned char iv[DES_BLOCK_SIZE]; /* working iv pointer into cipher */
|
/* working iv pointer into cipher */
|
||||||
|
ALIGN16 unsigned char iv[DES_BLOCK_SIZE];
|
||||||
#endif
|
#endif
|
||||||
WOLFSSL_Cipher cipher;
|
WOLFSSL_Cipher cipher;
|
||||||
byte buf[WOLFSSL_EVP_BUF_SIZE];
|
ALIGN16 byte buf[WOLFSSL_EVP_BUF_SIZE];
|
||||||
int bufUsed;
|
int bufUsed;
|
||||||
byte fin[WOLFSSL_EVP_BUF_SIZE];
|
ALIGN16 byte fin[WOLFSSL_EVP_BUF_SIZE];
|
||||||
int finUsed;
|
int finUsed;
|
||||||
} WOLFSSL_EVP_CIPHER_CTX;
|
} WOLFSSL_EVP_CIPHER_CTX;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user