going through wolfcrypt

pull/1/head
Jacob Barthelmeh 2015-01-07 13:36:11 -07:00
parent 7e9c8028b2
commit 02f16b9232
11 changed files with 47 additions and 47 deletions

View File

@ -3201,7 +3201,7 @@ static void GHASH(Aes* aes, const byte* a, word32 aSz,
XMEMCPY(bigH, aes->H, AES_BLOCK_SIZE); XMEMCPY(bigH, aes->H, AES_BLOCK_SIZE);
#ifdef LITTLE_ENDIAN_ORDER #ifdef LITTLE_ENDIAN_ORDER
ByteReverseWords(bigH, bigH, AES_BLOCK_SIZE); ByteReverseWords(bigH, bigH, AES_BLOCK_SIZE);
#endif #endif
/* Hash in A, the Additional Authentication Data */ /* Hash in A, the Additional Authentication Data */
@ -3412,7 +3412,7 @@ int wc_AesGcmDecrypt(Aes* aes, byte* out, const byte* in, word32 sz,
return AES_GCM_AUTH_E; return AES_GCM_AUTH_E;
} }
} }
#ifdef WOLFSSL_PIC32MZ_CRYPT #ifdef WOLFSSL_PIC32MZ_CRYPT
if(blocks) if(blocks)
wc_AesCrypt(aes, out, in, blocks*AES_BLOCK_SIZE, wc_AesCrypt(aes, out, in, blocks*AES_BLOCK_SIZE,
@ -3682,7 +3682,7 @@ int wc_AesCcmDecrypt(Aes* aes, byte* out, const byte* in, word32 inSz,
for (i = 0; i < lenSz; i++) for (i = 0; i < lenSz; i++)
B[AES_BLOCK_SIZE - 1 - i] = 0; B[AES_BLOCK_SIZE - 1 - i] = 0;
B[15] = 1; B[15] = 1;
while (oSz >= AES_BLOCK_SIZE) { while (oSz >= AES_BLOCK_SIZE) {
#ifdef FREESCALE_MMCAU #ifdef FREESCALE_MMCAU
cau_aes_encrypt(B, key, aes->rounds, A); cau_aes_encrypt(B, key, aes->rounds, A);
@ -3778,7 +3778,7 @@ int wc_AesInitCavium(Aes* aes, int devId)
aes->devId = devId; aes->devId = devId;
aes->magic = WOLFSSL_AES_CAVIUM_MAGIC; aes->magic = WOLFSSL_AES_CAVIUM_MAGIC;
return 0; return 0;
} }

View File

@ -149,7 +149,7 @@ static void wc_Arc4CaviumSetKey(Arc4* arc4, const byte* key, word32 length)
static void wc_Arc4CaviumProcess(Arc4* arc4, byte* out, const byte* in, static void wc_Arc4CaviumProcess(Arc4* arc4, byte* out, const byte* in,
word32 length) word32 length)
{ {
cyassl_word offset = 0; wolfssl_word offset = 0;
word32 requestId; word32 requestId;
while (length > WOLFSSL_MAX_16BIT) { while (length > WOLFSSL_MAX_16BIT) {

View File

@ -116,7 +116,7 @@
#include <rtl.h> #include <rtl.h>
#endif #endif
#undef RNG #undef RNG
#include "cyassl_MDK_ARM.h" #include "wolfssl_MDK_ARM.h"
#undef RNG #undef RNG
#define RNG wolfSSL_RNG /*for avoiding name conflict in "stm32f2xx.h" */ #define RNG wolfSSL_RNG /*for avoiding name conflict in "stm32f2xx.h" */
#define XTIME(tl) (0) #define XTIME(tl) (0)
@ -3094,34 +3094,34 @@ static int ConfirmSignature(const byte* buf, word32 bufSz,
#ifdef WOLFSSL_DEBUG_ENCODING #ifdef WOLFSSL_DEBUG_ENCODING
{ {
int x; int x;
printf("cyassl encodedSig:\n"); printf("wolfssl encodedSig:\n");
for (x = 0; x < encodedSigSz; x++) { for (x = 0; x < encodedSigSz; x++) {
printf("%02x ", encodedSig[x]); printf("%02x ", encodedSig[x]);
if ( (x % 16) == 15) if ( (x % 16) == 15)
printf("\n"); printf("\n");
} }
printf("\n"); printf("\n");
printf("actual digest:\n"); printf("actual digest:\n");
for (x = 0; x < verifySz; x++) { for (x = 0; x < verifySz; x++) {
printf("%02x ", out[x]); printf("%02x ", out[x]);
if ( (x % 16) == 15) if ( (x % 16) == 15)
printf("\n"); printf("\n");
} }
printf("\n"); printf("\n");
} }
#endif /* WOLFSSL_DEBUG_ENCODING */ #endif /* WOLFSSL_DEBUG_ENCODING */
} }
} }
wc_FreeRsaKey(pubKey); wc_FreeRsaKey(pubKey);
#ifdef WOLFSSL_SMALL_STACK #ifdef WOLFSSL_SMALL_STACK
XFREE(pubKey, NULL, DYNAMIC_TYPE_TMP_BUFFER); XFREE(pubKey, NULL, DYNAMIC_TYPE_TMP_BUFFER);
XFREE(plain, NULL, DYNAMIC_TYPE_TMP_BUFFER); XFREE(plain, NULL, DYNAMIC_TYPE_TMP_BUFFER);

View File

@ -120,7 +120,7 @@ int wc_Chacha_SetKey(ChaCha* ctx, const byte* key, word32 keySz)
#ifdef XSTREAM_ALIGN #ifdef XSTREAM_ALIGN
word32 alignKey[keySz / 4]; word32 alignKey[keySz / 4];
if ((cyassl_word)key % 4) { if ((wolfssl_word)key % 4) {
WOLFSSL_MSG("wc_ChachaSetKey unaligned key"); WOLFSSL_MSG("wc_ChachaSetKey unaligned key");
XMEMCPY(alignKey, key, sizeof(alignKey)); XMEMCPY(alignKey, key, sizeof(alignKey));
k = (byte*)alignKey; k = (byte*)alignKey;

View File

@ -290,7 +290,7 @@ static INLINE int DoKey(HC128* ctx, const byte* key, const byte* iv)
int wc_Hc128_SetKey(HC128* ctx, const byte* key, const byte* iv) int wc_Hc128_SetKey(HC128* ctx, const byte* key, const byte* iv)
{ {
#ifdef XSTREAM_ALIGN #ifdef XSTREAM_ALIGN
if ((cyassl_word)key % 4) { if ((wolfssl_word)key % 4) {
int alignKey[4]; int alignKey[4];
/* iv gets aligned in SetIV */ /* iv gets aligned in SetIV */
@ -362,7 +362,7 @@ static INLINE int DoProcess(HC128* ctx, byte* output, const byte* input,
int wc_Hc128_Process(HC128* ctx, byte* output, const byte* input, word32 msglen) int wc_Hc128_Process(HC128* ctx, byte* output, const byte* input, word32 msglen)
{ {
#ifdef XSTREAM_ALIGN #ifdef XSTREAM_ALIGN
if ((cyassl_word)input % 4 || (cyassl_word)output % 4) { if ((wolfssl_word)input % 4 || (wolfssl_word)output % 4) {
#ifndef NO_WOLFSSL_ALLOC_ALIGN #ifndef NO_WOLFSSL_ALLOC_ALIGN
byte* tmp; byte* tmp;
WOLFSSL_MSG("Hc128Process unaligned"); WOLFSSL_MSG("Hc128Process unaligned");

View File

@ -108,7 +108,7 @@ int wc_HmacFinal_fips(Hmac* hmac, byte* out)
#endif /* HAVE_FIPS */ #endif /* HAVE_FIPS */
#else #else
#ifdef CYASSL_PIC32MZ_HASH #ifdef WOLFSSL_PIC32MZ_HASH
#define wc_InitMd5 wc_InitMd5_sw #define wc_InitMd5 wc_InitMd5_sw
#define wc_Md5Update wc_Md5Update_sw #define wc_Md5Update wc_Md5Update_sw
@ -203,7 +203,7 @@ int wc_HmacSetKey(Hmac* hmac, int type, const byte* key, word32 length)
int ret; int ret;
#ifdef HAVE_CAVIUM #ifdef HAVE_CAVIUM
if (hmac->magic == CYASSL_HMAC_CAVIUM_MAGIC) if (hmac->magic == WOLFSSL_HMAC_CAVIUM_MAGIC)
return HmacCaviumSetKey(hmac, type, key, length); return HmacCaviumSetKey(hmac, type, key, length);
#endif #endif
@ -419,7 +419,7 @@ int wc_HmacUpdate(Hmac* hmac, const byte* msg, word32 length)
int ret; int ret;
#ifdef HAVE_CAVIUM #ifdef HAVE_CAVIUM
if (hmac->magic == CYASSL_HMAC_CAVIUM_MAGIC) if (hmac->magic == WOLFSSL_HMAC_CAVIUM_MAGIC)
return HmacCaviumUpdate(hmac, msg, length); return HmacCaviumUpdate(hmac, msg, length);
#endif #endif
@ -487,7 +487,7 @@ int wc_HmacFinal(Hmac* hmac, byte* hash)
int ret; int ret;
#ifdef HAVE_CAVIUM #ifdef HAVE_CAVIUM
if (hmac->magic == CYASSL_HMAC_CAVIUM_MAGIC) if (hmac->magic == WOLFSSL_HMAC_CAVIUM_MAGIC)
return HmacCaviumFinal(hmac, hash); return HmacCaviumFinal(hmac, hash);
#endif #endif
@ -648,7 +648,7 @@ int wc_HmacInitCavium(Hmac* hmac, int devId)
hmac->dataLen = 0; hmac->dataLen = 0;
hmac->type = 0; hmac->type = 0;
hmac->devId = devId; hmac->devId = devId;
hmac->magic = CYASSL_HMAC_CAVIUM_MAGIC; hmac->magic = WOLFSSL_HMAC_CAVIUM_MAGIC;
hmac->data = NULL; /* buffered input data */ hmac->data = NULL; /* buffered input data */
hmac->innerHashKeyed = 0; hmac->innerHashKeyed = 0;
@ -677,7 +677,7 @@ static void HmacCaviumFinal(Hmac* hmac, byte* hash)
if (CspHmac(CAVIUM_BLOCKING, hmac->type, NULL, hmac->keyLen, if (CspHmac(CAVIUM_BLOCKING, hmac->type, NULL, hmac->keyLen,
(byte*)hmac->ipad, hmac->dataLen, hmac->data, hash, &requestId, (byte*)hmac->ipad, hmac->dataLen, hmac->data, hash, &requestId,
hmac->devId) != 0) { hmac->devId) != 0) {
CYASSL_MSG("Cavium Hmac failed"); WOLFSSL_MSG("Cavium Hmac failed");
} }
hmac->innerHashKeyed = 0; /* tell update to start over if used again */ hmac->innerHashKeyed = 0; /* tell update to start over if used again */
} }
@ -689,8 +689,8 @@ static void HmacCaviumUpdate(Hmac* hmac, const byte* msg, word32 length)
word32 total; word32 total;
byte* tmp; byte* tmp;
if (length > CYASSL_MAX_16BIT) { if (length > WOLFSSL_MAX_16BIT) {
CYASSL_MSG("Too big msg for cavium hmac"); WOLFSSL_MSG("Too big msg for cavium hmac");
return; return;
} }
@ -700,14 +700,14 @@ static void HmacCaviumUpdate(Hmac* hmac, const byte* msg, word32 length)
} }
total = add + hmac->dataLen; total = add + hmac->dataLen;
if (total > CYASSL_MAX_16BIT) { if (total > WOLFSSL_MAX_16BIT) {
CYASSL_MSG("Too big msg for cavium hmac"); WOLFSSL_MSG("Too big msg for cavium hmac");
return; return;
} }
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) {
CYASSL_MSG("Out of memory for cavium update"); WOLFSSL_MSG("Out of memory for cavium update");
return; return;
} }
if (hmac->dataLen) if (hmac->dataLen)
@ -731,7 +731,7 @@ static void HmacCaviumSetKey(Hmac* hmac, int type, const byte* key,
else if (type == SHA256) else if (type == SHA256)
hmac->type = SHA256_TYPE; hmac->type = SHA256_TYPE;
else { else {
CYASSL_MSG("unsupported cavium hmac type"); WOLFSSL_MSG("unsupported cavium hmac type");
} }
hmac->innerHashKeyed = 0; /* should we key Startup flag */ hmac->innerHashKeyed = 0; /* should we key Startup flag */
@ -785,13 +785,13 @@ static INLINE int GetHashSizeByType(int type)
break; break;
#endif #endif
#ifdef CYASSL_SHA384 #ifdef WOLFSSL_SHA384
case SHA384: case SHA384:
return SHA384_DIGEST_SIZE; return SHA384_DIGEST_SIZE;
break; break;
#endif #endif
#ifdef CYASSL_SHA512 #ifdef WOLFSSL_SHA512
case SHA512: case SHA512:
return SHA512_DIGEST_SIZE; return SHA512_DIGEST_SIZE;
break; break;
@ -817,7 +817,7 @@ int wc_HKDF(int type, const byte* inKey, word32 inKeySz,
byte* out, word32 outSz) byte* out, word32 outSz)
{ {
Hmac myHmac; Hmac myHmac;
#ifdef CYASSL_SMALL_STACK #ifdef WOLFSSL_SMALL_STACK
byte* tmp; byte* tmp;
byte* prk; byte* prk;
#else #else
@ -833,7 +833,7 @@ int wc_HKDF(int type, const byte* inKey, word32 inKeySz,
if (hashSz < 0) if (hashSz < 0)
return BAD_FUNC_ARG; return BAD_FUNC_ARG;
#ifdef CYASSL_SMALL_STACK #ifdef WOLFSSL_SMALL_STACK
tmp = (byte*)XMALLOC(MAX_DIGEST_SIZE, NULL, DYNAMIC_TYPE_TMP_BUFFER); tmp = (byte*)XMALLOC(MAX_DIGEST_SIZE, NULL, DYNAMIC_TYPE_TMP_BUFFER);
if (tmp == NULL) if (tmp == NULL)
return MEMORY_E; return MEMORY_E;
@ -891,7 +891,7 @@ int wc_HKDF(int type, const byte* inKey, word32 inKeySz,
} }
} }
#ifdef CYASSL_SMALL_STACK #ifdef WOLFSSL_SMALL_STACK
XFREE(tmp, NULL, DYNAMIC_TYPE_TMP_BUFFER); XFREE(tmp, NULL, DYNAMIC_TYPE_TMP_BUFFER);
XFREE(prk, NULL, DYNAMIC_TYPE_TMP_BUFFER); XFREE(prk, NULL, DYNAMIC_TYPE_TMP_BUFFER);
#endif #endif

View File

@ -28,7 +28,7 @@
#if !defined(NO_MD5) #if !defined(NO_MD5)
#ifdef CYASSL_PIC32MZ_HASH #ifdef WOLFSSL_PIC32MZ_HASH
#define wc_InitMd5 InitMd5_sw #define wc_InitMd5 InitMd5_sw
#define wc_Md5Update Md5Update_sw #define wc_Md5Update Md5Update_sw
#define wc_Md5Final Md5Final_sw #define wc_Md5Final Md5Final_sw
@ -365,13 +365,13 @@ void wc_Md5Final(Md5* md5, byte* hash)
int wc_Md5Hash(const byte* data, word32 len, byte* hash) int wc_Md5Hash(const byte* data, word32 len, byte* hash)
{ {
#ifdef CYASSL_SMALL_STACK #ifdef WOLFSSL_SMALL_STACK
Md5* md5; Md5* md5;
#else #else
Md5 md5[1]; Md5 md5[1];
#endif #endif
#ifdef CYASSL_SMALL_STACK #ifdef WOLFSSL_SMALL_STACK
md5 = (Md5*)XMALLOC(sizeof(Md5), NULL, DYNAMIC_TYPE_TMP_BUFFER); md5 = (Md5*)XMALLOC(sizeof(Md5), NULL, DYNAMIC_TYPE_TMP_BUFFER);
if (md5 == NULL) if (md5 == NULL)
return MEMORY_E; return MEMORY_E;
@ -381,7 +381,7 @@ int wc_Md5Hash(const byte* data, word32 len, byte* hash)
wc_Md5Update(md5, data, len); wc_Md5Update(md5, data, len);
wc_Md5Final(md5, hash); wc_Md5Final(md5, hash);
#ifdef CYASSL_SMALL_STACK #ifdef WOLFSSL_SMALL_STACK
XFREE(md5, NULL, DYNAMIC_TYPE_TMP_BUFFER); XFREE(md5, NULL, DYNAMIC_TYPE_TMP_BUFFER);
#endif #endif

View File

@ -81,7 +81,7 @@ void* wolfSSL_Malloc(size_t size)
else else
res = malloc(size); res = malloc(size);
#ifdef CYASSL_MALLOC_CHECK #ifdef WOLFSSL_MALLOC_CHECK
if (res == NULL) if (res == NULL)
puts("wolfSSL_malloc failed"); puts("wolfSSL_malloc failed");
#endif #endif
@ -173,7 +173,7 @@ void* XREALLOC(void *p, size_t n, void* heap, int type)
} }
/* unit api calls, let's make sure visible with CYASSL_API */ /* unit api calls, let's make sure visible with WOLFSSL_API */
WOLFSSL_API void XFREE(void *p, void* heap, int type) WOLFSSL_API void XFREE(void *p, void* heap, int type)
{ {
(void)heap; (void)heap;

View File

@ -202,7 +202,7 @@ static INLINE int DoKey(Rabbit* ctx, const byte* key, const byte* iv)
int wc_RabbitSetKey(Rabbit* ctx, const byte* key, const byte* iv) int wc_RabbitSetKey(Rabbit* ctx, const byte* key, const byte* iv)
{ {
#ifdef XSTREAM_ALIGN #ifdef XSTREAM_ALIGN
if ((cyassl_word)key % 4) { if ((wolfssl_word)key % 4) {
int alignKey[4]; int alignKey[4];
/* iv aligned in SetIV */ /* iv aligned in SetIV */
@ -282,7 +282,7 @@ static INLINE int DoProcess(Rabbit* ctx, byte* output, const byte* input,
int wc_RabbitProcess(Rabbit* ctx, byte* output, const byte* input, word32 msglen) int wc_RabbitProcess(Rabbit* ctx, byte* output, const byte* input, word32 msglen)
{ {
#ifdef XSTREAM_ALIGN #ifdef XSTREAM_ALIGN
if ((cyassl_word)input % 4 || (cyassl_word)output % 4) { if ((wolfssl_word)input % 4 || (wolfssl_word)output % 4) {
#ifndef NO_WOLFSSL_ALLOC_ALIGN #ifndef NO_WOLFSSL_ALLOC_ALIGN
byte* tmp; byte* tmp;
WOLFSSL_MSG("wc_RabbitProcess unaligned"); WOLFSSL_MSG("wc_RabbitProcess unaligned");

View File

@ -672,7 +672,7 @@ int wc_RNG_GenerateByte(RNG* rng, byte* b)
#ifdef HAVE_CAVIUM #ifdef HAVE_CAVIUM
#include <cyassl/ctaocrypt/logging.h> #include <wolfssl/ctaocrypt/logging.h>
#include "cavium_common.h" #include "cavium_common.h"
/* Initiliaze RNG for use with Nitrox device */ /* Initiliaze RNG for use with Nitrox device */
@ -690,7 +690,7 @@ int wc_InitRngCavium(RNG* rng, int devId)
static void CaviumRNG_GenerateBlock(RNG* rng, byte* output, word32 sz) static void CaviumRNG_GenerateBlock(RNG* rng, byte* output, word32 sz)
{ {
cyassl_word offset = 0; wolfssl_word offset = 0;
word32 requestId; word32 requestId;
while (sz > WOLFSSL_MAX_16BIT) { while (sz > WOLFSSL_MAX_16BIT) {

View File

@ -201,7 +201,7 @@ int UnLockMutex(wolfSSL_Mutex *m)
int InitMutex(wolfSSL_Mutex* m) int InitMutex(wolfSSL_Mutex* m)
{ {
if (tx_mutex_create(m, "CyaSSL Mutex", TX_NO_INHERIT) == 0) if (tx_mutex_create(m, "wolfSSL Mutex", TX_NO_INHERIT) == 0)
return 0; return 0;
else else
return BAD_MUTEX_E; return BAD_MUTEX_E;