From 02f16b9232a963ed8e9cb4b6ff74d84b69896a2e Mon Sep 17 00:00:00 2001 From: Jacob Barthelmeh Date: Wed, 7 Jan 2015 13:36:11 -0700 Subject: [PATCH] going through wolfcrypt --- wolfcrypt/src/aes.c | 8 ++++---- wolfcrypt/src/arc4.c | 2 +- wolfcrypt/src/asn.c | 22 +++++++++++----------- wolfcrypt/src/chacha.c | 2 +- wolfcrypt/src/hc128.c | 4 ++-- wolfcrypt/src/hmac.c | 34 +++++++++++++++++----------------- wolfcrypt/src/md5.c | 8 ++++---- wolfcrypt/src/memory.c | 4 ++-- wolfcrypt/src/rabbit.c | 4 ++-- wolfcrypt/src/random.c | 4 ++-- wolfcrypt/src/wc_port.c | 2 +- 11 files changed, 47 insertions(+), 47 deletions(-) diff --git a/wolfcrypt/src/aes.c b/wolfcrypt/src/aes.c index d5df99917..06e295519 100644 --- a/wolfcrypt/src/aes.c +++ b/wolfcrypt/src/aes.c @@ -3201,7 +3201,7 @@ static void GHASH(Aes* aes, const byte* a, word32 aSz, XMEMCPY(bigH, aes->H, AES_BLOCK_SIZE); #ifdef LITTLE_ENDIAN_ORDER - ByteReverseWords(bigH, bigH, AES_BLOCK_SIZE); + ByteReverseWords(bigH, bigH, AES_BLOCK_SIZE); #endif /* 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; } } - + #ifdef WOLFSSL_PIC32MZ_CRYPT if(blocks) 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++) B[AES_BLOCK_SIZE - 1 - i] = 0; B[15] = 1; - + while (oSz >= AES_BLOCK_SIZE) { #ifdef FREESCALE_MMCAU cau_aes_encrypt(B, key, aes->rounds, A); @@ -3778,7 +3778,7 @@ int wc_AesInitCavium(Aes* aes, int devId) aes->devId = devId; aes->magic = WOLFSSL_AES_CAVIUM_MAGIC; - + return 0; } diff --git a/wolfcrypt/src/arc4.c b/wolfcrypt/src/arc4.c index 5c622d0dd..76f1040e4 100644 --- a/wolfcrypt/src/arc4.c +++ b/wolfcrypt/src/arc4.c @@ -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, word32 length) { - cyassl_word offset = 0; + wolfssl_word offset = 0; word32 requestId; while (length > WOLFSSL_MAX_16BIT) { diff --git a/wolfcrypt/src/asn.c b/wolfcrypt/src/asn.c index b640b414b..4653a673e 100644 --- a/wolfcrypt/src/asn.c +++ b/wolfcrypt/src/asn.c @@ -116,7 +116,7 @@ #include #endif #undef RNG - #include "cyassl_MDK_ARM.h" + #include "wolfssl_MDK_ARM.h" #undef RNG #define RNG wolfSSL_RNG /*for avoiding name conflict in "stm32f2xx.h" */ #define XTIME(tl) (0) @@ -3094,34 +3094,34 @@ static int ConfirmSignature(const byte* buf, word32 bufSz, #ifdef WOLFSSL_DEBUG_ENCODING { int x; - - printf("cyassl encodedSig:\n"); - + + printf("wolfssl encodedSig:\n"); + for (x = 0; x < encodedSigSz; x++) { printf("%02x ", encodedSig[x]); if ( (x % 16) == 15) printf("\n"); } - + printf("\n"); printf("actual digest:\n"); - + for (x = 0; x < verifySz; x++) { printf("%02x ", out[x]); if ( (x % 16) == 15) printf("\n"); } - + printf("\n"); } #endif /* WOLFSSL_DEBUG_ENCODING */ - + } - + } - + wc_FreeRsaKey(pubKey); - + #ifdef WOLFSSL_SMALL_STACK XFREE(pubKey, NULL, DYNAMIC_TYPE_TMP_BUFFER); XFREE(plain, NULL, DYNAMIC_TYPE_TMP_BUFFER); diff --git a/wolfcrypt/src/chacha.c b/wolfcrypt/src/chacha.c index 14d0508a7..30deabf2f 100644 --- a/wolfcrypt/src/chacha.c +++ b/wolfcrypt/src/chacha.c @@ -120,7 +120,7 @@ int wc_Chacha_SetKey(ChaCha* ctx, const byte* key, word32 keySz) #ifdef XSTREAM_ALIGN word32 alignKey[keySz / 4]; - if ((cyassl_word)key % 4) { + if ((wolfssl_word)key % 4) { WOLFSSL_MSG("wc_ChachaSetKey unaligned key"); XMEMCPY(alignKey, key, sizeof(alignKey)); k = (byte*)alignKey; diff --git a/wolfcrypt/src/hc128.c b/wolfcrypt/src/hc128.c index 5a4e66db0..a70381a0a 100644 --- a/wolfcrypt/src/hc128.c +++ b/wolfcrypt/src/hc128.c @@ -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) { #ifdef XSTREAM_ALIGN - if ((cyassl_word)key % 4) { + if ((wolfssl_word)key % 4) { int alignKey[4]; /* 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) { #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 byte* tmp; WOLFSSL_MSG("Hc128Process unaligned"); diff --git a/wolfcrypt/src/hmac.c b/wolfcrypt/src/hmac.c index 06ae16344..ae2a64406 100644 --- a/wolfcrypt/src/hmac.c +++ b/wolfcrypt/src/hmac.c @@ -108,7 +108,7 @@ int wc_HmacFinal_fips(Hmac* hmac, byte* out) #endif /* HAVE_FIPS */ #else -#ifdef CYASSL_PIC32MZ_HASH +#ifdef WOLFSSL_PIC32MZ_HASH #define wc_InitMd5 wc_InitMd5_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; #ifdef HAVE_CAVIUM - if (hmac->magic == CYASSL_HMAC_CAVIUM_MAGIC) + if (hmac->magic == WOLFSSL_HMAC_CAVIUM_MAGIC) return HmacCaviumSetKey(hmac, type, key, length); #endif @@ -419,7 +419,7 @@ int wc_HmacUpdate(Hmac* hmac, const byte* msg, word32 length) int ret; #ifdef HAVE_CAVIUM - if (hmac->magic == CYASSL_HMAC_CAVIUM_MAGIC) + if (hmac->magic == WOLFSSL_HMAC_CAVIUM_MAGIC) return HmacCaviumUpdate(hmac, msg, length); #endif @@ -487,7 +487,7 @@ int wc_HmacFinal(Hmac* hmac, byte* hash) int ret; #ifdef HAVE_CAVIUM - if (hmac->magic == CYASSL_HMAC_CAVIUM_MAGIC) + if (hmac->magic == WOLFSSL_HMAC_CAVIUM_MAGIC) return HmacCaviumFinal(hmac, hash); #endif @@ -648,7 +648,7 @@ int wc_HmacInitCavium(Hmac* hmac, int devId) hmac->dataLen = 0; hmac->type = 0; hmac->devId = devId; - hmac->magic = CYASSL_HMAC_CAVIUM_MAGIC; + hmac->magic = WOLFSSL_HMAC_CAVIUM_MAGIC; hmac->data = NULL; /* buffered input data */ hmac->innerHashKeyed = 0; @@ -677,7 +677,7 @@ static void HmacCaviumFinal(Hmac* hmac, byte* hash) if (CspHmac(CAVIUM_BLOCKING, hmac->type, NULL, hmac->keyLen, (byte*)hmac->ipad, hmac->dataLen, hmac->data, hash, &requestId, hmac->devId) != 0) { - CYASSL_MSG("Cavium Hmac failed"); + WOLFSSL_MSG("Cavium Hmac failed"); } 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; byte* tmp; - if (length > CYASSL_MAX_16BIT) { - CYASSL_MSG("Too big msg for cavium hmac"); + if (length > WOLFSSL_MAX_16BIT) { + WOLFSSL_MSG("Too big msg for cavium hmac"); return; } @@ -700,14 +700,14 @@ static void HmacCaviumUpdate(Hmac* hmac, const byte* msg, word32 length) } total = add + hmac->dataLen; - if (total > CYASSL_MAX_16BIT) { - CYASSL_MSG("Too big msg for cavium hmac"); + if (total > WOLFSSL_MAX_16BIT) { + WOLFSSL_MSG("Too big msg for cavium hmac"); return; } tmp = XMALLOC(hmac->dataLen + add, NULL,DYNAMIC_TYPE_CAVIUM_TMP); if (tmp == NULL) { - CYASSL_MSG("Out of memory for cavium update"); + WOLFSSL_MSG("Out of memory for cavium update"); return; } if (hmac->dataLen) @@ -731,7 +731,7 @@ static void HmacCaviumSetKey(Hmac* hmac, int type, const byte* key, else if (type == SHA256) hmac->type = SHA256_TYPE; else { - CYASSL_MSG("unsupported cavium hmac type"); + WOLFSSL_MSG("unsupported cavium hmac type"); } hmac->innerHashKeyed = 0; /* should we key Startup flag */ @@ -785,13 +785,13 @@ static INLINE int GetHashSizeByType(int type) break; #endif - #ifdef CYASSL_SHA384 + #ifdef WOLFSSL_SHA384 case SHA384: return SHA384_DIGEST_SIZE; break; #endif - #ifdef CYASSL_SHA512 + #ifdef WOLFSSL_SHA512 case SHA512: return SHA512_DIGEST_SIZE; break; @@ -817,7 +817,7 @@ int wc_HKDF(int type, const byte* inKey, word32 inKeySz, byte* out, word32 outSz) { Hmac myHmac; -#ifdef CYASSL_SMALL_STACK +#ifdef WOLFSSL_SMALL_STACK byte* tmp; byte* prk; #else @@ -833,7 +833,7 @@ int wc_HKDF(int type, const byte* inKey, word32 inKeySz, if (hashSz < 0) return BAD_FUNC_ARG; -#ifdef CYASSL_SMALL_STACK +#ifdef WOLFSSL_SMALL_STACK tmp = (byte*)XMALLOC(MAX_DIGEST_SIZE, NULL, DYNAMIC_TYPE_TMP_BUFFER); if (tmp == NULL) 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(prk, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif diff --git a/wolfcrypt/src/md5.c b/wolfcrypt/src/md5.c index edb4165a9..b8916354e 100644 --- a/wolfcrypt/src/md5.c +++ b/wolfcrypt/src/md5.c @@ -28,7 +28,7 @@ #if !defined(NO_MD5) -#ifdef CYASSL_PIC32MZ_HASH +#ifdef WOLFSSL_PIC32MZ_HASH #define wc_InitMd5 InitMd5_sw #define wc_Md5Update Md5Update_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) { -#ifdef CYASSL_SMALL_STACK +#ifdef WOLFSSL_SMALL_STACK Md5* md5; #else Md5 md5[1]; #endif -#ifdef CYASSL_SMALL_STACK +#ifdef WOLFSSL_SMALL_STACK md5 = (Md5*)XMALLOC(sizeof(Md5), NULL, DYNAMIC_TYPE_TMP_BUFFER); if (md5 == NULL) return MEMORY_E; @@ -381,7 +381,7 @@ int wc_Md5Hash(const byte* data, word32 len, byte* hash) wc_Md5Update(md5, data, len); wc_Md5Final(md5, hash); -#ifdef CYASSL_SMALL_STACK +#ifdef WOLFSSL_SMALL_STACK XFREE(md5, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif diff --git a/wolfcrypt/src/memory.c b/wolfcrypt/src/memory.c index 41b01769f..74b5eee0d 100644 --- a/wolfcrypt/src/memory.c +++ b/wolfcrypt/src/memory.c @@ -81,7 +81,7 @@ void* wolfSSL_Malloc(size_t size) else res = malloc(size); - #ifdef CYASSL_MALLOC_CHECK + #ifdef WOLFSSL_MALLOC_CHECK if (res == NULL) puts("wolfSSL_malloc failed"); #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) { (void)heap; diff --git a/wolfcrypt/src/rabbit.c b/wolfcrypt/src/rabbit.c index 5ed3bbbe0..ccd8fda15 100644 --- a/wolfcrypt/src/rabbit.c +++ b/wolfcrypt/src/rabbit.c @@ -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) { #ifdef XSTREAM_ALIGN - if ((cyassl_word)key % 4) { + if ((wolfssl_word)key % 4) { int alignKey[4]; /* 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) { #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 byte* tmp; WOLFSSL_MSG("wc_RabbitProcess unaligned"); diff --git a/wolfcrypt/src/random.c b/wolfcrypt/src/random.c index 60b2d4443..c35285a5a 100644 --- a/wolfcrypt/src/random.c +++ b/wolfcrypt/src/random.c @@ -672,7 +672,7 @@ int wc_RNG_GenerateByte(RNG* rng, byte* b) #ifdef HAVE_CAVIUM -#include +#include #include "cavium_common.h" /* 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) { - cyassl_word offset = 0; + wolfssl_word offset = 0; word32 requestId; while (sz > WOLFSSL_MAX_16BIT) { diff --git a/wolfcrypt/src/wc_port.c b/wolfcrypt/src/wc_port.c index 06208b64f..1554821b6 100644 --- a/wolfcrypt/src/wc_port.c +++ b/wolfcrypt/src/wc_port.c @@ -201,7 +201,7 @@ int UnLockMutex(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; else return BAD_MUTEX_E;