AESNI support with EVP AES

This commit is contained in:
Jacob Barthelmeh
2016-11-09 16:25:12 -07:00
parent 8554912d68
commit 526b602ebd
3 changed files with 13 additions and 8 deletions

View File

@@ -1959,6 +1959,9 @@ int wc_AesSetKey(Aes* aes, const byte* userKey, word32 keylen,
checkAESNI = 1;
}
if (haveAESNI) {
#ifdef WOLFSSL_AES_COUNTER
aes->left = 0;
#endif /* WOLFSSL_AES_COUNTER */
aes->use_aesni = 1;
if (iv)
XMEMCPY(aes->reg, iv, AES_BLOCK_SIZE);

View File

@@ -7195,7 +7195,7 @@ int openssl_test(void)
(unsigned char*)ctr192Key, (unsigned char*)ctr192Iv, 0) == 0)
return -3316;
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;
EVP_CIPHER_CTX_init(&de);
if (EVP_CipherInit(&de, EVP_aes_192_ctr(),
@@ -7203,7 +7203,7 @@ int openssl_test(void)
return -3318;
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;
if (XMEMCMP(plainBuff, ctr192Plain, sizeof(ctr192Plain)))
@@ -7215,7 +7215,7 @@ int openssl_test(void)
if (EVP_CipherInit(&en, EVP_aes_256_ctr(),
(unsigned char*)ctr256Key, (unsigned char*)ctr256Iv, 0) == 0)
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;
EVP_CIPHER_CTX_init(&de);
if (EVP_CipherInit(&de, EVP_aes_256_ctr(),
@@ -7223,7 +7223,7 @@ int openssl_test(void)
return -3324;
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;
if (XMEMCMP(plainBuff, ctr256Plain, sizeof(ctr256Plain)))

View File

@@ -159,14 +159,16 @@ typedef struct WOLFSSL_EVP_CIPHER_CTX {
unsigned char enc; /* if encrypt side, then true */
unsigned char cipherType;
#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)
unsigned char iv[DES_BLOCK_SIZE]; /* working iv pointer into cipher */
/* working iv pointer into cipher */
ALIGN16 unsigned char iv[DES_BLOCK_SIZE];
#endif
WOLFSSL_Cipher cipher;
byte buf[WOLFSSL_EVP_BUF_SIZE];
ALIGN16 byte buf[WOLFSSL_EVP_BUF_SIZE];
int bufUsed;
byte fin[WOLFSSL_EVP_BUF_SIZE];
ALIGN16 byte fin[WOLFSSL_EVP_BUF_SIZE];
int finUsed;
} WOLFSSL_EVP_CIPHER_CTX;