update cavium nitrox port to wolfssl

This commit is contained in:
toddouska
2015-11-16 13:20:19 -08:00
parent 37f4fbc000
commit ca7956b50d
5 changed files with 28 additions and 21 deletions

View File

@ -1859,13 +1859,13 @@ static int SetKeys(Ciphers* enc, Ciphers* dec, Keys* keys, CipherSpecs* specs,
#ifdef HAVE_CAVIUM #ifdef HAVE_CAVIUM
if (devId != NO_CAVIUM_DEVICE) { if (devId != NO_CAVIUM_DEVICE) {
if (enc) { if (enc) {
if (Arc4InitCavium(enc->arc4, devId) != 0) { if (wc_Arc4InitCavium(enc->arc4, devId) != 0) {
WOLFSSL_MSG("Arc4InitCavium failed in SetKeys"); WOLFSSL_MSG("Arc4InitCavium failed in SetKeys");
return CAVIUM_INIT_E; return CAVIUM_INIT_E;
} }
} }
if (dec) { if (dec) {
if (Arc4InitCavium(dec->arc4, devId) != 0) { if (wc_Arc4InitCavium(dec->arc4, devId) != 0) {
WOLFSSL_MSG("Arc4InitCavium failed in SetKeys"); WOLFSSL_MSG("Arc4InitCavium failed in SetKeys");
return CAVIUM_INIT_E; return CAVIUM_INIT_E;
} }
@ -2048,13 +2048,13 @@ static int SetKeys(Ciphers* enc, Ciphers* dec, Keys* keys, CipherSpecs* specs,
#ifdef HAVE_CAVIUM #ifdef HAVE_CAVIUM
if (devId != NO_CAVIUM_DEVICE) { if (devId != NO_CAVIUM_DEVICE) {
if (enc) { if (enc) {
if (Des3_InitCavium(enc->des3, devId) != 0) { if (wc_Des3_InitCavium(enc->des3, devId) != 0) {
WOLFSSL_MSG("Des3_InitCavium failed in SetKeys"); WOLFSSL_MSG("Des3_InitCavium failed in SetKeys");
return CAVIUM_INIT_E; return CAVIUM_INIT_E;
} }
} }
if (dec) { if (dec) {
if (Des3_InitCavium(dec->des3, devId) != 0) { if (wc_Des3_InitCavium(dec->des3, devId) != 0) {
WOLFSSL_MSG("Des3_InitCavium failed in SetKeys"); WOLFSSL_MSG("Des3_InitCavium failed in SetKeys");
return CAVIUM_INIT_E; return CAVIUM_INIT_E;
} }

View File

@ -4105,7 +4105,7 @@ int wc_AesCcmDecrypt(Aes* aes, byte* out, const byte* in, word32 inSz,
#ifdef HAVE_CAVIUM #ifdef HAVE_CAVIUM
#include <wolfssl/ctaocrypt/logging.h> #include <wolfssl/wolfcrypt/logging.h>
#include "cavium_common.h" #include "cavium_common.h"
/* Initiliaze Aes for use with Nitrox device */ /* 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) word32 length)
{ {
wolfssl_word offset = 0; wolfssl_word offset = 0;
@ -4189,7 +4189,7 @@ static int AesCaviumCbcEncrypt(Aes* aes, byte* out, const byte* in,
return 0; 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 length)
{ {
word32 requestId; word32 requestId;

View File

@ -105,10 +105,10 @@ int wc_HKDF(int type, const byte* inKey, word32 inKeySz,
#ifdef HAVE_CAVIUM #ifdef HAVE_CAVIUM
static void HmacCaviumFinal(Hmac* hmac, byte* hash); static int HmacCaviumFinal(Hmac* hmac, byte* hash);
static void HmacCaviumUpdate(Hmac* hmac, const byte* msg, word32 length); static int HmacCaviumUpdate(Hmac* hmac, const byte* msg, word32 length);
static void HmacCaviumSetKey(Hmac* hmac, int type, const byte* key, static int HmacCaviumSetKey(Hmac* hmac, int type, const byte* key,
word32 length); word32 length);
#endif #endif
static int InitHmac(Hmac* hmac, int type) 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; word32 requestId;
@ -650,12 +650,15 @@ static void HmacCaviumFinal(Hmac* hmac, byte* hash)
(byte*)hmac->ipad, hmac->dataLen, hmac->data, hash, &requestId, (byte*)hmac->ipad, hmac->dataLen, hmac->data, hash, &requestId,
hmac->devId) != 0) { hmac->devId) != 0) {
WOLFSSL_MSG("Cavium Hmac failed"); WOLFSSL_MSG("Cavium Hmac failed");
return -1;
} }
hmac->innerHashKeyed = 0; /* tell update to start over if used again */ 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; word16 add = (word16)length;
word32 total; word32 total;
@ -663,7 +666,7 @@ static void HmacCaviumUpdate(Hmac* hmac, const byte* msg, word32 length)
if (length > WOLFSSL_MAX_16BIT) { if (length > WOLFSSL_MAX_16BIT) {
WOLFSSL_MSG("Too big msg for cavium hmac"); WOLFSSL_MSG("Too big msg for cavium hmac");
return; return -1;
} }
if (hmac->innerHashKeyed == 0) { /* starting new */ if (hmac->innerHashKeyed == 0) { /* starting new */
@ -674,13 +677,13 @@ static void HmacCaviumUpdate(Hmac* hmac, const byte* msg, word32 length)
total = add + hmac->dataLen; total = add + hmac->dataLen;
if (total > WOLFSSL_MAX_16BIT) { if (total > WOLFSSL_MAX_16BIT) {
WOLFSSL_MSG("Too big msg for cavium hmac"); WOLFSSL_MSG("Too big msg for cavium hmac");
return; return -1;
} }
tmp = XMALLOC(hmac->dataLen + add, NULL,DYNAMIC_TYPE_CAVIUM_TMP); tmp = XMALLOC(hmac->dataLen + add, NULL,DYNAMIC_TYPE_CAVIUM_TMP);
if (tmp == NULL) { if (tmp == NULL) {
WOLFSSL_MSG("Out of memory for cavium update"); WOLFSSL_MSG("Out of memory for cavium update");
return; return -1;
} }
if (hmac->dataLen) if (hmac->dataLen)
XMEMCPY(tmp, hmac->data, 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; hmac->dataLen += add;
XFREE(hmac->data, NULL, DYNAMIC_TYPE_CAVIUM_TMP); XFREE(hmac->data, NULL, DYNAMIC_TYPE_CAVIUM_TMP);
hmac->data = tmp; hmac->data = tmp;
return 0;
} }
static void HmacCaviumSetKey(Hmac* hmac, int type, const byte* key, static int HmacCaviumSetKey(Hmac* hmac, int type, const byte* key,
word32 length) word32 length)
{ {
hmac->macType = (byte)type; hmac->macType = (byte)type;
if (type == MD5) if (type == MD5)
@ -711,6 +716,8 @@ static void HmacCaviumSetKey(Hmac* hmac, int type, const byte* key,
hmac->keyLen = (word16)length; hmac->keyLen = (word16)length;
/* store key in ipad */ /* store key in ipad */
XMEMCPY(hmac->ipad, key, length); XMEMCPY(hmac->ipad, key, length);
return 0;
} }
#endif /* HAVE_CAVIUM */ #endif /* HAVE_CAVIUM */

View File

@ -715,11 +715,11 @@ int wc_MakeRsaKey(RsaKey* key, int size, long e, WC_RNG* rng)
#ifdef HAVE_CAVIUM #ifdef HAVE_CAVIUM
#include <cyassl/ctaocrypt/logging.h> #include <wolfssl/wolfcrypt/logging.h>
#include "cavium_common.h" #include "cavium_common.h"
/* Initiliaze RSA for use with Nitrox device */ /* Initiliaze RSA for use with Nitrox device */
int RsaInitCavium(RsaKey* rsa, int devId) int wc_RsaInitCavium(RsaKey* rsa, int devId)
{ {
if (rsa == NULL) if (rsa == NULL)
return -1; return -1;

View File

@ -39,7 +39,7 @@
#ifndef HAVE_FIPS /* to avoid redefinition of macros */ #ifndef HAVE_FIPS /* to avoid redefinition of macros */
#ifdef HAVE_CAVIUM #ifdef HAVE_CAVIUM
#include <wolfssl/ctaocrypt/logging.h> #include <wolfssl/wolfcrypt/logging.h>
#include "cavium_common.h" #include "cavium_common.h"
#endif #endif