diff --git a/src/keys.c b/src/keys.c index 5ca1b72f7..3c1ccea5c 100644 --- a/src/keys.c +++ b/src/keys.c @@ -1859,13 +1859,13 @@ static int SetKeys(Ciphers* enc, Ciphers* dec, Keys* keys, CipherSpecs* specs, #ifdef HAVE_CAVIUM if (devId != NO_CAVIUM_DEVICE) { if (enc) { - if (Arc4InitCavium(enc->arc4, devId) != 0) { + if (wc_Arc4InitCavium(enc->arc4, devId) != 0) { WOLFSSL_MSG("Arc4InitCavium failed in SetKeys"); return CAVIUM_INIT_E; } } if (dec) { - if (Arc4InitCavium(dec->arc4, devId) != 0) { + if (wc_Arc4InitCavium(dec->arc4, devId) != 0) { WOLFSSL_MSG("Arc4InitCavium failed in SetKeys"); return CAVIUM_INIT_E; } @@ -2048,13 +2048,13 @@ static int SetKeys(Ciphers* enc, Ciphers* dec, Keys* keys, CipherSpecs* specs, #ifdef HAVE_CAVIUM if (devId != NO_CAVIUM_DEVICE) { if (enc) { - if (Des3_InitCavium(enc->des3, devId) != 0) { + if (wc_Des3_InitCavium(enc->des3, devId) != 0) { WOLFSSL_MSG("Des3_InitCavium failed in SetKeys"); return CAVIUM_INIT_E; } } if (dec) { - if (Des3_InitCavium(dec->des3, devId) != 0) { + if (wc_Des3_InitCavium(dec->des3, devId) != 0) { WOLFSSL_MSG("Des3_InitCavium failed in SetKeys"); return CAVIUM_INIT_E; } diff --git a/wolfcrypt/src/aes.c b/wolfcrypt/src/aes.c index d7524b66a..52948062a 100644 --- a/wolfcrypt/src/aes.c +++ b/wolfcrypt/src/aes.c @@ -4105,7 +4105,7 @@ int wc_AesCcmDecrypt(Aes* aes, byte* out, const byte* in, word32 inSz, #ifdef HAVE_CAVIUM -#include +#include #include "cavium_common.h" /* Initiliaze Aes for use with Nitrox device */ @@ -4156,7 +4156,7 @@ static int wc_AesCaviumSetKey(Aes* aes, const byte* key, word32 length, } -static int AesCaviumCbcEncrypt(Aes* aes, byte* out, const byte* in, +static int wc_AesCaviumCbcEncrypt(Aes* aes, byte* out, const byte* in, word32 length) { wolfssl_word offset = 0; @@ -4189,7 +4189,7 @@ static int AesCaviumCbcEncrypt(Aes* aes, byte* out, const byte* in, return 0; } -static int AesCaviumCbcDecrypt(Aes* aes, byte* out, const byte* in, +static int wc_AesCaviumCbcDecrypt(Aes* aes, byte* out, const byte* in, word32 length) { word32 requestId; diff --git a/wolfcrypt/src/hmac.c b/wolfcrypt/src/hmac.c index aacbef88a..272f335d8 100644 --- a/wolfcrypt/src/hmac.c +++ b/wolfcrypt/src/hmac.c @@ -105,10 +105,10 @@ int wc_HKDF(int type, const byte* inKey, word32 inKeySz, #ifdef HAVE_CAVIUM - static void HmacCaviumFinal(Hmac* hmac, byte* hash); - static void HmacCaviumUpdate(Hmac* hmac, const byte* msg, word32 length); - static void HmacCaviumSetKey(Hmac* hmac, int type, const byte* key, - word32 length); + static int HmacCaviumFinal(Hmac* hmac, byte* hash); + static int HmacCaviumUpdate(Hmac* hmac, const byte* msg, word32 length); + static int HmacCaviumSetKey(Hmac* hmac, int type, const byte* key, + word32 length); #endif static int InitHmac(Hmac* hmac, int type) @@ -642,7 +642,7 @@ void wc_HmacFreeCavium(Hmac* hmac) } -static void HmacCaviumFinal(Hmac* hmac, byte* hash) +static int HmacCaviumFinal(Hmac* hmac, byte* hash) { word32 requestId; @@ -650,12 +650,15 @@ static void HmacCaviumFinal(Hmac* hmac, byte* hash) (byte*)hmac->ipad, hmac->dataLen, hmac->data, hash, &requestId, hmac->devId) != 0) { WOLFSSL_MSG("Cavium Hmac failed"); + return -1; } hmac->innerHashKeyed = 0; /* tell update to start over if used again */ + + return 0; } -static void HmacCaviumUpdate(Hmac* hmac, const byte* msg, word32 length) +static int HmacCaviumUpdate(Hmac* hmac, const byte* msg, word32 length) { word16 add = (word16)length; word32 total; @@ -663,7 +666,7 @@ static void HmacCaviumUpdate(Hmac* hmac, const byte* msg, word32 length) if (length > WOLFSSL_MAX_16BIT) { WOLFSSL_MSG("Too big msg for cavium hmac"); - return; + return -1; } if (hmac->innerHashKeyed == 0) { /* starting new */ @@ -674,13 +677,13 @@ static void HmacCaviumUpdate(Hmac* hmac, const byte* msg, word32 length) total = add + hmac->dataLen; if (total > WOLFSSL_MAX_16BIT) { WOLFSSL_MSG("Too big msg for cavium hmac"); - return; + return -1; } tmp = XMALLOC(hmac->dataLen + add, NULL,DYNAMIC_TYPE_CAVIUM_TMP); if (tmp == NULL) { WOLFSSL_MSG("Out of memory for cavium update"); - return; + return -1; } if (hmac->dataLen) XMEMCPY(tmp, hmac->data, hmac->dataLen); @@ -689,11 +692,13 @@ static void HmacCaviumUpdate(Hmac* hmac, const byte* msg, word32 length) hmac->dataLen += add; XFREE(hmac->data, NULL, DYNAMIC_TYPE_CAVIUM_TMP); hmac->data = tmp; + + return 0; } -static void HmacCaviumSetKey(Hmac* hmac, int type, const byte* key, - word32 length) +static int HmacCaviumSetKey(Hmac* hmac, int type, const byte* key, + word32 length) { hmac->macType = (byte)type; if (type == MD5) @@ -711,6 +716,8 @@ static void HmacCaviumSetKey(Hmac* hmac, int type, const byte* key, hmac->keyLen = (word16)length; /* store key in ipad */ XMEMCPY(hmac->ipad, key, length); + + return 0; } #endif /* HAVE_CAVIUM */ diff --git a/wolfcrypt/src/rsa.c b/wolfcrypt/src/rsa.c index 6f4c3a595..5ca4a40c6 100644 --- a/wolfcrypt/src/rsa.c +++ b/wolfcrypt/src/rsa.c @@ -715,11 +715,11 @@ int wc_MakeRsaKey(RsaKey* key, int size, long e, WC_RNG* rng) #ifdef HAVE_CAVIUM -#include +#include #include "cavium_common.h" /* Initiliaze RSA for use with Nitrox device */ -int RsaInitCavium(RsaKey* rsa, int devId) +int wc_RsaInitCavium(RsaKey* rsa, int devId) { if (rsa == NULL) return -1; diff --git a/wolfssl/wolfcrypt/aes.h b/wolfssl/wolfcrypt/aes.h index f850c3ca8..45c972226 100644 --- a/wolfssl/wolfcrypt/aes.h +++ b/wolfssl/wolfcrypt/aes.h @@ -39,7 +39,7 @@ #ifndef HAVE_FIPS /* to avoid redefinition of macros */ #ifdef HAVE_CAVIUM - #include + #include #include "cavium_common.h" #endif