From 8760e6ac3e60da7900cedabb701c0e613e2ea1df Mon Sep 17 00:00:00 2001 From: John Safranek Date: Wed, 10 Oct 2012 12:15:13 -0700 Subject: [PATCH] fixed build warnings & aes-gcm/ni conflict --- ctaocrypt/src/aes.c | 10 +++++++--- cyassl/ctaocrypt/aes.h | 3 +++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/ctaocrypt/src/aes.c b/ctaocrypt/src/aes.c index eabd0f4ee..b9268007e 100644 --- a/ctaocrypt/src/aes.c +++ b/ctaocrypt/src/aes.c @@ -743,7 +743,7 @@ static const word32 Td[5][256] = { #endif /* _MSC_VER */ -static int Check_CPU_support_AES() +static int Check_CPU_support_AES(void) { unsigned int a,b,c,d; cpuid(1,a,b,c,d); @@ -865,6 +865,9 @@ static int AesSetKeyLocal(Aes* aes, const byte* userKey, word32 keylen, word32 temp, *rk = aes->key; unsigned int i = 0; + #ifdef CYASSL_AESNI + aes->use_aesni = 0; + #endif /* CYASSL_AESNI */ aes->rounds = keylen/4 + 6; XMEMCPY(rk, userKey, keylen); @@ -1003,6 +1006,7 @@ int AesSetKey(Aes* aes, const byte* userKey, word32 keylen, const byte* iv, checkAESNI = 1; } if (haveAESNI) { + aes->use_aesni = 1; if (iv) XMEMCPY(aes->reg, iv, AES_BLOCK_SIZE); if (dir == AES_ENCRYPTION) @@ -1028,7 +1032,7 @@ static void AesEncrypt(Aes* aes, const byte* inBlock, byte* outBlock) return; /* stop instead of segfaulting, set up your keys! */ } #ifdef CYASSL_AESNI - if (haveAESNI) { + if (aes->use_aesni) { CYASSL_MSG("AesEncrypt encountered aesni keysetup, don't use direct"); return; /* just stop now */ } @@ -1173,7 +1177,7 @@ static void AesDecrypt(Aes* aes, const byte* inBlock, byte* outBlock) return; /* stop instead of segfaulting, set up your keys! */ } #ifdef CYASSL_AESNI - if (haveAESNI) { + if (aes->use_aesni) { CYASSL_MSG("AesEncrypt encountered aesni keysetup, don't use direct"); return; /* just stop now */ } diff --git a/cyassl/ctaocrypt/aes.h b/cyassl/ctaocrypt/aes.h index e8dc53312..8f1dc327d 100644 --- a/cyassl/ctaocrypt/aes.h +++ b/cyassl/ctaocrypt/aes.h @@ -76,6 +76,9 @@ typedef struct Aes { ALIGN16 byte M0[256][AES_BLOCK_SIZE]; #endif /* GCM_TABLE */ #endif /* HAVE_AESGCM */ +#ifdef CYASSL_AESNI + byte use_aesni; +#endif /* CYASSL_AESNI */ } Aes;