From e3826d26c5e2d47aaf2a998284ac23b6db96ab21 Mon Sep 17 00:00:00 2001 From: Jacob Barthelmeh Date: Wed, 7 Jan 2015 15:03:54 -0700 Subject: [PATCH] refactor settings_comp to respective .h files --- cyassl/ctaocrypt/aes.h | 33 ++++++++ cyassl/ctaocrypt/des3.h | 15 ++++ cyassl/ctaocrypt/hmac.h | 11 +++ cyassl/ctaocrypt/rsa.h | 20 +++++ cyassl/ctaocrypt/settings_comp.h | 132 ------------------------------- cyassl/ctaocrypt/sha.h | 4 + cyassl/ctaocrypt/sha256.h | 4 + cyassl/ctaocrypt/sha512.h | 11 +++ tests/hash.c | 8 +- 9 files changed, 102 insertions(+), 136 deletions(-) diff --git a/cyassl/ctaocrypt/aes.h b/cyassl/ctaocrypt/aes.h index 59b537a87..88ae91f2d 100644 --- a/cyassl/ctaocrypt/aes.h +++ b/cyassl/ctaocrypt/aes.h @@ -26,6 +26,39 @@ #define CTAO_CRYPT_AES_H #include +#define AesSetKey wc_AesSetKey +#define AesSetIV wc_AesSetIV +#define AesCbcEncrypt wc_AesCbcEncrypt +#define AesCbcDecrypt wc_AesCbcDecrypt +#define AesCbcDecryptWithKey wc_AesCbcDecryptWithKey + +/* AES-CTR */ +#ifdef WOLFSSL_AES_COUNTER + #define AesCtrEncrypt wc_AesCtrEncrypt +#endif +/* AES-DIRECT */ +#if defined(WOLFSSL_AES_DIRECT) + #define AesEncryptDirect wc_AesEncryptDirect + #define AesDecryptDirect wc_AesDecryptDirect + #define AesSetKeyDirect wc_AesSetKeyDirect +#endif +#ifdef HAVE_AESGCM + #define AesGcmSetKey wc_AesGcmSetKey + #define AesGcmEncrypt wc_AesGcmEncrypt + #define AesGcmDecrypt wc_AesGcmDecrypt + #define GmacSetKey wc_GmacSetKey + #define GmacUpdate wc_GmacUpdate +#endif /* HAVE_AESGCM */ +#ifdef HAVE_AESCCM + #define AesCcmSetKey wc_AesCcmSetKey + #define AesCcmEncrypt wc_AesCcmEncrypt + #define AesCcmDecrypt wc_AesCcmDecrypt +#endif /* HAVE_AESCCM */ + +#ifdef HAVE_CAVIUM + #define AesInitCavium wc_AesInitCavium + #define AesFreeCavium wc_AesFreeCavium +#endif #endif /* CTAO_CRYPT_AES_H */ #endif /* NO_AES */ diff --git a/cyassl/ctaocrypt/des3.h b/cyassl/ctaocrypt/des3.h index ea6712497..a47879f20 100644 --- a/cyassl/ctaocrypt/des3.h +++ b/cyassl/ctaocrypt/des3.h @@ -27,6 +27,21 @@ #include +#define Des_SetKey wc_Des_SetKey +#define Des_SetIV wc_Des_SetIV +#define Des_CbcEncrypt wc_Des_CbcEncrypt +#define Des_CbcDecrypt wc_Des_CbcDecrypt +#define Des_EcbEncrypt wc_Des_EcbEncrypt +#define Des_CbcDecryptWithKey wc_Des_CbcDecryptWithKey +#define Des3_SetKey wc_Des3_SetKey +#define Des3_SetIV wc_Des3_SetIV +#define Des3_CbcEncrypt wc_Des3_CbcEncrypt +#define Des3_CbcDecrypt wc_Des3_CbcDecrypt +#define Des3_CbcDecryptWithKey wc_Des3_CbcDecryptWithKey +#ifdef HAVE_CAVIUM + #define Des3_InitCavium wc_Des3_InitCavium + #define Des3_FreeCavium wc_Des3_FreeCavium +#endif #endif /* NO_DES3 */ #endif /* CTAO_CRYPT_DES3_H */ diff --git a/cyassl/ctaocrypt/hmac.h b/cyassl/ctaocrypt/hmac.h index 76c9323be..dcfb33ef4 100644 --- a/cyassl/ctaocrypt/hmac.h +++ b/cyassl/ctaocrypt/hmac.h @@ -26,6 +26,17 @@ #define CTAO_CRYPT_HMAC_H #include +#define HmacSetKey wc_HmacSetKey +#define HmacUpdate wc_HmacUpdate +#define HmacFinal wc_HmacFinal +#ifdef HAVE_CAVIUM + #define HmacInitCavium wc_HmacInitCavium + #define HmacFreeCavium wc_HmacFreeCavium +#endif +#define wolfSSL_GetHmacMaxSize wc_wolfSSL_GetHmacMaxSize +#ifdef HAVE_HKDF + #define HKDF wc_HKDF +#endif /* HAVE_HKDF */ #endif /* CTAO_CRYPT_HMAC_H */ diff --git a/cyassl/ctaocrypt/rsa.h b/cyassl/ctaocrypt/rsa.h index 92e8f0b54..d102aaac0 100644 --- a/cyassl/ctaocrypt/rsa.h +++ b/cyassl/ctaocrypt/rsa.h @@ -25,6 +25,26 @@ #define CTAO_CRYPT_RSA_H #include +#define InitRsaKey wc_InitRsaKey +#define FreeRsaKey wc_FreeRsaKey +#define RsaPublicEncrypt wc_RsaPublicEncrypt +#define RsaPrivateDecryptInline wc_RsaPrivateDecryptInline +#define RsaPrivateDecrypt wc_RsaPrivateDecrypt +#define RsaSSL_Sign wc_RsaSSL_Sign +#define RsaSSL_VerifyInline wc_RsaSSL_VerifyInline +#define RsaSSL_Verify wc_RsaSSL_Verify +#define RsaEncryptSize wc_RsaEncryptSize +#define RsaFlattenPublicKey wc_RsaFlattenPublicKey + +#ifdef WOLFSSL_KEY_GEN + #define MakeRsaKey wc_MakeRsaKey + #define RsaKeyToDer wc_RsaKeyToDer +#endif + +#ifdef HAVE_CAVIUM + #define RsaInitCavium wc_RsaInitCavium + #define RsaFreeCavium wc_RsaFreeCavium +#endif #endif /* CTAO_CRYPT_RSA_H */ diff --git a/cyassl/ctaocrypt/settings_comp.h b/cyassl/ctaocrypt/settings_comp.h index 770befe00..0b8ad68b0 100644 --- a/cyassl/ctaocrypt/settings_comp.h +++ b/cyassl/ctaocrypt/settings_comp.h @@ -41,137 +41,5 @@ #define NO_CYASSL_MEMORY #endif -/* These are compatibility from fips protected headers - * When using non-fips mode and including old headers this allows for - * using old function calls - */ -#ifndef HAVE_FIPS - #ifndef NO_AES - #include - #define AesSetKey wc_AesSetKey - #define AesSetIV wc_AesSetIV - #define AesCbcEncrypt wc_AesCbcEncrypt - #define AesCbcDecrypt wc_AesCbcDecrypt - #define AesCbcDecryptWithKey wc_AesCbcDecryptWithKey - - /* AES-CTR */ - #ifdef WOLFSSL_AES_COUNTER - #define AesCtrEncrypt wc_AesCtrEncrypt - #endif - /* AES-DIRECT */ - #if defined(WOLFSSL_AES_DIRECT) - #define AesEncryptDirect wc_AesEncryptDirect - #define AesDecryptDirect wc_AesDecryptDirect - #define AesSetKeyDirect wc_AesSetKeyDirect - #endif - #ifdef HAVE_AESGCM - #define AesGcmSetKey wc_AesGcmSetKey - #define AesGcmEncrypt wc_AesGcmEncrypt - #define AesGcmDecrypt wc_AesGcmDecrypt - #define GmacSetKey wc_GmacSetKey - #define GmacUpdate wc_GmacUpdate - #endif /* HAVE_AESGCM */ - #ifdef HAVE_AESCCM - #define AesCcmSetKey wc_AesCcmSetKey - #define AesCcmEncrypt wc_AesCcmEncrypt - #define AesCcmDecrypt wc_AesCcmDecrypt - #endif /* HAVE_AESCCM */ - - #ifdef HAVE_CAVIUM - #define AesInitCavium wc_AesInitCavium - #define AesFreeCavium wc_AesFreeCavium - #endif - #endif /* NO_AES */ - - #ifndef NO_RSA - #include - #define InitRsaKey wc_InitRsaKey - #define FreeRsaKey wc_FreeRsaKey - #define RsaPublicEncrypt wc_RsaPublicEncrypt - #define RsaPrivateDecryptInline wc_RsaPrivateDecryptInline - #define RsaPrivateDecrypt wc_RsaPrivateDecrypt - #define RsaSSL_Sign wc_RsaSSL_Sign - #define RsaSSL_VerifyInline wc_RsaSSL_VerifyInline - #define RsaSSL_Verify wc_RsaSSL_Verify - #define RsaEncryptSize wc_RsaEncryptSize - #define RsaFlattenPublicKey wc_RsaFlattenPublicKey - - #ifdef WOLFSSL_KEY_GEN - #define MakeRsaKey wc_MakeRsaKey - #define RsaKeyToDer wc_RsaKeyToDer - #endif - - #ifdef HAVE_CAVIUM - #define RsaInitCavium wc_RsaInitCavium - #define RsaFreeCavium wc_RsaFreeCavium - #endif - #endif /* NO_RSA */ - - #ifndef NO_HMAC - #include - #define HmacSetKey wc_HmacSetKey - #define HmacUpdate wc_HmacUpdate - #define HmacFinal wc_HmacFinal - #ifdef HAVE_CAVIUM - #define HmacInitCavium wc_HmacInitCavium - #define HmacFreeCavium wc_HmacFreeCavium - #endif - #define wolfSSL_GetHmacMaxSize wc_wolfSSL_GetHmacMaxSize - #ifdef HAVE_HKDF - #define HKDF wc_HKDF - #endif /* HAVE_HKDF */ - #endif /* NO_HMAC */ - - #ifndef NO_DES3 - #include - #define Des_SetKey wc_Des_SetKey - #define Des_SetIV wc_Des_SetIV - #define Des_CbcEncrypt wc_Des_CbcEncrypt - #define Des_CbcDecrypt wc_Des_CbcDecrypt - #define Des_EcbEncrypt wc_Des_EcbEncrypt - #define Des_CbcDecryptWithKey wc_Des_CbcDecryptWithKey - #define Des3_SetKey wc_Des3_SetKey - #define Des3_SetIV wc_Des3_SetIV - #define Des3_CbcEncrypt wc_Des3_CbcEncrypt - #define Des3_CbcDecrypt wc_Des3_CbcDecrypt - #define Des3_CbcDecryptWithKey wc_Des3_CbcDecryptWithKey - #ifdef HAVE_CAVIUM - #define Des3_InitCavium wc_Des3_InitCavium - #define Des3_FreeCavium wc_Des3_FreeCavium - #endif - #endif /* NO_DES3 */ - - #ifndef NO_SHA - #include - #define InitSha wc_InitSha - #define ShaUpdate wc_ShaUpdate - #define ShaFinal wc_ShaFinal - #define ShaHash wc_ShaHash - #endif /* NO_SHA */ - - #ifndef NO_SHA256 - #include - #define InitSha256 wc_InitSha256 - #define Sha256Update wc_Sha256Update - #define Sha256Final wc_Sha256Final - #define Sha256Hash wc_Sha256Hash - #endif /* NO_SHA256 */ - - #ifdef WOLFSSL_SHA512 - #include - #define InitSha512 wc_InitSha512 - #define Sha512Update wc_Sha512Update - #define Sha512Final wc_Sha512Final - #define Sha512Hash wc_Sha512Hash - - #if defined(WOLFSSL_SHA384) || defined(HAVE_AESGCM) - #define InitSha384 wc_InitSha384 - #define Sha384Update wc_Sha384Update - #define Sha384Final wc_Sha384Final - #define Sha384Hash wc_Sha384Hash - #endif /* WOLFSSL_SHA384 */ - #endif /* WOLFSSL_SHA512 */ -#endif /* HAVE_FIPS */ - #endif /* CTAO_CRYPT_SETTINGS_C_H */ diff --git a/cyassl/ctaocrypt/sha.h b/cyassl/ctaocrypt/sha.h index 792691b82..273984d10 100644 --- a/cyassl/ctaocrypt/sha.h +++ b/cyassl/ctaocrypt/sha.h @@ -26,6 +26,10 @@ #define CTAO_CRYPT_SHA_H #include +#define InitSha wc_InitSha +#define ShaUpdate wc_ShaUpdate +#define ShaFinal wc_ShaFinal +#define ShaHash wc_ShaHash #endif /* CTAO_CRYPT_SHA_H */ #endif /* NO_SHA */ diff --git a/cyassl/ctaocrypt/sha256.h b/cyassl/ctaocrypt/sha256.h index 9e1496147..69d053275 100644 --- a/cyassl/ctaocrypt/sha256.h +++ b/cyassl/ctaocrypt/sha256.h @@ -29,6 +29,10 @@ #define CTAO_CRYPT_SHA256_H #include +#define InitSha256 wc_InitSha256 +#define Sha256Update wc_Sha256Update +#define Sha256Final wc_Sha256Final +#define Sha256Hash wc_Sha256Hash #endif /* CTAO_CRYPT_SHA256_H */ #endif /* NO_SHA256 */ diff --git a/cyassl/ctaocrypt/sha512.h b/cyassl/ctaocrypt/sha512.h index d232bc895..a4da423d9 100644 --- a/cyassl/ctaocrypt/sha512.h +++ b/cyassl/ctaocrypt/sha512.h @@ -24,6 +24,17 @@ #define CTAO_CRYPT_SHA512_H #include +#define InitSha512 wc_InitSha512 +#define Sha512Update wc_Sha512Update +#define Sha512Final wc_Sha512Final +#define Sha512Hash wc_Sha512Hash + +#if defined(WOLFSSL_SHA384) || defined(HAVE_AESGCM) + #define InitSha384 wc_InitSha384 + #define Sha384Update wc_Sha384Update + #define Sha384Final wc_Sha384Final + #define Sha384Hash wc_Sha384Hash +#endif /* WOLFSSL_SHA384 */ #endif /* CTAO_CRYPT_SHA512_H */ diff --git a/tests/hash.c b/tests/hash.c index a4f604eb8..cbb3b3eca 100644 --- a/tests/hash.c +++ b/tests/hash.c @@ -440,11 +440,11 @@ int sha512_test(void) return ret; for (i = 0; i < times; ++i) { - ret = Sha512Update(&sha, (byte*)test_sha[i].input,(word32)test_sha[i].inLen); + ret = wc_Sha512Update(&sha, (byte*)test_sha[i].input,(word32)test_sha[i].inLen); if (ret != 0) return ret; - ret = Sha512Final(&sha, hash); + ret = wc_Sha512Final(&sha, hash); if (ret != 0) return ret; @@ -492,11 +492,11 @@ int sha384_test() return ret; for (i = 0; i < times; ++i) { - ret = Sha384Update(&sha, (byte*)test_sha[i].input,(word32)test_sha[i].inLen); + ret = wc_Sha384Update(&sha, (byte*)test_sha[i].input,(word32)test_sha[i].inLen); if (ret != 0) return ret; - ret = Sha384Final(&sha, hash); + ret = wc_Sha384Final(&sha, hash); if (ret != 0) return ret;