From 966ca9c97ed78d2ec65888f302bc7b1104202ca3 Mon Sep 17 00:00:00 2001 From: Jacob Barthelmeh Date: Sun, 4 Jan 2015 23:26:26 -0700 Subject: [PATCH] clean up comments on c files and fix duplicate in chacah header --- wolfcrypt/src/arc4.c | 2 +- wolfcrypt/src/asn.c | 20 ++++++++++---------- wolfcrypt/src/chacha.c | 8 ++++---- wolfcrypt/src/coding.c | 8 ++++---- wolfcrypt/src/logging.c | 32 ++++++++++++++++---------------- wolfcrypt/src/memory.c | 2 +- wolfssl/wolfcrypt/chacha.h | 12 +----------- 7 files changed, 37 insertions(+), 47 deletions(-) diff --git a/wolfcrypt/src/arc4.c b/wolfcrypt/src/arc4.c index 1721dfd0f..5c622d0dd 100644 --- a/wolfcrypt/src/arc4.c +++ b/wolfcrypt/src/arc4.c @@ -116,7 +116,7 @@ int wc_Arc4InitCavium(Arc4* arc4, int devId) arc4->devId = devId; arc4->magic = WOLFSSL_ARC4_CAVIUM_MAGIC; - + return 0; } diff --git a/wolfcrypt/src/asn.c b/wolfcrypt/src/asn.c index e9cf231c5..a3c3a0922 100644 --- a/wolfcrypt/src/asn.c +++ b/wolfcrypt/src/asn.c @@ -53,13 +53,13 @@ #include "ntru_crypto.h" #endif -//#if defined(WOLFSSL_SHA512) || defined(WOLFSSL_SHA384) -// #include -//#endif +#if defined(WOLFSSL_SHA512) || defined(WOLFSSL_SHA384) + #include +#endif -//#ifndef NO_SHA256 -// #include -//#endif +#ifndef NO_SHA256 + #include +#endif #ifdef HAVE_ECC #include @@ -87,7 +87,7 @@ #endif -#ifdef HAVE_RTP_SYS +#ifdef HAVE_RTP_SYS /* uses parital structures */ #define XTIME(tl) (0) #define XGMTIME(c) my_gmtime((c)) @@ -185,7 +185,7 @@ time_t time(time_t* timer) GetSystemTime(&sysTime); SystemTimeToFileTime(&sysTime, &fTime); - + XMEMCPY(&intTime, &fTime, sizeof(FILETIME)); /* subtract EPOCH */ intTime.QuadPart -= 0x19db1ded53e8000; @@ -250,7 +250,7 @@ struct tm* gmtime(const time_t* timer) #endif /* _WIN32_WCE || USER_TIME */ -#ifdef HAVE_RTP_SYS +#ifdef HAVE_RTP_SYS #define YEAR0 1900 @@ -293,7 +293,7 @@ time_t pic32_time(time_t* timer) if (timer == NULL) timer = &localTime; -#ifdef MICROCHIP_MPLAB_HARMONY +#ifdef MICROCHIP_MPLAB_HARMONY sec = TCPIP_SNTP_UTCSecondsGet(); #else sec = SNTPGetUTCSeconds(); diff --git a/wolfcrypt/src/chacha.c b/wolfcrypt/src/chacha.c index 64e8e432e..14d0508a7 100644 --- a/wolfcrypt/src/chacha.c +++ b/wolfcrypt/src/chacha.c @@ -17,13 +17,13 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - * + * * based from * chacha-ref.c version 20080118 * D. J. Bernstein * Public domain. */ - + #ifdef HAVE_CONFIG_H #include @@ -98,7 +98,7 @@ int wc_Chacha_SetIV(ChaCha* ctx, const byte* inIv, word32 counter) ctx->X[13] = temp[0]; /* fixed variable from nonce */ ctx->X[14] = temp[1]; /* counter from nonce */ ctx->X[15] = temp[2]; /* counter from nonce */ - + return 0; } @@ -138,7 +138,7 @@ int wc_Chacha_SetKey(ChaCha* ctx, const byte* key, word32 keySz) for (i = 0; i < keySz; i++) { printf("%02x", key[i]); if ((i + 1) % 8 == 0) - printf("\n"); + printf("\n"); } printf("\n\n"); #endif diff --git a/wolfcrypt/src/coding.c b/wolfcrypt/src/coding.c index cbd4e097a..ffffa4eaf 100644 --- a/wolfcrypt/src/coding.c +++ b/wolfcrypt/src/coding.c @@ -2,14 +2,14 @@ * * Copyright (C) 2006-2014 wolfSSL Inc. * - * This file is part of CyaSSL. + * This file is part of wolfSSL. (formerly known as CyaSSL) * - * CyaSSL is free software; you can redistribute it and/or modify + * wolfSSL is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * - * CyaSSL is distributed in the hope that it will be useful, + * wolfSSL is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. @@ -106,7 +106,7 @@ int Base64_Decode(const byte* in, word32 inLen, byte* out, word32* outLen) out[i++] = b3; else break; - + inLen -= 4; if (inLen && (in[j] == ' ' || in[j] == '\r' || in[j] == '\n')) { byte endLine = in[j++]; diff --git a/wolfcrypt/src/logging.c b/wolfcrypt/src/logging.c index e8db39aa5..1766d6464 100644 --- a/wolfcrypt/src/logging.c +++ b/wolfcrypt/src/logging.c @@ -2,14 +2,14 @@ * * Copyright (C) 2006-2014 wolfSSL Inc. * - * This file is part of CyaSSL. + * This file is part of wolfSSL. (formerly known as CyaSSL) * - * CyaSSL is free software; you can redistribute it and/or modify + * wolfSSL is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * - * CyaSSL is distributed in the hope that it will be useful, + * wolfSSL is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. @@ -41,18 +41,18 @@ #endif -#ifdef DEBUG_CYASSL +#ifdef DEBUG_WOLFSSL /* Set these to default values initially. */ static wolfSSL_Logging_cb log_function = 0; static int loggingEnabled = 0; -#endif /* DEBUG_CYASSL */ +#endif /* DEBUG_WOLFSSL */ int wolfSSL_SetLoggingCb(wolfSSL_Logging_cb f) { -#ifdef DEBUG_CYASSL +#ifdef DEBUG_WOLFSSL int res = 0; if (f) @@ -70,7 +70,7 @@ int wolfSSL_SetLoggingCb(wolfSSL_Logging_cb f) int wolfSSL_Debugging_ON(void) { -#ifdef DEBUG_CYASSL +#ifdef DEBUG_WOLFSSL loggingEnabled = 1; return 0; #else @@ -81,13 +81,13 @@ int wolfSSL_Debugging_ON(void) void wolfSSL_Debugging_OFF(void) { -#ifdef DEBUG_CYASSL +#ifdef DEBUG_WOLFSSL loggingEnabled = 0; #endif } -#ifdef DEBUG_CYASSL +#ifdef DEBUG_WOLFSSL #ifdef FREESCALE_MQX #include @@ -99,7 +99,7 @@ void wolfSSL_Debugging_OFF(void) int dc_log_printf(char*, ...); #endif -static void cyassl_log(const int logLevel, const char *const logMessage) +static void wolfssl_log(const int logLevel, const char *const logMessage) { if (log_function) log_function(logLevel, logMessage); @@ -111,7 +111,7 @@ static void cyassl_log(const int logLevel, const char *const logMessage) #if (NET_SECURE_MGR_CFG_EN == DEF_ENABLED) NetSecure_TraceOut((CPU_CHAR *)logMessage); #endif -#elif defined(CYASSL_MDK_ARM) +#elif defined(WOLFSSL_MDK_ARM) fflush(stdout) ; printf("%s\n", logMessage); fflush(stdout) ; @@ -126,7 +126,7 @@ static void cyassl_log(const int logLevel, const char *const logMessage) void WOLFSSL_MSG(const char* msg) { if (loggingEnabled) - cyassl_log(INFO_LOG , msg); + wolfssl_log(INFO_LOG , msg); } @@ -135,7 +135,7 @@ void WOLFSSL_ENTER(const char* msg) if (loggingEnabled) { char buffer[80]; sprintf(buffer, "wolfSSL Entering %s", msg); - cyassl_log(ENTER_LOG , buffer); + wolfssl_log(ENTER_LOG , buffer); } } @@ -145,7 +145,7 @@ void WOLFSSL_LEAVE(const char* msg, int ret) if (loggingEnabled) { char buffer[80]; sprintf(buffer, "wolfSSL Leaving %s, return %d", msg, ret); - cyassl_log(LEAVE_LOG , buffer); + wolfssl_log(LEAVE_LOG , buffer); } } @@ -155,8 +155,8 @@ void WOLFSSL_ERROR(int error) if (loggingEnabled) { char buffer[80]; sprintf(buffer, "wolfSSL error occured, error = %d", error); - cyassl_log(ERROR_LOG , buffer); + wolfssl_log(ERROR_LOG , buffer); } } -#endif /* DEBUG_WOLFSSL */ +#endif /* DEBUG_WOLFSSL */ diff --git a/wolfcrypt/src/memory.c b/wolfcrypt/src/memory.c index 7bbbd6902..408264203 100644 --- a/wolfcrypt/src/memory.c +++ b/wolfcrypt/src/memory.c @@ -1,4 +1,4 @@ -/* memory.c +/* memory.c * * Copyright (C) 2006-2014 wolfSSL Inc. * diff --git a/wolfssl/wolfcrypt/chacha.h b/wolfssl/wolfcrypt/chacha.h index e19658012..6d153a830 100644 --- a/wolfssl/wolfcrypt/chacha.h +++ b/wolfssl/wolfcrypt/chacha.h @@ -37,12 +37,8 @@ typedef struct ChaCha { word32 X[16]; /* state of cipher */ } ChaCha; -WOLFSSL_API int wc_Chacha_Process(ChaCha* ctx, byte* cipher, const byte* plain, - word32 msglen); -WOLFSSL_API int wc_Chacha_SetKey(ChaCha* ctx, const byte* key, word32 keySz); - /** - * IV(nonce) changes with each record + * IV(nonce) changes with each record * counter is for what value the block counter should start ... usually 0 */ WOLFSSL_API int wc_Chacha_SetIV(ChaCha* ctx, const byte* inIv, word32 counter); @@ -51,12 +47,6 @@ WOLFSSL_API int wc_Chacha_Process(ChaCha* ctx, byte* cipher, const byte* plain, word32 msglen); WOLFSSL_API int wc_Chacha_SetKey(ChaCha* ctx, const byte* key, word32 keySz); -/** - * IV(nonce) changes with each record - * counter is for what value the block counter should start ... usually 0 - */ -WOLFSSL_API int wc_Chacha_SetIV(ChaCha* ctx, const byte* inIv, word32 counter); - #ifdef __cplusplus } /* extern "C" */ #endif