From 2520973b73c8ba2e582df9c0269614520e00174a Mon Sep 17 00:00:00 2001 From: Jacob Barthelmeh Date: Sat, 3 Jan 2015 19:09:48 -0700 Subject: [PATCH] update to c files for name change and pwdbased along with debugging src function calls --- cyassl/ssl.h | 7 +- src/internal.c | 12 +-- src/io.c | 2 +- src/sniffer.c | 94 +++++++++---------- src/ssl.c | 174 +++++++++++++++++------------------ testsuite/testsuite.c | 18 ++-- wolfcrypt/src/aes.c | 148 ++++++++++++++--------------- wolfcrypt/src/asn.c | 4 +- wolfcrypt/src/blake2b.c | 6 +- wolfcrypt/src/camellia.c | 18 ++-- wolfcrypt/src/dh.c | 2 +- wolfcrypt/src/dsa.c | 4 +- wolfcrypt/src/ecc.c | 4 +- wolfcrypt/src/pkcs7.c | 74 +++++++-------- wolfcrypt/src/pwdbased.c | 94 +++++++++---------- wolfcrypt/test/test.c | 38 ++++---- wolfssl/test.h | 66 ++++++------- wolfssl/wolfcrypt/asn.h | 4 +- wolfssl/wolfcrypt/pwdbased.h | 7 +- wolfssl/wolfcrypt/sha512.h | 15 --- 20 files changed, 388 insertions(+), 403 deletions(-) diff --git a/cyassl/ssl.h b/cyassl/ssl.h index 9845b1b23..5aedb1f75 100644 --- a/cyassl/ssl.h +++ b/cyassl/ssl.h @@ -391,10 +391,10 @@ #if !defined(CYASSL_MAX_ERROR_SZ) && !defined(HAVE_FIPS) #define CYASSL_MAX_ERROR_SZ WOLFSSL_MAX_ERROR_SZ #endif - -/* + +/* * wrapper around macros until they are changed in cyassl code - * needs investigation in regards to macros in fips + * needs investigation in regards to macros in fips */ #define NO_WOLFSSL_ALLOC_ALIGN NO_CYASSL_ALLOC_ALIGN /* @TODO */ @@ -407,6 +407,7 @@ /* examples/client/client.h */ #define CYASSL_THREAD WOLFSSL_THREAD +#define CYASSL_DTLS WOLFSSL_DTLS /* examples/client/client.c */ #define LIBCYASSL_VERSION_STRING LIBWOLFSSL_VERSION_STRING diff --git a/src/internal.c b/src/internal.c index 5289fa14b..47bc01edc 100644 --- a/src/internal.c +++ b/src/internal.c @@ -10159,7 +10159,7 @@ static void PickHashSigAlgo(WOLFSSL* ssl, && !(ret = wc_Sha256Update(sha256, ssl->arrays->clientRandom, RAN_LEN)) && !(ret = wc_Sha256Update(sha256, ssl->arrays->serverRandom, RAN_LEN)) && !(ret = wc_Sha256Update(sha256, messageVerify, verifySz))) - ret = Sha256Final(sha256, hash256); + ret = wc_Sha256Final(sha256, hash256); if (ret != 0) goto done; #endif @@ -10177,7 +10177,7 @@ static void PickHashSigAlgo(WOLFSSL* ssl, && !(ret = wc_Sha384Update(sha384, ssl->arrays->clientRandom, RAN_LEN)) && !(ret = wc_Sha384Update(sha384, ssl->arrays->serverRandom, RAN_LEN)) && !(ret = wc_Sha384Update(sha384, messageVerify, verifySz))) - ret = Sha384Final(sha384, hash384); + ret = wc_Sha384Final(sha384, hash384); if (ret != 0) goto done; #endif @@ -11854,7 +11854,7 @@ int DoSessionTicket(WOLFSSL* ssl, && !(ret = wc_Sha256Update(sha256, ssl->arrays->serverRandom, RAN_LEN)) && !(ret = wc_Sha256Update(sha256, output + preSigIdx, preSigSz))) - ret = Sha256Final(sha256, hash256); + ret = wc_Sha256Final(sha256, hash256); if (ret != 0) goto done_a2; @@ -11876,7 +11876,7 @@ int DoSessionTicket(WOLFSSL* ssl, && !(ret = wc_Sha384Update(sha384, ssl->arrays->serverRandom, RAN_LEN)) && !(ret = wc_Sha384Update(sha384, output + preSigIdx, preSigSz))) - ret = Sha384Final(sha384, hash384); + ret = wc_Sha384Final(sha384, hash384); if (ret != 0) goto done_a2; @@ -12309,7 +12309,7 @@ int DoSessionTicket(WOLFSSL* ssl, && !(ret = wc_Sha256Update(sha256, ssl->arrays->serverRandom, RAN_LEN)) && !(ret = wc_Sha256Update(sha256, output + preSigIdx, preSigSz))) - ret = Sha256Final(sha256, hash256); + ret = wc_Sha256Final(sha256, hash256); if (ret != 0) goto done_b; @@ -12331,7 +12331,7 @@ int DoSessionTicket(WOLFSSL* ssl, && !(ret = wc_Sha384Update(sha384, ssl->arrays->serverRandom, RAN_LEN)) && !(ret = wc_Sha384Update(sha384, output + preSigIdx, preSigSz))) - ret = Sha384Final(sha384, hash384); + ret = wc_Sha384Final(sha384, hash384); if (ret != 0) goto done_b; diff --git a/src/io.c b/src/io.c index f8a5e1a11..5c803fecb 100644 --- a/src/io.c +++ b/src/io.c @@ -505,7 +505,7 @@ int EmbedGenerateCookie(WOLFSSL* ssl, byte *buf, int sz, void *ctx) return GEN_COOKIE_E; } - ret = ShaHash((byte*)&peer, peerSz, digest); + ret = wc_ShaHash((byte*)&peer, peerSz, digest); if (ret != 0) return ret; diff --git a/src/sniffer.c b/src/sniffer.c index f69c060ab..fc0f96072 100644 --- a/src/sniffer.c +++ b/src/sniffer.c @@ -20,7 +20,7 @@ */ /* Name change compatibility layer */ -#include +//#include #ifdef HAVE_CONFIG_H #include @@ -82,7 +82,7 @@ enum { FATAL_ERROR_STATE = 1, /* SnifferSession fatal error state */ TICKET_HINT_LEN = 4, /* Session Ticket Hint length */ EXT_TYPE_SZ = 2, /* Extension length */ - MAX_INPUT_SZ = MAX_RECORD_SIZE + COMP_EXTRA + MAX_MSG_EXTRA + + MAX_INPUT_SZ = MAX_RECORD_SIZE + COMP_EXTRA + MAX_MSG_EXTRA + MTU_EXTRA, /* Max input sz of reassembly */ TICKET_EXT_ID = 0x23 /* Session Ticket Extension ID */ }; @@ -1284,37 +1284,37 @@ static int ProcessClientKeyExchange(const byte* input, int* sslBytes, RsaKey key; int ret; - ret = InitRsaKey(&key, 0); - if (ret == 0) - ret = RsaPrivateKeyDecode(session->sslServer->buffers.key.buffer, + ret = wc_InitRsaKey(&key, 0); + if (ret == 0) + ret = wc_RsaPrivateKeyDecode(session->sslServer->buffers.key.buffer, &idx, &key, session->sslServer->buffers.key.length); if (ret == 0) { - int length = RsaEncryptSize(&key); - - if (IsTLS(session->sslServer)) + int length = wc_RsaEncryptSize(&key); + + if (IsTLS(session->sslServer)) input += 2; /* tls pre length */ - - if (length > *sslBytes) { + + if (length > *sslBytes) { SetError(PARTIAL_INPUT_STR, error, session, FATAL_ERROR_STATE); - FreeRsaKey(&key); + wc_FreeRsaKey(&key); return -1; } - ret = RsaPrivateDecrypt(input, length, + ret = wc_RsaPrivateDecrypt(input, length, session->sslServer->arrays->preMasterSecret,SECRET_LEN, &key); - + if (ret != SECRET_LEN) { SetError(RSA_DECRYPT_STR, error, session, FATAL_ERROR_STATE); - FreeRsaKey(&key); + wc_FreeRsaKey(&key); return -1; } ret = 0; /* not in error state */ session->sslServer->arrays->preMasterSz = SECRET_LEN; - + /* store for client side as well */ XMEMCPY(session->sslClient->arrays->preMasterSecret, session->sslServer->arrays->preMasterSecret, SECRET_LEN); session->sslClient->arrays->preMasterSz = SECRET_LEN; - + #ifdef SHOW_SECRETS { int i; @@ -1327,19 +1327,19 @@ static int ProcessClientKeyExchange(const byte* input, int* sslBytes, } else { SetError(RSA_DECODE_STR, error, session, FATAL_ERROR_STATE); - FreeRsaKey(&key); + wc_FreeRsaKey(&key); return -1; } - + if (SetCipherSpecs(session->sslServer) != 0) { SetError(BAD_CIPHER_SPEC_STR, error, session, FATAL_ERROR_STATE); - FreeRsaKey(&key); + wc_FreeRsaKey(&key); return -1; } - + if (SetCipherSpecs(session->sslClient) != 0) { SetError(BAD_CIPHER_SPEC_STR, error, session, FATAL_ERROR_STATE); - FreeRsaKey(&key); + wc_FreeRsaKey(&key); return -1; } @@ -1360,7 +1360,7 @@ static int ProcessClientKeyExchange(const byte* input, int* sslBytes, for (i = 0; i < SECRET_LEN; i++) printf("%02x", session->sslServer->arrays->masterSecret[i]); printf("\n"); - + printf("client master secret: "); for (i = 0; i < SECRET_LEN; i++) printf("%02x", session->sslClient->arrays->masterSecret[i]); @@ -1369,9 +1369,9 @@ static int ProcessClientKeyExchange(const byte* input, int* sslBytes, printf("server suite = %d\n", session->sslServer->options.cipherSuite); printf("client suite = %d\n", session->sslClient->options.cipherSuite); } -#endif - - FreeRsaKey(&key); +#endif + + wc_FreeRsaKey(&key); return ret; } @@ -1387,7 +1387,7 @@ static int ProcessSessionTicket(const byte* input, int* sslBytes, SetError(BAD_INPUT_STR, error, session, FATAL_ERROR_STATE); return -1; } - + input += TICKET_HINT_LEN; /* skip over hint */ *sslBytes -= TICKET_HINT_LEN; @@ -1404,7 +1404,7 @@ static int ProcessSessionTicket(const byte* input, int* sslBytes, /* store session with macID as sessionID */ session->sslServer->options.haveSessionId = 1; XMEMCPY(session->sslServer->arrays->sessionID, input + len - ID_LEN,ID_LEN); - + return 0; } @@ -1417,7 +1417,7 @@ static int ProcessServerHello(const byte* input, int* sslBytes, byte b; int toRead = VERSION_SZ + RAN_LEN + ENUM_LEN; int doResume = 0; - + /* make sure we didn't miss ClientHello */ if (session->flags.clientHello == 0) { SetError(MISSED_CLIENT_HELLO_STR, error, session, FATAL_ERROR_STATE); @@ -1429,22 +1429,22 @@ static int ProcessServerHello(const byte* input, int* sslBytes, SetError(SERVER_HELLO_INPUT_STR, error, session, FATAL_ERROR_STATE); return -1; } - + XMEMCPY(&pv, input, VERSION_SZ); input += VERSION_SZ; *sslBytes -= VERSION_SZ; - + session->sslServer->version = pv; session->sslClient->version = pv; - + XMEMCPY(session->sslServer->arrays->serverRandom, input, RAN_LEN); XMEMCPY(session->sslClient->arrays->serverRandom, input, RAN_LEN); input += RAN_LEN; *sslBytes -= RAN_LEN; - + b = *input++; *sslBytes -= 1; - + /* make sure can read through compression */ if ( (b + SUITE_LEN + ENUM_LEN) > *sslBytes) { SetError(SERVER_HELLO_INPUT_STR, error, session, FATAL_ERROR_STATE); @@ -1456,8 +1456,8 @@ static int ProcessServerHello(const byte* input, int* sslBytes, } input += b; *sslBytes -= b; - - /* cipher suite */ + + /* cipher suite */ b = *input++; /* first byte, ECC or not */ session->sslServer->options.cipherSuite0 = b; session->sslClient->options.cipherSuite0 = b; @@ -1474,7 +1474,7 @@ static int ProcessServerHello(const byte* input, int* sslBytes, SetError(BAD_COMPRESSION_STR, error, session, FATAL_ERROR_STATE); return -1; } - + if (session->sslServer->options.haveSessionId && XMEMCMP(session->sslServer->arrays->sessionID, session->sslClient->arrays->sessionID, ID_LEN) == 0) @@ -1503,18 +1503,18 @@ static int ProcessServerHello(const byte* input, int* sslBytes, XMEMCPY(session->sslClient->arrays->masterSecret, session->sslServer->arrays->masterSecret, SECRET_LEN); session->flags.resuming = 1; - + Trace(SERVER_DID_RESUMPTION_STR); if (SetCipherSpecs(session->sslServer) != 0) { SetError(BAD_CIPHER_SPEC_STR, error, session, FATAL_ERROR_STATE); return -1; } - + if (SetCipherSpecs(session->sslClient) != 0) { SetError(BAD_CIPHER_SPEC_STR, error, session, FATAL_ERROR_STATE); return -1; } - + if (session->sslServer->options.tls) { ret = DeriveTlsKeys(session->sslServer); ret += DeriveTlsKeys(session->sslClient); @@ -1541,19 +1541,19 @@ static int ProcessServerHello(const byte* input, int* sslBytes, printf("%02x", session->sslServer->arrays->serverRandom[i]); printf("\n"); } -#endif +#endif return 0; } /* Process normal Client Hello */ -static int ProcessClientHello(const byte* input, int* sslBytes, +static int ProcessClientHello(const byte* input, int* sslBytes, SnifferSession* session, char* error) { byte bLen; word16 len; int toRead = VERSION_SZ + RAN_LEN + ENUM_LEN; - + #ifdef HAVE_SNI { byte name[MAX_SERVER_NAME]; @@ -1593,23 +1593,23 @@ static int ProcessClientHello(const byte* input, int* sslBytes, #endif session->flags.clientHello = 1; /* don't process again */ - + /* make sure can read up to session len */ if (toRead > *sslBytes) { SetError(CLIENT_HELLO_INPUT_STR, error, session, FATAL_ERROR_STATE); return -1; } - + /* skip, get negotiated one from server hello */ input += VERSION_SZ; *sslBytes -= VERSION_SZ; - + XMEMCPY(session->sslServer->arrays->clientRandom, input, RAN_LEN); XMEMCPY(session->sslClient->arrays->clientRandom, input, RAN_LEN); - + input += RAN_LEN; *sslBytes -= RAN_LEN; - + /* store session in case trying to resume */ bLen = *input++; *sslBytes -= ENUM_LEN; diff --git a/src/ssl.c b/src/ssl.c index 0d4267db4..9cb10566f 100644 --- a/src/ssl.c +++ b/src/ssl.c @@ -786,21 +786,21 @@ int wolfSSL_Rehandshake(WOLFSSL* ssl) #ifndef NO_OLD_TLS #ifndef NO_MD5 - InitMd5(&ssl->hashMd5); + wc_InitMd5(&ssl->hashMd5); #endif #ifndef NO_SHA - ret = InitSha(&ssl->hashSha); + ret = wc_InitSha(&ssl->hashSha); if (ret !=0) return ret; #endif #endif /* NO_OLD_TLS */ #ifndef NO_SHA256 - ret = InitSha256(&ssl->hashSha256); + ret = wc_InitSha256(&ssl->hashSha256); if (ret !=0) return ret; #endif #ifdef WOLFSSL_SHA384 - ret = InitSha384(&ssl->hashSha384); + ret = wc_InitSha384(&ssl->hashSha384); if (ret !=0) return ret; #endif @@ -2414,23 +2414,23 @@ static int ProcessBuffer(WOLFSSL_CTX* ctx, const unsigned char* buff, /* empty */ } else if (XSTRNCMP(info->name, "DES-CBC", 7) == 0) { - ret = Des_CbcDecryptWithKey(der.buffer, der.buffer, der.length, + ret = wc_Des_CbcDecryptWithKey(der.buffer, der.buffer, der.length, key, info->iv); } else if (XSTRNCMP(info->name, "DES-EDE3-CBC", 13) == 0) { - ret = Des3_CbcDecryptWithKey(der.buffer, der.buffer, der.length, + ret = wc_Des3_CbcDecryptWithKey(der.buffer, der.buffer, der.length, key, info->iv); } else if (XSTRNCMP(info->name, "AES-128-CBC", 13) == 0) { - ret = AesCbcDecryptWithKey(der.buffer, der.buffer, der.length, + ret = wc_AesCbcDecryptWithKey(der.buffer, der.buffer, der.length, key, AES_128_KEY_SIZE, info->iv); } else if (XSTRNCMP(info->name, "AES-192-CBC", 13) == 0) { - ret = AesCbcDecryptWithKey(der.buffer, der.buffer, der.length, + ret = wc_AesCbcDecryptWithKey(der.buffer, der.buffer, der.length, key, AES_192_KEY_SIZE, info->iv); } else if (XSTRNCMP(info->name, "AES-256-CBC", 13) == 0) { - ret = AesCbcDecryptWithKey(der.buffer, der.buffer, der.length, + ret = wc_AesCbcDecryptWithKey(der.buffer, der.buffer, der.length, key, AES_256_KEY_SIZE, info->iv); } else { @@ -5050,8 +5050,8 @@ int wolfSSL_dtls_got_timeout(WOLFSSL* ssl) if (ssl->options.dtls) { /* re-init hashes, exclude first hello and verify request */ #ifndef NO_OLD_TLS - InitMd5(&ssl->hashMd5); - if ( (ssl->error = InitSha(&ssl->hashSha)) != 0) { + wc_InitMd5(&ssl->hashMd5); + if ( (ssl->error = wc_InitSha(&ssl->hashSha)) != 0) { WOLFSSL_ERROR(ssl->error); return SSL_FATAL_ERROR; } @@ -5059,14 +5059,14 @@ int wolfSSL_dtls_got_timeout(WOLFSSL* ssl) if (IsAtLeastTLSv1_2(ssl)) { #ifndef NO_SHA256 if ( (ssl->error = - InitSha256(&ssl->hashSha256)) != 0) { + wc_InitSha256(&ssl->hashSha256)) != 0) { WOLFSSL_ERROR(ssl->error); return SSL_FATAL_ERROR; } #endif #ifdef WOLFSSL_SHA384 if ( (ssl->error = - InitSha384(&ssl->hashSha384)) != 0) { + wc_InitSha384(&ssl->hashSha384)) != 0) { WOLFSSL_ERROR(ssl->error); return SSL_FATAL_ERROR; } @@ -5328,8 +5328,8 @@ int wolfSSL_dtls_got_timeout(WOLFSSL* ssl) XMEMSET(&ssl->msgsReceived, 0, sizeof(ssl->msgsReceived)); /* re-init hashes, exclude first hello and verify request */ #ifndef NO_OLD_TLS - InitMd5(&ssl->hashMd5); - if ( (ssl->error = InitSha(&ssl->hashSha)) != 0) { + wc_InitMd5(&ssl->hashMd5); + if ( (ssl->error = wc_InitSha(&ssl->hashSha)) != 0) { WOLFSSL_ERROR(ssl->error); return SSL_FATAL_ERROR; } @@ -5337,14 +5337,14 @@ int wolfSSL_dtls_got_timeout(WOLFSSL* ssl) if (IsAtLeastTLSv1_2(ssl)) { #ifndef NO_SHA256 if ( (ssl->error = - InitSha256(&ssl->hashSha256)) != 0) { + wc_InitSha256(&ssl->hashSha256)) != 0) { WOLFSSL_ERROR(ssl->error); return SSL_FATAL_ERROR; } #endif #ifdef WOLFSSL_SHA384 if ( (ssl->error = - InitSha384(&ssl->hashSha384)) != 0) { + wc_InitSha384(&ssl->hashSha384)) != 0) { WOLFSSL_ERROR(ssl->error); return SSL_FATAL_ERROR; } @@ -6964,7 +6964,7 @@ int wolfSSL_set_compression(WOLFSSL* ssl) #endif WOLFSSL_ENTER("EVP_BytesToKey"); - InitMd5(md5); + wc_InitMd5(md5); /* only support MD5 for now */ if (XSTRNCMP(md, "MD5", 3) != 0) return 0; @@ -7004,17 +7004,17 @@ int wolfSSL_set_compression(WOLFSSL* ssl) int digestLeft = MD5_DIGEST_SIZE; /* D_(i - 1) */ if (keyOutput) /* first time D_0 is empty */ - Md5Update(md5, digest, MD5_DIGEST_SIZE); + wc_Md5Update(md5, digest, MD5_DIGEST_SIZE); /* data */ - Md5Update(md5, data, sz); + wc_Md5Update(md5, data, sz); /* salt */ if (salt) - Md5Update(md5, salt, EVP_SALT_SIZE); - Md5Final(md5, digest); + wc_Md5Update(md5, salt, EVP_SALT_SIZE); + wc_Md5Final(md5, digest); /* count */ for (j = 1; j < count; j++) { - Md5Update(md5, digest, MD5_DIGEST_SIZE); - Md5Final(md5, digest); + wc_Md5Update(md5, digest, MD5_DIGEST_SIZE); + wc_Md5Final(md5, digest); } if (keyLeft) { @@ -7067,7 +7067,7 @@ int wolfSSL_set_compression(WOLFSSL* ssl) (void)sizeof(md5_test); WOLFSSL_ENTER("MD5_Init"); - InitMd5((Md5*)md5); + wc_InitMd5((Md5*)md5); } @@ -7075,14 +7075,14 @@ int wolfSSL_set_compression(WOLFSSL* ssl) unsigned long sz) { WOLFSSL_ENTER("wolfSSL_MD5_Update"); - Md5Update((Md5*)md5, (const byte*)input, (word32)sz); + wc_Md5Update((Md5*)md5, (const byte*)input, (word32)sz); } void wolfSSL_MD5_Final(byte* input, WOLFSSL_MD5_CTX* md5) { WOLFSSL_ENTER("MD5_Final"); - Md5Final((Md5*)md5, input); + wc_Md5Final((Md5*)md5, input); } @@ -7092,7 +7092,7 @@ int wolfSSL_set_compression(WOLFSSL* ssl) (void)sizeof(sha_test); WOLFSSL_ENTER("SHA_Init"); - InitSha((Sha*)sha); /* OpenSSL compat, no ret */ + wc_InitSha((Sha*)sha); /* OpenSSL compat, no ret */ } @@ -7100,14 +7100,14 @@ int wolfSSL_set_compression(WOLFSSL* ssl) unsigned long sz) { WOLFSSL_ENTER("SHA_Update"); - ShaUpdate((Sha*)sha, (const byte*)input, (word32)sz); + wc_ShaUpdate((Sha*)sha, (const byte*)input, (word32)sz); } void wolfSSL_SHA_Final(byte* input, WOLFSSL_SHA_CTX* sha) { WOLFSSL_ENTER("SHA_Final"); - ShaFinal((Sha*)sha, input); + wc_ShaFinal((Sha*)sha, input); } @@ -7139,7 +7139,7 @@ int wolfSSL_set_compression(WOLFSSL* ssl) (void)sizeof(sha_test); WOLFSSL_ENTER("SHA256_Init"); - InitSha256((Sha256*)sha256); /* OpenSSL compat, no error */ + wc_InitSha256((Sha256*)sha256); /* OpenSSL compat, no error */ } @@ -7147,7 +7147,7 @@ int wolfSSL_set_compression(WOLFSSL* ssl) unsigned long sz) { WOLFSSL_ENTER("SHA256_Update"); - Sha256Update((Sha256*)sha, (const byte*)input, (word32)sz); + wc_Sha256Update((Sha256*)sha, (const byte*)input, (word32)sz); /* OpenSSL compat, no error */ } @@ -7155,7 +7155,7 @@ int wolfSSL_set_compression(WOLFSSL* ssl) void wolfSSL_SHA256_Final(byte* input, WOLFSSL_SHA256_CTX* sha) { WOLFSSL_ENTER("SHA256_Final"); - Sha256Final((Sha256*)sha, input); + wc_Sha256Final((Sha256*)sha, input); /* OpenSSL compat, no error */ } @@ -7168,7 +7168,7 @@ int wolfSSL_set_compression(WOLFSSL* ssl) (void)sizeof(sha_test); WOLFSSL_ENTER("SHA384_Init"); - InitSha384((Sha384*)sha); /* OpenSSL compat, no error */ + wc_InitSha384((Sha384*)sha); /* OpenSSL compat, no error */ } @@ -7176,7 +7176,7 @@ int wolfSSL_set_compression(WOLFSSL* ssl) unsigned long sz) { WOLFSSL_ENTER("SHA384_Update"); - Sha384Update((Sha384*)sha, (const byte*)input, (word32)sz); + wc_Sha384Update((Sha384*)sha, (const byte*)input, (word32)sz); /* OpenSSL compat, no error */ } @@ -7184,7 +7184,7 @@ int wolfSSL_set_compression(WOLFSSL* ssl) void wolfSSL_SHA384_Final(byte* input, WOLFSSL_SHA384_CTX* sha) { WOLFSSL_ENTER("SHA384_Final"); - Sha384Final((Sha384*)sha, input); + wc_Sha384Final((Sha384*)sha, input); /* OpenSSL compat, no error */ } @@ -7199,7 +7199,7 @@ int wolfSSL_set_compression(WOLFSSL* ssl) (void)sizeof(sha_test); WOLFSSL_ENTER("SHA512_Init"); - InitSha512((Sha512*)sha); /* OpenSSL compat, no error */ + wc_InitSha512((Sha512*)sha); /* OpenSSL compat, no error */ } @@ -7207,7 +7207,7 @@ int wolfSSL_set_compression(WOLFSSL* ssl) unsigned long sz) { WOLFSSL_ENTER("SHA512_Update"); - Sha512Update((Sha512*)sha, (const byte*)input, (word32)sz); + wc_Sha512Update((Sha512*)sha, (const byte*)input, (word32)sz); /* OpenSSL compat, no error */ } @@ -7215,7 +7215,7 @@ int wolfSSL_set_compression(WOLFSSL* ssl) void wolfSSL_SHA512_Final(byte* input, WOLFSSL_SHA512_CTX* sha) { WOLFSSL_ENTER("SHA512_Final"); - Sha512Final((Sha512*)sha, input); + wc_Sha512Final((Sha512*)sha, input); /* OpenSSL compat, no error */ } @@ -7415,13 +7415,13 @@ int wolfSSL_set_compression(WOLFSSL* ssl) if (enc == 0 || enc == 1) ctx->enc = enc ? 1 : 0; if (key) { - ret = AesSetKey(&ctx->cipher.aes, key, ctx->keyLen, iv, + ret = wc_AesSetKey(&ctx->cipher.aes, key, ctx->keyLen, iv, ctx->enc ? AES_ENCRYPTION : AES_DECRYPTION); if (ret != 0) return ret; } if (iv && key == NULL) { - ret = AesSetIV(&ctx->cipher.aes, iv); + ret = wc_AesSetIV(&ctx->cipher.aes, iv); if (ret != 0) return ret; } @@ -7434,13 +7434,13 @@ int wolfSSL_set_compression(WOLFSSL* ssl) if (enc == 0 || enc == 1) ctx->enc = enc ? 1 : 0; if (key) { - ret = AesSetKey(&ctx->cipher.aes, key, ctx->keyLen, iv, + ret = wc_AesSetKey(&ctx->cipher.aes, key, ctx->keyLen, iv, ctx->enc ? AES_ENCRYPTION : AES_DECRYPTION); if (ret != 0) return ret; } if (iv && key == NULL) { - ret = AesSetIV(&ctx->cipher.aes, iv); + ret = wc_AesSetIV(&ctx->cipher.aes, iv); if (ret != 0) return ret; } @@ -7453,13 +7453,13 @@ int wolfSSL_set_compression(WOLFSSL* ssl) if (enc == 0 || enc == 1) ctx->enc = enc ? 1 : 0; if (key) { - ret = AesSetKey(&ctx->cipher.aes, key, ctx->keyLen, iv, + ret = wc_AesSetKey(&ctx->cipher.aes, key, ctx->keyLen, iv, ctx->enc ? AES_ENCRYPTION : AES_DECRYPTION); if (ret != 0) return ret; } if (iv && key == NULL) { - ret = AesSetIV(&ctx->cipher.aes, iv); + ret = wc_AesSetIV(&ctx->cipher.aes, iv); if (ret != 0) return ret; } @@ -7473,13 +7473,13 @@ int wolfSSL_set_compression(WOLFSSL* ssl) if (enc == 0 || enc == 1) ctx->enc = enc ? 1 : 0; if (key) { - ret = AesSetKey(&ctx->cipher.aes, key, ctx->keyLen, iv, + ret = wc_AesSetKey(&ctx->cipher.aes, key, ctx->keyLen, iv, AES_ENCRYPTION); if (ret != 0) return ret; } if (iv && key == NULL) { - ret = AesSetIV(&ctx->cipher.aes, iv); + ret = wc_AesSetIV(&ctx->cipher.aes, iv); if (ret != 0) return ret; } @@ -7492,13 +7492,13 @@ int wolfSSL_set_compression(WOLFSSL* ssl) if (enc == 0 || enc == 1) ctx->enc = enc ? 1 : 0; if (key) { - ret = AesSetKey(&ctx->cipher.aes, key, ctx->keyLen, iv, + ret = wc_AesSetKey(&ctx->cipher.aes, key, ctx->keyLen, iv, AES_ENCRYPTION); if (ret != 0) return ret; } if (iv && key == NULL) { - ret = AesSetIV(&ctx->cipher.aes, iv); + ret = wc_AesSetIV(&ctx->cipher.aes, iv); if (ret != 0) return ret; } @@ -7511,13 +7511,13 @@ int wolfSSL_set_compression(WOLFSSL* ssl) if (enc == 0 || enc == 1) ctx->enc = enc ? 1 : 0; if (key) { - ret = AesSetKey(&ctx->cipher.aes, key, ctx->keyLen, iv, + ret = wc_AesSetKey(&ctx->cipher.aes, key, ctx->keyLen, iv, AES_ENCRYPTION); if (ret != 0) return ret; } if (iv && key == NULL) { - ret = AesSetIV(&ctx->cipher.aes, iv); + ret = wc_AesSetIV(&ctx->cipher.aes, iv); if (ret != 0) return ret; } @@ -7531,14 +7531,14 @@ int wolfSSL_set_compression(WOLFSSL* ssl) if (enc == 0 || enc == 1) ctx->enc = enc ? 1 : 0; if (key) { - ret = Des_SetKey(&ctx->cipher.des, key, iv, + ret = wc_Des_SetKey(&ctx->cipher.des, key, iv, ctx->enc ? DES_ENCRYPTION : DES_DECRYPTION); if (ret != 0) return ret; } if (iv && key == NULL) - Des_SetIV(&ctx->cipher.des, iv); + wc_Des_SetIV(&ctx->cipher.des, iv); } else if (ctx->cipherType == DES_EDE3_CBC_TYPE || (type && XSTRNCMP(type, "DES-EDE3-CBC", 11) == 0)) { @@ -7548,14 +7548,14 @@ int wolfSSL_set_compression(WOLFSSL* ssl) if (enc == 0 || enc == 1) ctx->enc = enc ? 1 : 0; if (key) { - ret = Des3_SetKey(&ctx->cipher.des3, key, iv, + ret = wc_Des3_SetKey(&ctx->cipher.des3, key, iv, ctx->enc ? DES_ENCRYPTION : DES_DECRYPTION); if (ret != 0) return ret; } if (iv && key == NULL) { - ret = Des3_SetIV(&ctx->cipher.des3, iv); + ret = wc_Des3_SetIV(&ctx->cipher.des3, iv); if (ret != 0) return ret; } @@ -7632,9 +7632,9 @@ int wolfSSL_set_compression(WOLFSSL* ssl) case AES_256_CBC_TYPE : WOLFSSL_MSG("AES CBC"); if (ctx->enc) - ret = AesCbcEncrypt(&ctx->cipher.aes, dst, src, len); + ret = wc_AesCbcEncrypt(&ctx->cipher.aes, dst, src, len); else - ret = AesCbcDecrypt(&ctx->cipher.aes, dst, src, len); + ret = wc_AesCbcDecrypt(&ctx->cipher.aes, dst, src, len); break; #ifdef WOLFSSL_AES_COUNTER @@ -7648,16 +7648,16 @@ int wolfSSL_set_compression(WOLFSSL* ssl) case DES_CBC_TYPE : if (ctx->enc) - Des_CbcEncrypt(&ctx->cipher.des, dst, src, len); + wc_Des_CbcEncrypt(&ctx->cipher.des, dst, src, len); else - Des_CbcDecrypt(&ctx->cipher.des, dst, src, len); + wc_Des_CbcDecrypt(&ctx->cipher.des, dst, src, len); break; case DES_EDE3_CBC_TYPE : if (ctx->enc) - ret = Des3_CbcEncrypt(&ctx->cipher.des3, dst, src, len); + ret = wc_Des3_CbcEncrypt(&ctx->cipher.des3, dst, src, len); else - ret = Des3_CbcDecrypt(&ctx->cipher.des3, dst, src, len); + ret = wc_Des3_CbcDecrypt(&ctx->cipher.des3, dst, src, len); break; case ARC4_TYPE : @@ -7994,12 +7994,12 @@ int wolfSSL_set_compression(WOLFSSL* ssl) WOLFSSL_ENTER("DES_cbc_encrypt"); /* OpenSSL compat, no ret */ - Des_SetKey(&myDes, (const byte*)schedule, (const byte*)ivec, !enc); + wc_Des_SetKey(&myDes, (const byte*)schedule, (const byte*)ivec, !enc); if (enc) - Des_CbcEncrypt(&myDes, output, input, (word32)length); + wc_Des_CbcEncrypt(&myDes, output, input, (word32)length); else - Des_CbcDecrypt(&myDes, output, input, (word32)length); + wc_Des_CbcDecrypt(&myDes, output, input, (word32)length); } @@ -8014,12 +8014,12 @@ int wolfSSL_set_compression(WOLFSSL* ssl) WOLFSSL_ENTER("DES_ncbc_encrypt"); /* OpenSSL compat, no ret */ - Des_SetKey(&myDes, (const byte*)schedule, (const byte*)ivec, !enc); + wc_Des_SetKey(&myDes, (const byte*)schedule, (const byte*)ivec, !enc); if (enc) - Des_CbcEncrypt(&myDes, output, input, (word32)length); + wc_Des_CbcEncrypt(&myDes, output, input, (word32)length); else - Des_CbcDecrypt(&myDes, output, input, (word32)length); + wc_Des_CbcDecrypt(&myDes, output, input, (word32)length); XMEMCPY(ivec, output + length - sizeof(DES_cblock), sizeof(DES_cblock)); } @@ -9359,7 +9359,7 @@ void wolfSSL_MD4_Init(WOLFSSL_MD4_CTX* md4) (void) sizeof(ok); WOLFSSL_ENTER("MD4_Init"); - InitMd4((Md4*)md4); + wc_InitMd4((Md4*)md4); } @@ -10250,7 +10250,7 @@ int wolfSSL_RAND_seed(const void* seed, int len) (void)len; if (initGlobalRNG == 0) { - if (InitRng(&globalRNG) < 0) { + if (wc_InitRng(&globalRNG) < 0) { WOLFSSL_MSG("wolfSSL Init Global RNG failed"); return 0; } @@ -10281,7 +10281,7 @@ int wolfSSL_RAND_bytes(unsigned char* buf, int num) return ret; #endif - if (InitRng(tmpRNG) == 0) { + if (wc_InitRng(tmpRNG) == 0) { rng = tmpRNG; initTmpRng = 1; } @@ -10289,15 +10289,15 @@ int wolfSSL_RAND_bytes(unsigned char* buf, int num) rng = &globalRNG; if (rng) { - if (RNG_GenerateBlock(rng, buf, num) != 0) - WOLFSSL_MSG("Bad RNG_GenerateBlock"); + if (wc_RNG_GenerateBlock(rng, buf, num) != 0) + WOLFSSL_MSG("Bad wc_RNG_GenerateBlock"); else ret = SSL_SUCCESS; } if (initTmpRng) { #if defined(HAVE_HASHDRBG) || defined(NO_RC4) - FreeRng(tmpRNG); + wc_FreeRng(tmpRNG); #endif } @@ -10602,14 +10602,14 @@ int wolfSSL_BN_rand(WOLFSSL_BIGNUM* bn, int bits, int top, int bottom) if (bn == NULL || bn->internal == NULL) WOLFSSL_MSG("Bad function arguments"); - else if (InitRng(tmpRNG) == 0) + else if (wc_InitRng(tmpRNG) == 0) rng = tmpRNG; else if (initGlobalRNG) rng = &globalRNG; if (rng) { - if (RNG_GenerateBlock(rng, buff, len) != 0) - WOLFSSL_MSG("Bad RNG_GenerateBlock"); + if (wc_RNG_GenerateBlock(rng, buff, len) != 0) + WOLFSSL_MSG("Bad wc_RNG_GenerateBlock"); else { buff[0] |= 0x80 | 0x40; buff[len-1] |= 0x01; @@ -10617,8 +10617,8 @@ int wolfSSL_BN_rand(WOLFSSL_BIGNUM* bn, int bits, int top, int bottom) if (mp_read_unsigned_bin((mp_int*)bn->internal,buff,len) != MP_OKAY) WOLFSSL_MSG("mp read bin failed"); else - ret = SSL_SUCCESS; - } + ret = SSL_SUCCESS; + } } #ifdef WOLFSSL_SMALL_STACK @@ -10925,7 +10925,7 @@ int wolfSSL_DH_generate_key(WOLFSSL_DH* dh) WOLFSSL_MSG("Bad function arguments"); else if (dh->inSet == 0 && SetDhInternal(dh) < 0) WOLFSSL_MSG("Bad DH set internal"); - else if (InitRng(tmpRNG) == 0) + else if (wc_InitRng(tmpRNG) == 0) rng = tmpRNG; else { WOLFSSL_MSG("Bad RNG Init, trying global"); @@ -11174,7 +11174,7 @@ WOLFSSL_RSA* wolfSSL_RSA_new(void) } InitwolfSSL_Rsa(external); - if (InitRsaKey(key, NULL) != 0) { + if (wc_InitRsaKey(key, NULL) != 0) { WOLFSSL_MSG("InitRsaKey WOLFSSL_RSA failure"); XFREE(external, NULL, DYNAMIC_TYPE_RSA); XFREE(key, NULL, DYNAMIC_TYPE_RSA); @@ -11371,7 +11371,7 @@ int wolfSSL_RSA_generate_key_ex(WOLFSSL_RSA* rsa, int bits, WOLFSSL_BIGNUM* bn, return SSL_FATAL_ERROR; #endif - if (InitRng(rng) < 0) + if (wc_InitRng(rng) < 0) WOLFSSL_MSG("RNG init failed"); else if (wc_MakeRsaKey((RsaKey*)rsa->internal, bits, 65537, rng) < 0) WOLFSSL_MSG("wc_MakeRsaKey failed"); @@ -11473,7 +11473,7 @@ int wolfSSL_DSA_do_sign(const unsigned char* d, unsigned char* sigRet, return SSL_FATAL_ERROR; #endif - if (InitRng(tmpRNG) == 0) + if (wc_InitRng(tmpRNG) == 0) rng = tmpRNG; else { WOLFSSL_MSG("Bad RNG Init, trying global"); @@ -11544,7 +11544,7 @@ int wolfSSL_RSA_sign(int type, const unsigned char* m, if (outLen == 0) WOLFSSL_MSG("Bad RSA size"); - else if (InitRng(tmpRNG) == 0) + else if (wc_InitRng(tmpRNG) == 0) rng = tmpRNG; else { WOLFSSL_MSG("Bad RNG Init, trying global"); @@ -11564,7 +11564,7 @@ int wolfSSL_RSA_sign(int type, const unsigned char* m, WOLFSSL_MSG("Bad Encode Signature"); } else { - *sigLen = RsaSSL_Sign(encodedSig, signSz, sigRet, outLen, + *sigLen = wc_RsaSSL_Sign(encodedSig, signSz, sigRet, outLen, (RsaKey*)rsa->internal, rng); if (*sigLen <= 0) WOLFSSL_MSG("Bad Rsa Sign"); @@ -11832,7 +11832,7 @@ void wolfSSL_3des_iv(WOLFSSL_EVP_CIPHER_CTX* ctx, int doset, } if (doset) - Des3_SetIV(&ctx->cipher.des3, iv); /* OpenSSL compat, no ret */ + wc_Des3_SetIV(&ctx->cipher.des3, iv); /* OpenSSL compat, no ret */ else memcpy(iv, &ctx->cipher.des3.reg, DES_BLOCK_SIZE); } @@ -11851,7 +11851,7 @@ void wolfSSL_aes_ctr_iv(WOLFSSL_EVP_CIPHER_CTX* ctx, int doset, } if (doset) - AesSetIV(&ctx->cipher.aes, iv); /* OpenSSL compat, no ret */ + wc_AesSetIV(&ctx->cipher.aes, iv); /* OpenSSL compat, no ret */ else memcpy(iv, &ctx->cipher.aes.reg, AES_BLOCK_SIZE); } @@ -12020,7 +12020,7 @@ int wolfSSL_RSA_LoadDer(WOLFSSL_RSA* rsa, const unsigned char* der, int derSz) return BAD_FUNC_ARG; } - ret = RsaPrivateKeyDecode(der, &idx, (RsaKey*)rsa->internal, derSz); + ret = wc_RsaPrivateKeyDecode(der, &idx, (RsaKey*)rsa->internal, derSz); if (ret < 0) { WOLFSSL_MSG("RsaPrivateKeyDecode failed"); return ret; diff --git a/testsuite/testsuite.c b/testsuite/testsuite.c index abd41f319..a3c986316 100644 --- a/testsuite/testsuite.c +++ b/testsuite/testsuite.c @@ -135,7 +135,7 @@ int testsuite_test(int argc, char** argv) echo_args.argc = 3; echo_args.argv = myArgv; - + strcpy(echo_args.argv[0], "echoclient"); strcpy(echo_args.argv[1], "input"); strcpy(echo_args.argv[2], outputName); @@ -146,7 +146,7 @@ int testsuite_test(int argc, char** argv) /* make sure OK */ echoclient_test(&echo_args); - if (echo_args.return_code != 0) return echo_args.return_code; + if (echo_args.return_code != 0) return echo_args.return_code; #ifdef WOLFSSL_DTLS wait_tcp_ready(&server_args); @@ -235,7 +235,7 @@ void simple_test(func_args* args) cliArgs.argc = 1; cliArgs.argv = cliArgv; cliArgs.return_code = 0; - + strcpy(svrArgs.argv[0], "SimpleServer"); #if !defined(USE_WINDOWS_API) && !defined(WOLFSSL_SNIFFER) && \ !defined(WOLFSSL_TIRTOS) @@ -256,7 +256,7 @@ void simple_test(func_args* args) svrArgs.signal = args->signal; start_thread(server_test, &svrArgs, &serverThread); wait_tcp_ready(&svrArgs); - + /* Setting the actual port number. */ strcpy(cliArgs.argv[0], "SimpleClient"); #ifndef USE_WINDOWS_API @@ -279,7 +279,7 @@ void wait_tcp_ready(func_args* args) { #if defined(_POSIX_THREADS) && !defined(__MINGW32__) pthread_mutex_lock(&args->signal->mutex); - + if (!args->signal->ready) pthread_cond_wait(&args->signal->cond, &args->signal->mutex); args->signal->ready = 0; /* reset */ @@ -363,7 +363,7 @@ void file_test(const char* file, byte* check) Sha256 sha256; byte buf[1024]; byte shasum[SHA256_DIGEST_SIZE]; - + ret = wc_InitSha256(&sha256); if (ret != 0) { printf("Can't wc_InitSha256 %d\n", ret); @@ -380,7 +380,7 @@ void file_test(const char* file, byte* check) return; } } - + ret = wc_Sha256Final(&sha256, shasum); if (ret != 0) { printf("Can't wc_Sha256Final %d\n", ret); @@ -389,9 +389,9 @@ void file_test(const char* file, byte* check) memcpy(check, shasum, sizeof(shasum)); - for(j = 0; j < SHA256_DIGEST_SIZE; ++j ) + for(j = 0; j < SHA256_DIGEST_SIZE; ++j ) printf( "%02x", shasum[j] ); - + printf(" %s\n", file); fclose(f); diff --git a/wolfcrypt/src/aes.c b/wolfcrypt/src/aes.c index 850685297..9c99db84f 100644 --- a/wolfcrypt/src/aes.c +++ b/wolfcrypt/src/aes.c @@ -63,7 +63,7 @@ int wc_AesCbcDecryptWithKey(byte* out, const byte* in, word32 inSz, /* AES-CTR */ -#ifdef CYASSL_AES_COUNTER +#ifdef WOLFSSL_AES_COUNTER void wc_AesCtrEncrypt(Aes* aes, byte* out, const byte* in, word32 sz) { AesCtrEncrypt(aes, out, in, sz); @@ -71,7 +71,7 @@ void wc_AesCtrEncrypt(Aes* aes, byte* out, const byte* in, word32 sz) #endif /* AES-DIRECT */ -#if defined(CYASSL_AES_DIRECT) +#if defined(WOLFSSL_AES_DIRECT) void wc_AesEncryptDirect(Aes* aes, byte* out, const byte* in) { AesEncryptDirect(aes, out, in); @@ -213,9 +213,9 @@ void wc_AesFreeCavium(Aes* aes) * Guide (See note in README). * NOTE: no support for AES-CTR */ #include "cau_api.h" -#elif defined(CYASSL_PIC32MZ_CRYPT) +#elif defined(WOLFSSL_PIC32MZ_CRYPT) /* NOTE: no support for AES-CCM/Direct */ - #define DEBUG_CYASSL + #define DEBUG_WOLFSSL #include "wolfssl/wolfcrypt/port/pic32/pic32mz-crypt.h" #elif defined(HAVE_CAVIUM) #include @@ -914,7 +914,7 @@ static const word32 Td[5][256] = { #define GETBYTE(x, y) (word32)((byte)((x) >> (8 * (y)))) -#ifdef CYASSL_AESNI +#ifdef WOLFSSL_AESNI /* Each platform needs to query info type 1 from cpuid to see if aesni is * supported. Also, let's setup a macro for proper linkage w/o ABI conflicts @@ -1055,7 +1055,7 @@ static int AES_set_decrypt_key(const unsigned char* userKey, const int bits, -#endif /* CYASSL_AESNI */ +#endif /* WOLFSSL_AESNI */ static void wc_AesEncrypt(Aes* aes, const byte* inBlock, byte* outBlock) @@ -1066,10 +1066,10 @@ static void wc_AesEncrypt(Aes* aes, const byte* inBlock, byte* outBlock) const word32* rk = aes->key; if (r > 7 || r == 0) { - CYASSL_MSG("AesEncrypt encountered improper key, set it up"); + WOLFSSL_MSG("AesEncrypt encountered improper key, set it up"); return; /* stop instead of segfaulting, set up your keys! */ } -#ifdef CYASSL_AESNI +#ifdef WOLFSSL_AESNI if (haveAESNI && aes->use_aesni) { #ifdef DEBUG_AESNI printf("about to aes encrypt\n"); @@ -1081,8 +1081,8 @@ static void wc_AesEncrypt(Aes* aes, const byte* inBlock, byte* outBlock) #endif /* check alignment, decrypt doesn't need alignment */ - if ((cyassl_word)inBlock % 16) { - #ifndef NO_CYASSL_ALLOC_ALIGN + if ((wolfssl_word)inBlock % 16) { + #ifndef NO_WOLFSSL_ALLOC_ALIGN byte* tmp = (byte*)XMALLOC(AES_BLOCK_SIZE, NULL, DYNAMIC_TYPE_TMP_BUFFER); if (tmp == NULL) return; @@ -1094,7 +1094,7 @@ static void wc_AesEncrypt(Aes* aes, const byte* inBlock, byte* outBlock) XFREE(tmp, NULL, DYNAMIC_TYPE_TMP_BUFFER); return; #else - CYASSL_MSG("AES-ECB encrypt with bad alignment"); + WOLFSSL_MSG("AES-ECB encrypt with bad alignment"); return; #endif } @@ -1245,10 +1245,10 @@ static void wc_AesDecrypt(Aes* aes, const byte* inBlock, byte* outBlock) const word32* rk = aes->key; if (r > 7 || r == 0) { - CYASSL_MSG("AesDecrypt encountered improper key, set it up"); + WOLFSSL_MSG("AesDecrypt encountered improper key, set it up"); return; /* stop instead of segfaulting, set up your keys! */ } -#ifdef CYASSL_AESNI +#ifdef WOLFSSL_AESNI if (haveAESNI && aes->use_aesni) { #ifdef DEBUG_AESNI printf("about to aes decrypt\n"); @@ -1512,12 +1512,12 @@ static void wc_AesDecrypt(Aes* aes, const byte* inBlock, byte* outBlock) word32 temp, *rk = aes->key; unsigned int i = 0; - #ifdef CYASSL_AESNI + #ifdef WOLFSSL_AESNI aes->use_aesni = 0; - #endif /* CYASSL_AESNI */ - #ifdef CYASSL_AES_COUNTER + #endif /* WOLFSSL_AESNI */ + #ifdef WOLFSSL_AES_COUNTER aes->left = 0; - #endif /* CYASSL_AES_COUNTER */ + #endif /* WOLFSSL_AES_COUNTER */ aes->rounds = keylen/4 + 6; @@ -1526,7 +1526,7 @@ static void wc_AesDecrypt(Aes* aes, const byte* inBlock, byte* outBlock) ByteReverseWords(rk, rk, keylen); #endif - #ifdef CYASSL_PIC32MZ_CRYPT + #ifdef WOLFSSL_PIC32MZ_CRYPT { word32 *akey1 = aes->key_ce; word32 *areg = aes->iv_ce ; @@ -1665,11 +1665,11 @@ static void wc_AesDecrypt(Aes* aes, const byte* inBlock, byte* outBlock) return BAD_FUNC_ARG; #ifdef HAVE_CAVIUM - if (aes->magic == CYASSL_AES_CAVIUM_MAGIC) + if (aes->magic == WOLFSSL_AES_CAVIUM_MAGIC) return wc_AesCaviumSetKey(aes, userKey, keylen, iv); #endif - #ifdef CYASSL_AESNI + #ifdef WOLFSSL_AESNI if (checkAESNI == 0) { haveAESNI = Check_CPU_support_AES(); checkAESNI = 1; @@ -1683,12 +1683,12 @@ static void wc_AesDecrypt(Aes* aes, const byte* inBlock, byte* outBlock) else return AES_set_decrypt_key(userKey, keylen * 8, aes); } - #endif /* CYASSL_AESNI */ + #endif /* WOLFSSL_AESNI */ return wc_AesSetKeyLocal(aes, userKey, keylen, iv, dir); } - #if defined(CYASSL_AES_DIRECT) || defined(CYASSL_AES_COUNTER) + #if defined(WOLFSSL_AES_DIRECT) || defined(CYASSL_AES_COUNTER) /* AES-CTR and AES-DIRECT need to use this for key setup, no aesni yet */ int wc_AesSetKeyDirect(Aes* aes, const byte* userKey, word32 keylen, @@ -1697,7 +1697,7 @@ static void wc_AesDecrypt(Aes* aes, const byte* inBlock, byte* outBlock) return wc_AesSetKeyLocal(aes, userKey, keylen, iv, dir); } - #endif /* CYASSL_AES_DIRECT || CYASSL_AES_COUNTER */ + #endif /* WOLFSSL_AES_DIRECT || CYASSL_AES_COUNTER */ #endif /* STM32F2_CRYPTO, wc_AesSetKey block */ @@ -1720,13 +1720,13 @@ int wc_AesCbcDecryptWithKey(byte* out, const byte* in, word32 inSz, const byte* key, word32 keySz, const byte* iv) { int ret = 0; -#ifdef CYASSL_SMALL_STACK +#ifdef WOLFSSL_SMALL_STACK Aes* aes = NULL; #else Aes aes[1]; #endif -#ifdef CYASSL_SMALL_STACK +#ifdef WOLFSSL_SMALL_STACK aes = (Aes*)XMALLOC(sizeof(Aes), NULL, DYNAMIC_TYPE_TMP_BUFFER); if (aes == NULL) return MEMORY_E; @@ -1736,7 +1736,7 @@ int wc_AesCbcDecryptWithKey(byte* out, const byte* in, word32 inSz, if (ret == 0) ret = wc_AesCbcDecrypt(aes, out, in, inSz); -#ifdef CYASSL_SMALL_STACK +#ifdef WOLFSSL_SMALL_STACK XFREE(aes, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif @@ -1745,7 +1745,7 @@ int wc_AesCbcDecryptWithKey(byte* out, const byte* in, word32 inSz, /* AES-DIRECT */ -#if defined(CYASSL_AES_DIRECT) +#if defined(WOLFSSL_AES_DIRECT) #if defined(FREESCALE_MMCAU) /* Allow direct access to one block encrypt */ @@ -1772,7 +1772,7 @@ int wc_AesCbcDecryptWithKey(byte* out, const byte* in, word32 inSz, #elif defined(HAVE_COLDFIRE_SEC) #error "Coldfire SEC doesn't yet support AES direct" - #elif defined(CYASSL_PIC32MZ_CRYPT) + #elif defined(WOLFSSL_PIC32MZ_CRYPT) #error "PIC32MZ doesn't yet support AES direct" #else @@ -1789,7 +1789,7 @@ int wc_AesCbcDecryptWithKey(byte* out, const byte* in, word32 inSz, } #endif /* FREESCALE_MMCAU, AES direct block */ -#endif /* CYASSL_AES_DIRECT */ +#endif /* WOLFSSL_AES_DIRECT */ /* AES-CBC */ @@ -2024,7 +2024,7 @@ int wc_AesCbcDecryptWithKey(byte* out, const byte* in, word32 inSz, static int wc_AesCbcCrypt(Aes* aes, byte* po, const byte* pi, word32 sz, word32 descHeader) { - #ifdef DEBUG_CYASSL + #ifdef DEBUG_WOLFSSL int i; int stat1, stat2; int ret; #endif @@ -2087,7 +2087,7 @@ int wc_AesCbcDecryptWithKey(byte* out, const byte* in, word32 inSz, while ((secDesc->header>> 24) != 0xff) v++; - #ifdef DEBUG_CYASSL + #ifdef DEBUG_WOLFSSL ret = MCF_SEC_SISRH; stat1 = MCF_SEC_AESSR; stat2 = MCF_SEC_AESISR; @@ -2137,8 +2137,8 @@ int wc_AesCbcDecryptWithKey(byte* out, const byte* in, word32 inSz, iv = (byte*)aes->reg; enc_key = (byte*)aes->key; - if ((cyassl_word)out % CYASSL_MMCAU_ALIGNMENT) { - CYASSL_MSG("Bad cau_aes_encrypt alignment"); + if ((wolfssl_word)out % WOLFSSL_MMCAU_ALIGNMENT) { + WOLFSSL_MSG("Bad cau_aes_encrypt alignment"); return BAD_ALIGN_E; } @@ -2174,8 +2174,8 @@ int wc_AesCbcDecryptWithKey(byte* out, const byte* in, word32 inSz, iv = (byte*)aes->reg; dec_key = (byte*)aes->key; - if ((cyassl_word)out % CYASSL_MMCAU_ALIGNMENT) { - CYASSL_MSG("Bad cau_aes_decrypt alignment"); + if ((wolfssl_word)out % WOLFSSL_MMCAU_ALIGNMENT) { + WOLFSSL_MSG("Bad cau_aes_decrypt alignment"); return BAD_ALIGN_E; } @@ -2199,7 +2199,7 @@ int wc_AesCbcDecryptWithKey(byte* out, const byte* in, word32 inSz, return 0; } -#elif defined(CYASSL_PIC32MZ_CRYPT) +#elif defined(WOLFSSL_PIC32MZ_CRYPT) /* core hardware crypt engine driver */ static void wc_AesCrypt(Aes *aes, byte* out, const byte* in, word32 sz, int dir, int algo, int cryptoalgo) @@ -2315,11 +2315,11 @@ int wc_AesCbcDecryptWithKey(byte* out, const byte* in, word32 inSz, word32 blocks = sz / AES_BLOCK_SIZE; #ifdef HAVE_CAVIUM - if (aes->magic == CYASSL_AES_CAVIUM_MAGIC) + if (aes->magic == WOLFSSL_AES_CAVIUM_MAGIC) return wc_AesCaviumCbcEncrypt(aes, out, in, sz); #endif - #ifdef CYASSL_AESNI + #ifdef WOLFSSL_AESNI if (haveAESNI) { #ifdef DEBUG_AESNI printf("about to aes cbc encrypt\n"); @@ -2332,10 +2332,10 @@ int wc_AesCbcDecryptWithKey(byte* out, const byte* in, word32 inSz, #endif /* check alignment, decrypt doesn't need alignment */ - if ((cyassl_word)in % 16) { - #ifndef NO_CYASSL_ALLOC_ALIGN + if ((wolfssl_word)in % 16) { + #ifndef NO_WOLFSSL_ALLOC_ALIGN byte* tmp = (byte*)XMALLOC(sz, NULL, DYNAMIC_TYPE_TMP_BUFFER); - CYASSL_MSG("AES-CBC encrypt with bad alignment"); + WOLFSSL_MSG("AES-CBC encrypt with bad alignment"); if (tmp == NULL) return MEMORY_E; XMEMCPY(tmp, in, sz); @@ -2378,11 +2378,11 @@ int wc_AesCbcDecryptWithKey(byte* out, const byte* in, word32 inSz, word32 blocks = sz / AES_BLOCK_SIZE; #ifdef HAVE_CAVIUM - if (aes->magic == CYASSL_AES_CAVIUM_MAGIC) + if (aes->magic == WOLFSSL_AES_CAVIUM_MAGIC) return wc_AesCaviumCbcDecrypt(aes, out, in, sz); #endif - #ifdef CYASSL_AESNI + #ifdef WOLFSSL_AESNI if (haveAESNI) { #ifdef DEBUG_AESNI printf("about to aes cbc decrypt\n"); @@ -2420,7 +2420,7 @@ int wc_AesCbcDecryptWithKey(byte* out, const byte* in, word32 inSz, #endif /* STM32F2_CRYPTO, AES-CBC block */ /* AES-CTR */ -#ifdef CYASSL_AES_COUNTER +#ifdef WOLFSSL_AES_COUNTER #ifdef STM32F2_CRYPTO void wc_AesCtrEncrypt(Aes* aes, byte* out, const byte* in, word32 sz) @@ -2526,7 +2526,7 @@ int wc_AesCbcDecryptWithKey(byte* out, const byte* in, word32 inSz, CRYP_Cmd(DISABLE); } - #elif defined(CYASSL_PIC32MZ_CRYPT) + #elif defined(WOLFSSL_PIC32MZ_CRYPT) void wc_AesCtrEncrypt(Aes* aes, byte* out, const byte* in, word32 sz) { int i ; @@ -2643,7 +2643,7 @@ int wc_AesCbcDecryptWithKey(byte* out, const byte* in, word32 inSz, #endif /* STM32F2_CRYPTO, AES-CTR block */ -#endif /* CYASSL_AES_COUNTER */ +#endif /* WOLFSSL_AES_COUNTER */ #ifdef HAVE_AESGCM @@ -3308,9 +3308,9 @@ int wc_AesGcmEncrypt(Aes* aes, byte* out, const byte* in, word32 sz, byte* key = (byte*)aes->key; #endif - CYASSL_ENTER("AesGcmEncrypt"); + WOLFSSL_ENTER("AesGcmEncrypt"); -#ifdef CYASSL_PIC32MZ_CRYPT +#ifdef WOLFSSL_PIC32MZ_CRYPT ctr = (char *)aes->iv_ce ; #else ctr = counter ; @@ -3320,14 +3320,14 @@ int wc_AesGcmEncrypt(Aes* aes, byte* out, const byte* in, word32 sz, XMEMCPY(ctr, iv, ivSz); InitGcmCounter(ctr); -#ifdef CYASSL_PIC32MZ_CRYPT +#ifdef WOLFSSL_PIC32MZ_CRYPT if(blocks) wc_AesCrypt(aes, out, in, blocks*AES_BLOCK_SIZE, PIC32_ENCRYPTION, PIC32_ALGO_AES, PIC32_CRYPTOALGO_AES_GCM ); #endif while (blocks--) { IncrementGcmCounter(ctr); - #ifndef CYASSL_PIC32MZ_CRYPT + #ifndef WOLFSSL_PIC32MZ_CRYPT #ifdef FREESCALE_MMCAU cau_aes_encrypt(ctr, key, aes->rounds, scratch); #else @@ -3382,9 +3382,9 @@ int wc_AesGcmDecrypt(Aes* aes, byte* out, const byte* in, word32 sz, byte* key = (byte*)aes->key; #endif - CYASSL_ENTER("AesGcmDecrypt"); + WOLFSSL_ENTER("AesGcmDecrypt"); -#ifdef CYASSL_PIC32MZ_CRYPT +#ifdef WOLFSSL_PIC32MZ_CRYPT ctr = (char *)aes->iv_ce ; #else ctr = counter ; @@ -3413,7 +3413,7 @@ int wc_AesGcmDecrypt(Aes* aes, byte* out, const byte* in, word32 sz, } } -#ifdef CYASSL_PIC32MZ_CRYPT +#ifdef WOLFSSL_PIC32MZ_CRYPT if(blocks) wc_AesCrypt(aes, out, in, blocks*AES_BLOCK_SIZE, PIC32_DECRYPTION, PIC32_ALGO_AES, PIC32_CRYPTOALGO_AES_GCM ); @@ -3421,7 +3421,7 @@ int wc_AesGcmDecrypt(Aes* aes, byte* out, const byte* in, word32 sz, while (blocks--) { IncrementGcmCounter(ctr); - #ifndef CYASSL_PIC32MZ_CRYPT + #ifndef WOLFSSL_PIC32MZ_CRYPT #ifdef FREESCALE_MMCAU cau_aes_encrypt(ctr, key, aes->rounds, scratch); #else @@ -3448,13 +3448,13 @@ int wc_AesGcmDecrypt(Aes* aes, byte* out, const byte* in, word32 sz, -CYASSL_API int GmacSetKey(Gmac* gmac, const byte* key, word32 len) +WOLFSSL_API int wc_GmacSetKey(Gmac* gmac, const byte* key, word32 len) { return wc_AesGcmSetKey(&gmac->aes, key, len); } -CYASSL_API int GmacUpdate(Gmac* gmac, const byte* iv, word32 ivSz, +WOLFSSL_API int wc_GmacUpdate(Gmac* gmac, const byte* iv, word32 ivSz, const byte* authIn, word32 authInSz, byte* authTag, word32 authTagSz) { @@ -3473,7 +3473,7 @@ CYASSL_API int GmacUpdate(Gmac* gmac, const byte* iv, word32 ivSz, #elif defined(HAVE_COLDFIRE_SEC) #error "Coldfire SEC doesn't currently support AES-CCM mode" -#elif defined(CYASSL_PIC32MZ_CRYPT) +#elif defined(WOLFSSL_PIC32MZ_CRYPT) #error "PIC32MZ doesn't currently support AES-CCM mode" #endif @@ -3764,7 +3764,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 */ @@ -3777,7 +3777,7 @@ int wc_AesInitCavium(Aes* aes, int devId) return -1; aes->devId = devId; - aes->magic = CYASSL_AES_CAVIUM_MAGIC; + aes->magic = WOLFSSL_AES_CAVIUM_MAGIC; return 0; } @@ -3789,7 +3789,7 @@ void wc_AesFreeCavium(Aes* aes) if (aes == NULL) return; - if (aes->magic != CYASSL_AES_CAVIUM_MAGIC) + if (aes->magic != WOLFSSL_AES_CAVIUM_MAGIC) return; CspFreeContext(CONTEXT_SSL, aes->contextHandle, aes->devId); @@ -3818,20 +3818,20 @@ static int wc_AesCaviumSetKey(Aes* aes, const byte* key, word32 length, static int AesCaviumCbcEncrypt(Aes* aes, byte* out, const byte* in, word32 length) { - cyassl_word offset = 0; + wolfssl_word offset = 0; word32 requestId; - while (length > CYASSL_MAX_16BIT) { - word16 slen = (word16)CYASSL_MAX_16BIT; + while (length > WOLFSSL_MAX_16BIT) { + word16 slen = (word16)WOLFSSL_MAX_16BIT; if (CspEncryptAes(CAVIUM_BLOCKING, aes->contextHandle, CAVIUM_NO_UPDATE, aes->type, slen, (byte*)in + offset, out + offset, (byte*)aes->reg, (byte*)aes->key, &requestId, aes->devId) != 0) { - CYASSL_MSG("Bad Cavium Aes Encrypt"); + WOLFSSL_MSG("Bad Cavium Aes Encrypt"); return -1; } - length -= CYASSL_MAX_16BIT; - offset += CYASSL_MAX_16BIT; + length -= WOLFSSL_MAX_16BIT; + offset += WOLFSSL_MAX_16BIT; XMEMCPY(aes->reg, out + offset - AES_BLOCK_SIZE, AES_BLOCK_SIZE); } if (length) { @@ -3840,7 +3840,7 @@ static int AesCaviumCbcEncrypt(Aes* aes, byte* out, const byte* in, aes->type, slen, (byte*)in + offset, out + offset, (byte*)aes->reg, (byte*)aes->key, &requestId, aes->devId) != 0) { - CYASSL_MSG("Bad Cavium Aes Encrypt"); + WOLFSSL_MSG("Bad Cavium Aes Encrypt"); return -1; } XMEMCPY(aes->reg, out + offset+length - AES_BLOCK_SIZE, AES_BLOCK_SIZE); @@ -3852,20 +3852,20 @@ static int AesCaviumCbcDecrypt(Aes* aes, byte* out, const byte* in, word32 length) { word32 requestId; - cyassl_word offset = 0; + wolfssl_word offset = 0; - while (length > CYASSL_MAX_16BIT) { - word16 slen = (word16)CYASSL_MAX_16BIT; + while (length > WOLFSSL_MAX_16BIT) { + word16 slen = (word16)WOLFSSL_MAX_16BIT; XMEMCPY(aes->tmp, in + offset + slen - AES_BLOCK_SIZE, AES_BLOCK_SIZE); if (CspDecryptAes(CAVIUM_BLOCKING, aes->contextHandle, CAVIUM_NO_UPDATE, aes->type, slen, (byte*)in + offset, out + offset, (byte*)aes->reg, (byte*)aes->key, &requestId, aes->devId) != 0) { - CYASSL_MSG("Bad Cavium Aes Decrypt"); + WOLFSSL_MSG("Bad Cavium Aes Decrypt"); return -1; } - length -= CYASSL_MAX_16BIT; - offset += CYASSL_MAX_16BIT; + length -= WOLFSSL_MAX_16BIT; + offset += WOLFSSL_MAX_16BIT; XMEMCPY(aes->reg, aes->tmp, AES_BLOCK_SIZE); } if (length) { @@ -3875,7 +3875,7 @@ static int AesCaviumCbcDecrypt(Aes* aes, byte* out, const byte* in, aes->type, slen, (byte*)in + offset, out + offset, (byte*)aes->reg, (byte*)aes->key, &requestId, aes->devId) != 0) { - CYASSL_MSG("Bad Cavium Aes Decrypt"); + WOLFSSL_MSG("Bad Cavium Aes Decrypt"); return -1; } XMEMCPY(aes->reg, aes->tmp, AES_BLOCK_SIZE); diff --git a/wolfcrypt/src/asn.c b/wolfcrypt/src/asn.c index 86deb6e3e..e9cf231c5 100644 --- a/wolfcrypt/src/asn.c +++ b/wolfcrypt/src/asn.c @@ -5494,7 +5494,7 @@ static int EncodeCert(Cert* cert, DerCert* der, RsaKey* rsaKey, ecc_key* eccKey, der->versionSz = SetMyVersion(cert->version, der->version, TRUE); /* serial number */ - ret = RNG_GenerateBlock(rng, cert->serial, CTC_SERIAL_SIZE); + ret = wc_RNG_GenerateBlock(rng, cert->serial, CTC_SERIAL_SIZE); if (ret != 0) return ret; @@ -7279,7 +7279,7 @@ int EncodeOcspRequest(OcspRequest* req) if (wc_InitRng(&rng) != 0) { WOLFSSL_MSG("\tCannot initialize RNG. Skipping the OSCP Nonce."); } else { - if (RNG_GenerateBlock(&rng, req->nonce, MAX_OCSP_NONCE_SZ) != 0) + if (wc_RNG_GenerateBlock(&rng, req->nonce, MAX_OCSP_NONCE_SZ) != 0) WOLFSSL_MSG("\tCannot run RNG. Skipping the OSCP Nonce."); else { req->nonceSz = MAX_OCSP_NONCE_SZ; diff --git a/wolfcrypt/src/blake2b.c b/wolfcrypt/src/blake2b.c index 58af31116..9af16315a 100644 --- a/wolfcrypt/src/blake2b.c +++ b/wolfcrypt/src/blake2b.c @@ -403,7 +403,7 @@ int main( int argc, char **argv ) /* wolfCrypt API */ /* Init Blake2b digest, track size incase final doesn't want to "remember" */ -int Wolf_InitBlake2b(Blake2b* b2b, word32 digestSz) +int wc_InitBlake2b(Blake2b* b2b, word32 digestSz) { b2b->digestSz = digestSz; @@ -412,14 +412,14 @@ int Wolf_InitBlake2b(Blake2b* b2b, word32 digestSz) /* Blake2b Update */ -int Wolf_Blake2bUpdate(Blake2b* b2b, const byte* data, word32 sz) +int wc_Blake2bUpdate(Blake2b* b2b, const byte* data, word32 sz) { return blake2b_update(b2b->S, data, sz); } /* Blake2b Final, if pass in zero size we use init digestSz */ -int Wolf_Blake2bFinal(Blake2b* b2b, byte* final, word32 requestSz) +int wc_Blake2bFinal(Blake2b* b2b, byte* final, word32 requestSz) { word32 sz = requestSz ? requestSz : b2b->digestSz; diff --git a/wolfcrypt/src/camellia.c b/wolfcrypt/src/camellia.c index b332fcfd5..8bf949de9 100644 --- a/wolfcrypt/src/camellia.c +++ b/wolfcrypt/src/camellia.c @@ -1527,7 +1527,7 @@ static void Camellia_DecryptBlock(const int keyBitLength, /* wolfCrypt wrappers to the Camellia code */ -int CamelliaSetKey(Camellia* cam, const byte* key, word32 len, const byte* iv) +int wc_CamelliaSetKey(Camellia* cam, const byte* key, word32 len, const byte* iv) { int ret = 0; @@ -1554,11 +1554,11 @@ int CamelliaSetKey(Camellia* cam, const byte* key, word32 len, const byte* iv) cam->keySz = len * 8; - return CamelliaSetIV(cam, iv); + return wc_CamelliaSetIV(cam, iv); } -int CamelliaSetIV(Camellia* cam, const byte* iv) +int wc_CamelliaSetIV(Camellia* cam, const byte* iv) { if (cam == NULL) return BAD_FUNC_ARG; @@ -1572,19 +1572,19 @@ int CamelliaSetIV(Camellia* cam, const byte* iv) } -void CamelliaEncryptDirect(Camellia* cam, byte* out, const byte* in) +void wc_CamelliaEncryptDirect(Camellia* cam, byte* out, const byte* in) { Camellia_EncryptBlock(cam->keySz, in, cam->key, out); } -void CamelliaDecryptDirect(Camellia* cam, byte* out, const byte* in) +void wc_CamelliaDecryptDirect(Camellia* cam, byte* out, const byte* in) { Camellia_DecryptBlock(cam->keySz, in, cam->key, out); } -void CamelliaCbcEncrypt(Camellia* cam, byte* out, const byte* in, word32 sz) +void wc_CamelliaCbcEncrypt(Camellia* cam, byte* out, const byte* in, word32 sz) { word32 blocks = sz / CAMELLIA_BLOCK_SIZE; @@ -1595,12 +1595,12 @@ void CamelliaCbcEncrypt(Camellia* cam, byte* out, const byte* in, word32 sz) XMEMCPY(out, cam->reg, CAMELLIA_BLOCK_SIZE); out += CAMELLIA_BLOCK_SIZE; - in += CAMELLIA_BLOCK_SIZE; + in += CAMELLIA_BLOCK_SIZE; } } -void CamelliaCbcDecrypt(Camellia* cam, byte* out, const byte* in, word32 sz) +void wc_CamelliaCbcDecrypt(Camellia* cam, byte* out, const byte* in, word32 sz) { word32 blocks = sz / CAMELLIA_BLOCK_SIZE; @@ -1611,7 +1611,7 @@ void CamelliaCbcDecrypt(Camellia* cam, byte* out, const byte* in, word32 sz) XMEMCPY(cam->reg, cam->tmp, CAMELLIA_BLOCK_SIZE); out += CAMELLIA_BLOCK_SIZE; - in += CAMELLIA_BLOCK_SIZE; + in += CAMELLIA_BLOCK_SIZE; } } diff --git a/wolfcrypt/src/dh.c b/wolfcrypt/src/dh.c index f2251f705..ca5bbcaf8 100644 --- a/wolfcrypt/src/dh.c +++ b/wolfcrypt/src/dh.c @@ -89,7 +89,7 @@ static int GeneratePrivate(DhKey* key, RNG* rng, byte* priv, word32* privSz) sz = min(sz, 2 * DiscreteLogWorkFactor(sz * WOLFSSL_BIT_SIZE) / WOLFSSL_BIT_SIZE + 1); - ret = RNG_GenerateBlock(rng, priv, sz); + ret = wc_RNG_GenerateBlock(rng, priv, sz); if (ret != 0) return ret; diff --git a/wolfcrypt/src/dsa.c b/wolfcrypt/src/dsa.c index e7cf5cf85..8f1dfd113 100644 --- a/wolfcrypt/src/dsa.c +++ b/wolfcrypt/src/dsa.c @@ -86,10 +86,10 @@ int wc_DsaSign(const byte* digest, byte* out, DsaKey* key, RNG* rng) int ret, sz; byte buffer[DSA_HALF_SIZE]; - sz = min(sizeof(buffer), mp_unsigned_bin_size(&key->q)); + sz = min(sizeof(buffer), mp_unsigned_bin_size(&key->q)); /* generate k */ - ret = RNG_GenerateBlock(rng, buffer, sz); + ret = wc_RNG_GenerateBlock(rng, buffer, sz); if (ret != 0) return ret; diff --git a/wolfcrypt/src/ecc.c b/wolfcrypt/src/ecc.c index 85a0d71e2..588fa44df 100644 --- a/wolfcrypt/src/ecc.c +++ b/wolfcrypt/src/ecc.c @@ -1523,7 +1523,7 @@ int wc_ecc_make_key_ex(RNG* rng, ecc_key* key, const ecc_set_type* dp) base = NULL; /* make up random string */ - err = RNG_GenerateBlock(rng, buf, keysize); + err = wc_RNG_GenerateBlock(rng, buf, keysize); if (err == 0) buf[0] |= 0x0c; @@ -4130,7 +4130,7 @@ static int ecc_ctx_set_salt(ecEncCtx* ctx, int flags, RNG* rng) saltBuffer = (flags == REQ_RESP_CLIENT) ? ctx->clientSalt : ctx->serverSalt; - return RNG_GenerateBlock(rng, saltBuffer, EXCHANGE_SALT_SZ); + return wc_RNG_GenerateBlock(rng, saltBuffer, EXCHANGE_SALT_SZ); } diff --git a/wolfcrypt/src/pkcs7.c b/wolfcrypt/src/pkcs7.c index bccac5b52..5722391d7 100644 --- a/wolfcrypt/src/pkcs7.c +++ b/wolfcrypt/src/pkcs7.c @@ -372,7 +372,7 @@ int wc_PKCS7_EncodeSignedData(PKCS7* pkcs7, byte* output, word32 outputSz) #endif XMEMSET(esd, 0, sizeof(ESD)); - ret = InitSha(&esd->sha); + ret = wc_InitSha(&esd->sha); if (ret != 0) { #ifdef WOLFSSL_SMALL_STACK XFREE(esd, NULL, DYNAMIC_TYPE_TMP_BUFFER); @@ -382,10 +382,10 @@ int wc_PKCS7_EncodeSignedData(PKCS7* pkcs7, byte* output, word32 outputSz) if (pkcs7->contentSz != 0) { - ShaUpdate(&esd->sha, pkcs7->content, pkcs7->contentSz); + wc_ShaUpdate(&esd->sha, pkcs7->content, pkcs7->contentSz); esd->contentDigest[0] = ASN_OCTET_STRING; esd->contentDigest[1] = SHA_DIGEST_SIZE; - ShaFinal(&esd->sha, &esd->contentDigest[2]); + wc_ShaFinal(&esd->sha, &esd->contentDigest[2]); } esd->innerOctetsSz = SetOctetString(pkcs7->contentSz, esd->innerOctets); @@ -477,7 +477,7 @@ int wc_PKCS7_EncodeSignedData(PKCS7* pkcs7, byte* output, word32 outputSz) attribSetSz = SetSet(flatSignedAttribsSz, attribSet); - ret = InitSha(&esd->sha); + ret = wc_InitSha(&esd->sha); if (ret < 0) { XFREE(flatSignedAttribs, 0, NULL); #ifdef WOLFSSL_SMALL_STACK @@ -485,10 +485,10 @@ int wc_PKCS7_EncodeSignedData(PKCS7* pkcs7, byte* output, word32 outputSz) #endif return ret; } - ShaUpdate(&esd->sha, attribSet, attribSetSz); - ShaUpdate(&esd->sha, flatSignedAttribs, flatSignedAttribsSz); + wc_ShaUpdate(&esd->sha, attribSet, attribSetSz); + wc_ShaUpdate(&esd->sha, flatSignedAttribs, flatSignedAttribsSz); } - ShaFinal(&esd->sha, esd->contentAttribsDigest); + wc_ShaFinal(&esd->sha, esd->contentAttribsDigest); digestStrSz = SetOctetString(SHA_DIGEST_SIZE, digestStr); digestInfoSeqSz = SetSequence(esd->signerDigAlgoIdSz + @@ -530,9 +530,9 @@ int wc_PKCS7_EncodeSignedData(PKCS7* pkcs7, byte* output, word32 outputSz) } #endif - result = InitRsaKey(privKey, NULL); + result = wc_InitRsaKey(privKey, NULL); if (result == 0) - result = RsaPrivateKeyDecode(pkcs7->privateKey, &scratch, privKey, + result = wc_RsaPrivateKeyDecode(pkcs7->privateKey, &scratch, privKey, pkcs7->privateKeySz); if (result < 0) { if (pkcs7->signedAttribsSz != 0) @@ -545,12 +545,12 @@ int wc_PKCS7_EncodeSignedData(PKCS7* pkcs7, byte* output, word32 outputSz) return PUBLIC_KEY_E; } - result = RsaSSL_Sign(digestInfo, digIdx, + result = wc_RsaSSL_Sign(digestInfo, digIdx, esd->encContentDigest, sizeof(esd->encContentDigest), privKey, pkcs7->rng); - FreeRsaKey(privKey); + wc_FreeRsaKey(privKey); #ifdef WOLFSSL_SMALL_STACK XFREE(privKey, NULL, DYNAMIC_TYPE_TMP_BUFFER); @@ -899,15 +899,15 @@ int wc_PKCS7_VerifySignedData(PKCS7* pkcs7, byte* pkiMsg, word32 pkiMsgSz) XMEMSET(digest, 0, digestSz); - ret = InitRsaKey(key, NULL); + ret = wc_InitRsaKey(key, NULL); if (ret != 0) { #ifdef WOLFSSL_SMALL_STACK XFREE(digest, NULL, DYNAMIC_TYPE_TMP_BUFFER); XFREE(key, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return ret; - } - if (RsaPublicKeyDecode(pkcs7->publicKey, &scratch, key, + } + if (wc_RsaPublicKeyDecode(pkcs7->publicKey, &scratch, key, pkcs7->publicKeySz) < 0) { WOLFSSL_MSG("ASN RSA key decode error"); #ifdef WOLFSSL_SMALL_STACK @@ -917,8 +917,8 @@ int wc_PKCS7_VerifySignedData(PKCS7* pkcs7, byte* pkiMsg, word32 pkiMsgSz) return PUBLIC_KEY_E; } - plainSz = RsaSSL_Verify(sig, sigSz, digest, digestSz, key); - FreeRsaKey(key); + plainSz = wc_RsaSSL_Verify(sig, sigSz, digest, digestSz, key); + wc_FreeRsaKey(key); #ifdef WOLFSSL_SMALL_STACK XFREE(digest, NULL, DYNAMIC_TYPE_TMP_BUFFER); @@ -1060,7 +1060,7 @@ WOLFSSL_LOCAL int wc_CreateRecipientInfo(const byte* cert, word32 certSz, #endif /* EncryptedKey */ - ret = InitRsaKey(pubKey, 0); + ret = wc_InitRsaKey(pubKey, 0); if (ret != 0) { FreeDecodedCert(decoded); #ifdef WOLFSSL_SMALL_STACK @@ -1072,10 +1072,10 @@ WOLFSSL_LOCAL int wc_CreateRecipientInfo(const byte* cert, word32 certSz, return ret; } - if (RsaPublicKeyDecode(decoded->publicKey, &idx, pubKey, + if (wc_RsaPublicKeyDecode(decoded->publicKey, &idx, pubKey, decoded->pubKeySize) < 0) { WOLFSSL_MSG("ASN RSA key decode error"); - FreeRsaKey(pubKey); + wc_FreeRsaKey(pubKey); FreeDecodedCert(decoded); #ifdef WOLFSSL_SMALL_STACK XFREE(pubKey, NULL, DYNAMIC_TYPE_TMP_BUFFER); @@ -1086,9 +1086,9 @@ WOLFSSL_LOCAL int wc_CreateRecipientInfo(const byte* cert, word32 certSz, return PUBLIC_KEY_E; } - *keyEncSz = RsaPublicEncrypt(contentKeyPlain, blockKeySz, contentKeyEnc, + *keyEncSz = wc_RsaPublicEncrypt(contentKeyPlain, blockKeySz, contentKeyEnc, MAX_ENCRYPTED_KEY_SZ, pubKey, rng); - FreeRsaKey(pubKey); + wc_FreeRsaKey(pubKey); #ifdef WOLFSSL_SMALL_STACK XFREE(pubKey, NULL, DYNAMIC_TYPE_TMP_BUFFER); @@ -1228,11 +1228,11 @@ int wc_PKCS7_EncodeEnvelopedData(PKCS7* pkcs7, byte* output, word32 outputSz) verSz = SetMyVersion(0, ver, 0); /* generate random content encryption key */ - ret = InitRng(&rng); + ret = wc_InitRng(&rng); if (ret != 0) return ret; - ret = RNG_GenerateBlock(&rng, contentKeyPlain, blockKeySz); + ret = wc_RNG_GenerateBlock(&rng, contentKeyPlain, blockKeySz); if (ret != 0) return ret; @@ -1270,7 +1270,7 @@ int wc_PKCS7_EncodeEnvelopedData(PKCS7* pkcs7, byte* output, word32 outputSz) recipSetSz = SetSet(recipSz, recipSet); /* generate IV for block cipher */ - ret = RNG_GenerateBlock(&rng, tmpIv, DES_BLOCK_SIZE); + ret = wc_RNG_GenerateBlock(&rng, tmpIv, DES_BLOCK_SIZE); if (ret != 0) { #ifdef WOLFSSL_SMALL_STACK XFREE(recip, NULL, DYNAMMIC_TYPE_TMP_BUFFER); @@ -1343,10 +1343,10 @@ int wc_PKCS7_EncodeEnvelopedData(PKCS7* pkcs7, byte* output, word32 outputSz) if (pkcs7->encryptOID == DESb) { Des des; - ret = Des_SetKey(&des, contentKeyPlain, tmpIv, DES_ENCRYPTION); + ret = wc_Des_SetKey(&des, contentKeyPlain, tmpIv, DES_ENCRYPTION); if (ret == 0) - Des_CbcEncrypt(&des, encryptedContent, plain, desOutSz); + wc_Des_CbcEncrypt(&des, encryptedContent, plain, desOutSz); if (ret != 0) { XFREE(encryptedContent, NULL, DYNAMIC_TYPE_TMP_BUFFER); @@ -1361,10 +1361,10 @@ int wc_PKCS7_EncodeEnvelopedData(PKCS7* pkcs7, byte* output, word32 outputSz) else if (pkcs7->encryptOID == DES3b) { Des3 des3; - ret = Des3_SetKey(&des3, contentKeyPlain, tmpIv, DES_ENCRYPTION); + ret = wc_Des3_SetKey(&des3, contentKeyPlain, tmpIv, DES_ENCRYPTION); if (ret == 0) - ret = Des3_CbcEncrypt(&des3, encryptedContent, plain, desOutSz); + ret = wc_Des3_CbcEncrypt(&des3, encryptedContent, plain, desOutSz); if (ret != 0) { XFREE(encryptedContent, NULL, DYNAMIC_TYPE_TMP_BUFFER); @@ -1443,7 +1443,7 @@ int wc_PKCS7_EncodeEnvelopedData(PKCS7* pkcs7, byte* output, word32 outputSz) idx += desOutSz; #if defined(HAVE_HASHDRBG) || defined(NO_RC4) - FreeRng(&rng); + wc_FreeRng(&rng); #endif XMEMSET(contentKeyPlain, 0, MAX_CONTENT_KEY_LEN); @@ -1738,7 +1738,7 @@ WOLFSSL_API int wc_PKCS7_DecodeEnvelopedData(PKCS7* pkcs7, byte* pkiMsg, } #endif - ret = InitRsaKey(privKey, 0); + ret = wc_InitRsaKey(privKey, 0); if (ret != 0) { XFREE(encryptedContent, NULL, DYNAMIC_TYPE_TMP_BUFFER); #ifdef WOLFSSL_SMALL_STACK @@ -1750,7 +1750,7 @@ WOLFSSL_API int wc_PKCS7_DecodeEnvelopedData(PKCS7* pkcs7, byte* pkiMsg, idx = 0; - ret = RsaPrivateKeyDecode(pkcs7->privateKey, &idx, privKey, + ret = wc_RsaPrivateKeyDecode(pkcs7->privateKey, &idx, privKey, pkcs7->privateKeySz); if (ret != 0) { WOLFSSL_MSG("Failed to decode RSA private key"); @@ -1763,9 +1763,9 @@ WOLFSSL_API int wc_PKCS7_DecodeEnvelopedData(PKCS7* pkcs7, byte* pkiMsg, } /* decrypt encryptedKey */ - keySz = RsaPrivateDecryptInline(encryptedKey, encryptedKeySz, + keySz = wc_RsaPrivateDecryptInline(encryptedKey, encryptedKeySz, &decryptedKey, privKey); - FreeRsaKey(privKey); + wc_FreeRsaKey(privKey); #ifdef WOLFSSL_SMALL_STACK XFREE(privKey, NULL, DYNAMIC_TYPE_TMP_BUFFER); @@ -1782,10 +1782,10 @@ WOLFSSL_API int wc_PKCS7_DecodeEnvelopedData(PKCS7* pkcs7, byte* pkiMsg, /* decrypt encryptedContent */ if (encOID == DESb) { Des des; - ret = Des_SetKey(&des, decryptedKey, tmpIv, DES_DECRYPTION); + ret = wc_Des_SetKey(&des, decryptedKey, tmpIv, DES_DECRYPTION); if (ret == 0) - Des_CbcDecrypt(&des, encryptedContent, encryptedContent, + wc_Des_CbcDecrypt(&des, encryptedContent, encryptedContent, encryptedContentSz); if (ret != 0) { @@ -1798,9 +1798,9 @@ WOLFSSL_API int wc_PKCS7_DecodeEnvelopedData(PKCS7* pkcs7, byte* pkiMsg, } else if (encOID == DES3b) { Des3 des; - ret = Des3_SetKey(&des, decryptedKey, tmpIv, DES_DECRYPTION); + ret = wc_Des3_SetKey(&des, decryptedKey, tmpIv, DES_DECRYPTION); if (ret == 0) - ret = Des3_CbcDecrypt(&des, encryptedContent, encryptedContent, + ret = wc_Des3_CbcDecrypt(&des, encryptedContent, encryptedContent, encryptedContentSz); if (ret != 0) { diff --git a/wolfcrypt/src/pwdbased.c b/wolfcrypt/src/pwdbased.c index 6e08d1436..b2596da83 100644 --- a/wolfcrypt/src/pwdbased.c +++ b/wolfcrypt/src/pwdbased.c @@ -29,17 +29,17 @@ #ifdef WOLFSSL_PIC32MZ_HASH -#define InitMd5 InitMd5_sw -#define Md5Update Md5Update_sw -#define Md5Final Md5Final_sw +#define wc_InitMd5 InitMd5_sw +#define wc_Md5Update Md5Update_sw +#define wc_Md5Final Md5Final_sw -#define InitSha InitSha_sw -#define ShaUpdate ShaUpdate_sw -#define ShaFinal ShaFinal_sw +#define wc_InitSha InitSha_sw +#define wc_ShaUpdate ShaUpdate_sw +#define wc_ShaFinal ShaFinal_sw -#define InitSha256 InitSha256_sw -#define Sha256Update Sha256Update_sw -#define Sha256Final Sha256Final_sw +#define wc_InitSha256 InitSha256_sw +#define wc_Sha256Update Sha256Update_sw +#define wc_Sha256Final Sha256Final_sw #endif @@ -87,28 +87,28 @@ int wc_PBKDF1(byte* output, const byte* passwd, int pLen, const byte* salt, return BAD_FUNC_ARG; if (hashType == MD5) { - InitMd5(&md5); - Md5Update(&md5, passwd, pLen); - Md5Update(&md5, salt, sLen); - Md5Final(&md5, buffer); + wc_InitMd5(&md5); + wc_Md5Update(&md5, passwd, pLen); + wc_Md5Update(&md5, salt, sLen); + wc_Md5Final(&md5, buffer); } else { - ret = InitSha(&sha); + ret = wc_InitSha(&sha); if (ret != 0) return ret; - ShaUpdate(&sha, passwd, pLen); - ShaUpdate(&sha, salt, sLen); - ShaFinal(&sha, buffer); + wc_ShaUpdate(&sha, passwd, pLen); + wc_ShaUpdate(&sha, salt, sLen); + wc_ShaFinal(&sha, buffer); } for (i = 1; i < iterations; i++) { if (hashType == MD5) { - Md5Update(&md5, buffer, hLen); - Md5Final(&md5, buffer); + wc_Md5Update(&md5, buffer, hLen); + wc_Md5Final(&md5, buffer); } else { - ShaUpdate(&sha, buffer, hLen); - ShaFinal(&sha, buffer); + wc_ShaUpdate(&sha, buffer, hLen); + wc_ShaFinal(&sha, buffer); } } XMEMCPY(output, buffer, kLen); @@ -155,13 +155,13 @@ int wc_PBKDF2(byte* output, const byte* passwd, int pLen, const byte* salt, return MEMORY_E; #endif - ret = HmacSetKey(&hmac, hashType, passwd, pLen); + ret = wc_HmacSetKey(&hmac, hashType, passwd, pLen); if (ret == 0) { while (kLen) { int currentLen; - ret = HmacUpdate(&hmac, salt, sLen); + ret = wc_HmacUpdate(&hmac, salt, sLen); if (ret != 0) break; @@ -169,7 +169,7 @@ int wc_PBKDF2(byte* output, const byte* passwd, int pLen, const byte* salt, for (j = 0; j < 4; j++) { byte b = (byte)(i >> ((3-j) * 8)); - ret = HmacUpdate(&hmac, &b, 1); + ret = wc_HmacUpdate(&hmac, &b, 1); if (ret != 0) break; } @@ -178,7 +178,7 @@ int wc_PBKDF2(byte* output, const byte* passwd, int pLen, const byte* salt, if (ret != 0) break; - ret = HmacFinal(&hmac, buffer); + ret = wc_HmacFinal(&hmac, buffer); if (ret != 0) break; @@ -186,10 +186,10 @@ int wc_PBKDF2(byte* output, const byte* passwd, int pLen, const byte* salt, XMEMCPY(output, buffer, currentLen); for (j = 1; j < iterations; j++) { - ret = HmacUpdate(&hmac, buffer, hLen); + ret = wc_HmacUpdate(&hmac, buffer, hLen); if (ret != 0) break; - ret = HmacFinal(&hmac, buffer); + ret = wc_HmacFinal(&hmac, buffer); if (ret != 0) break; xorbuf(output, buffer, currentLen); @@ -323,51 +323,51 @@ int wc_PKCS12_PBKDF(byte* output, const byte* passwd, int passLen,const byte* sa if (hashType == MD5) { Md5 md5; - InitMd5(&md5); - Md5Update(&md5, buffer, totalLen); - Md5Final(&md5, Ai); + wc_InitMd5(&md5); + wc_Md5Update(&md5, buffer, totalLen); + wc_Md5Final(&md5, Ai); for (i = 1; i < iterations; i++) { - Md5Update(&md5, Ai, u); - Md5Final(&md5, Ai); + wc_Md5Update(&md5, Ai, u); + wc_Md5Final(&md5, Ai); } } else if (hashType == SHA) { Sha sha; - ret = InitSha(&sha); + ret = wc_InitSha(&sha); if (ret != 0) break; - ShaUpdate(&sha, buffer, totalLen); - ShaFinal(&sha, Ai); + wc_ShaUpdate(&sha, buffer, totalLen); + wc_ShaFinal(&sha, Ai); for (i = 1; i < iterations; i++) { - ShaUpdate(&sha, Ai, u); - ShaFinal(&sha, Ai); + wc_ShaUpdate(&sha, Ai, u); + wc_ShaFinal(&sha, Ai); } } #ifndef NO_SHA256 else if (hashType == SHA256) { Sha256 sha256; - ret = InitSha256(&sha256); + ret = wc_InitSha256(&sha256); if (ret != 0) break; - ret = Sha256Update(&sha256, buffer, totalLen); + ret = wc_Sha256Update(&sha256, buffer, totalLen); if (ret != 0) break; - ret = Sha256Final(&sha256, Ai); + ret = wc_Sha256Final(&sha256, Ai); if (ret != 0) break; for (i = 1; i < iterations; i++) { - ret = Sha256Update(&sha256, Ai, u); + ret = wc_Sha256Update(&sha256, Ai, u); if (ret != 0) break; - ret = Sha256Final(&sha256, Ai); + ret = wc_Sha256Final(&sha256, Ai); if (ret != 0) break; } @@ -377,24 +377,24 @@ int wc_PKCS12_PBKDF(byte* output, const byte* passwd, int passLen,const byte* sa else if (hashType == SHA512) { Sha512 sha512; - ret = InitSha512(&sha512); + ret = wc_InitSha512(&sha512); if (ret != 0) break; - ret = Sha512Update(&sha512, buffer, totalLen); + ret = wc_Sha512Update(&sha512, buffer, totalLen); if (ret != 0) break; - ret = Sha512Final(&sha512, Ai); + ret = wc_Sha512Final(&sha512, Ai); if (ret != 0) break; for (i = 1; i < iterations; i++) { - ret = Sha512Update(&sha512, Ai, u); + ret = wc_Sha512Update(&sha512, Ai, u); if (ret != 0) break; - ret = Sha512Final(&sha512, Ai); + ret = wc_Sha512Final(&sha512, Ai); if (ret != 0) break; } diff --git a/wolfcrypt/test/test.c b/wolfcrypt/test/test.c index 36a25d156..e5be25ed4 100644 --- a/wolfcrypt/test/test.c +++ b/wolfcrypt/test/test.c @@ -1040,7 +1040,7 @@ int sha256_test(void) #endif -#ifdef CYASSL_SHA512 +#ifdef WOLFSSL_SHA512 int sha512_test(void) { Sha512 sha; @@ -1095,7 +1095,7 @@ int sha512_test(void) #endif -#ifdef CYASSL_SHA384 +#ifdef WOLFSSL_SHA384 int sha384_test(void) { Sha384 sha; @@ -1541,7 +1541,7 @@ int hmac_sha384_test(void) #endif -#if !defined(NO_HMAC) && defined(CYASSL_SHA512) +#if !defined(NO_HMAC) && defined(WOLFSSL_SHA512) int hmac_sha512_test(void) { Hmac hmac; @@ -3352,7 +3352,7 @@ int rsa_test(void) if (ret != 0) { free(derCert); free(pem); - FreeRsaKey(&caKey); + wc_FreeRsaKey(&caKey); return -413; } @@ -3370,7 +3370,7 @@ int rsa_test(void) if (ret < 0) { free(derCert); free(pem); - FreeRsaKey(&caKey); + wc_FreeRsaKey(&caKey); return -405; } @@ -3378,7 +3378,7 @@ int rsa_test(void) if (certSz < 0) { free(derCert); free(pem); - FreeRsaKey(&caKey); + wc_FreeRsaKey(&caKey); return -407; } @@ -3387,7 +3387,7 @@ int rsa_test(void) if (certSz < 0) { free(derCert); free(pem); - FreeRsaKey(&caKey); + wc_FreeRsaKey(&caKey); return -408; } @@ -3398,7 +3398,7 @@ int rsa_test(void) if (ret != 0) { free(derCert); free(pem); - FreeRsaKey(&caKey); + wc_FreeRsaKey(&caKey); return -409; } FreeDecodedCert(&decode); @@ -3408,7 +3408,7 @@ int rsa_test(void) if (!derFile) { free(derCert); free(pem); - FreeRsaKey(&caKey); + wc_FreeRsaKey(&caKey); return -410; } ret = (int)fwrite(derCert, 1, certSz, derFile); @@ -3416,7 +3416,7 @@ int rsa_test(void) if (ret != certSz) { free(derCert); free(pem); - FreeRsaKey(&caKey); + wc_FreeRsaKey(&caKey); return -416; } @@ -3424,7 +3424,7 @@ int rsa_test(void) if (pemSz < 0) { free(derCert); free(pem); - FreeRsaKey(&caKey); + wc_FreeRsaKey(&caKey); return -411; } @@ -3432,20 +3432,20 @@ int rsa_test(void) if (!pemFile) { free(derCert); free(pem); - FreeRsaKey(&caKey); + wc_FreeRsaKey(&caKey); return -412; } ret = (int)fwrite(pem, 1, pemSz, pemFile); if (ret != pemSz) { free(derCert); free(pem); - FreeRsaKey(&caKey); + wc_FreeRsaKey(&caKey); return -415; } fclose(pemFile); free(pem); free(derCert); - FreeRsaKey(&caKey); + wc_FreeRsaKey(&caKey); } #ifdef HAVE_ECC /* ECC CA style */ @@ -3663,7 +3663,7 @@ int rsa_test(void) bytes = fread(tmp, 1, FOURK_BUF, caFile); fclose(caFile); - ret = InitRsaKey(&caKey, 0); + ret = wc_InitRsaKey(&caKey, 0); if (ret != 0) { free(derCert); free(pem); @@ -3690,7 +3690,7 @@ int rsa_test(void) if (ret < 0) { free(derCert); free(pem); - FreeRsaKey(&caKey); + wc_FreeRsaKey(&caKey); return -455; } @@ -3699,13 +3699,13 @@ int rsa_test(void) if (certSz < 0) { free(derCert); free(pem); - FreeRsaKey(&caKey); + wc_FreeRsaKey(&caKey); return -456; } certSz = wc_SignCert(myCert.bodySz, myCert.sigType, derCert, FOURK_BUF, &caKey, NULL, &rng); - FreeRsaKey(&caKey); + wc_FreeRsaKey(&caKey); if (certSz < 0) { free(derCert); free(pem); @@ -4477,7 +4477,7 @@ int ecc_test(void) int i, verify, ret; ecc_key userA, userB, pubKey; - ret = InitRng(&rng); + ret = wc_InitRng(&rng); if (ret != 0) return -1001; diff --git a/wolfssl/test.h b/wolfssl/test.h index 8a06c7054..d05aa7b5d 100644 --- a/wolfssl/test.h +++ b/wolfssl/test.h @@ -1406,17 +1406,17 @@ static INLINE int myMacEncryptCb(WOLFSSL* ssl, unsigned char* macOut, /* hmac, not needed if aead mode */ wolfSSL_SetTlsHmacInner(ssl, myInner, macInSz, macContent, macVerify); - ret = HmacSetKey(&hmac, wolfSSL_GetHmacType(ssl), + ret = wc_HmacSetKey(&hmac, wolfSSL_GetHmacType(ssl), wolfSSL_GetMacSecret(ssl, macVerify), wolfSSL_GetHmacSize(ssl)); if (ret != 0) return ret; - ret = HmacUpdate(&hmac, myInner, sizeof(myInner)); + ret = wc_HmacUpdate(&hmac, myInner, sizeof(myInner)); if (ret != 0) return ret; - ret = HmacUpdate(&hmac, macIn, macInSz); + ret = wc_HmacUpdate(&hmac, macIn, macInSz); if (ret != 0) return ret; - ret = HmacFinal(&hmac, macOut); + ret = wc_HmacFinal(&hmac, macOut); if (ret != 0) return ret; @@ -1436,7 +1436,7 @@ static INLINE int myMacEncryptCb(WOLFSSL* ssl, unsigned char* macOut, iv = wolfSSL_GetServerWriteIV(ssl); } - ret = AesSetKey(&encCtx->aes, key, keyLen, iv, AES_ENCRYPTION); + ret = wc_AesSetKey(&encCtx->aes, key, keyLen, iv, AES_ENCRYPTION); if (ret != 0) { printf("AesSetKey failed in myMacEncryptCb\n"); return ret; @@ -1445,7 +1445,7 @@ static INLINE int myMacEncryptCb(WOLFSSL* ssl, unsigned char* macOut, } /* encrypt */ - return AesCbcEncrypt(&encCtx->aes, encOut, encIn, encSz); + return wc_AesCbcEncrypt(&encCtx->aes, encOut, encIn, encSz); } @@ -1493,7 +1493,7 @@ static INLINE int myDecryptVerifyCb(WOLFSSL* ssl, iv = wolfSSL_GetServerWriteIV(ssl); } - ret = AesSetKey(&decCtx->aes, key, keyLen, iv, AES_DECRYPTION); + ret = wc_AesSetKey(&decCtx->aes, key, keyLen, iv, AES_DECRYPTION); if (ret != 0) { printf("AesSetKey failed in myDecryptVerifyCb\n"); return ret; @@ -1502,7 +1502,7 @@ static INLINE int myDecryptVerifyCb(WOLFSSL* ssl, } /* decrypt */ - ret = AesCbcDecrypt(&decCtx->aes, decOut, decIn, decSz); + ret = wc_AesCbcDecrypt(&decCtx->aes, decOut, decIn, decSz); if (wolfSSL_GetCipherType(ssl) == WOLFSSL_AEAD_TYPE) { *padSz = wolfSSL_GetAeadMacSize(ssl); @@ -1521,17 +1521,17 @@ static INLINE int myDecryptVerifyCb(WOLFSSL* ssl, wolfSSL_SetTlsHmacInner(ssl, myInner, macInSz, macContent, macVerify); - ret = HmacSetKey(&hmac, wolfSSL_GetHmacType(ssl), + ret = wc_HmacSetKey(&hmac, wolfSSL_GetHmacType(ssl), wolfSSL_GetMacSecret(ssl, macVerify), digestSz); if (ret != 0) return ret; - ret = HmacUpdate(&hmac, myInner, sizeof(myInner)); + ret = wc_HmacUpdate(&hmac, myInner, sizeof(myInner)); if (ret != 0) return ret; - ret = HmacUpdate(&hmac, decOut + ivExtra, macInSz); + ret = wc_HmacUpdate(&hmac, decOut + ivExtra, macInSz); if (ret != 0) return ret; - ret = HmacFinal(&hmac, verify); + ret = wc_HmacFinal(&hmac, verify); if (ret != 0) return ret; @@ -1597,7 +1597,7 @@ static INLINE int myEccSign(WOLFSSL* ssl, const byte* in, word32 inSz, (void)ssl; (void)ctx; - ret = InitRng(&rng); + ret = wc_InitRng(&rng); if (ret != 0) return ret; @@ -1647,20 +1647,20 @@ static INLINE int myRsaSign(WOLFSSL* ssl, const byte* in, word32 inSz, (void)ssl; (void)ctx; - ret = InitRng(&rng); + ret = wc_InitRng(&rng); if (ret != 0) return ret; - InitRsaKey(&myKey, NULL); + wc_InitRsaKey(&myKey, NULL); - ret = RsaPrivateKeyDecode(key, &idx, &myKey, keySz); + ret = wc_RsaPrivateKeyDecode(key, &idx, &myKey, keySz); if (ret == 0) - ret = RsaSSL_Sign(in, inSz, out, *outSz, &myKey, &rng); + ret = wc_RsaSSL_Sign(in, inSz, out, *outSz, &myKey, &rng); if (ret > 0) { /* save and convert to 0 success */ *outSz = ret; ret = 0; } - FreeRsaKey(&myKey); + wc_FreeRsaKey(&myKey); return ret; } @@ -1678,12 +1678,12 @@ static INLINE int myRsaVerify(WOLFSSL* ssl, byte* sig, word32 sigSz, (void)ssl; (void)ctx; - InitRsaKey(&myKey, NULL); - - ret = RsaPublicKeyDecode(key, &idx, &myKey, keySz); + wc_InitRsaKey(&myKey, NULL); + + ret = wc_RsaPublicKeyDecode(key, &idx, &myKey, keySz); if (ret == 0) - ret = RsaSSL_VerifyInline(sig, sigSz, out, &myKey); - FreeRsaKey(&myKey); + ret = wc_RsaSSL_VerifyInline(sig, sigSz, out, &myKey); + wc_FreeRsaKey(&myKey); return ret; } @@ -1701,21 +1701,21 @@ static INLINE int myRsaEnc(WOLFSSL* ssl, const byte* in, word32 inSz, (void)ssl; (void)ctx; - ret = InitRng(&rng); + ret = wc_InitRng(&rng); if (ret != 0) return ret; - InitRsaKey(&myKey, NULL); + wc_InitRsaKey(&myKey, NULL); - ret = RsaPublicKeyDecode(key, &idx, &myKey, keySz); + ret = wc_RsaPublicKeyDecode(key, &idx, &myKey, keySz); if (ret == 0) { - ret = RsaPublicEncrypt(in, inSz, out, *outSz, &myKey, &rng); + ret = wc_RsaPublicEncrypt(in, inSz, out, *outSz, &myKey, &rng); if (ret > 0) { *outSz = ret; ret = 0; /* reset to success */ } } - FreeRsaKey(&myKey); + wc_FreeRsaKey(&myKey); return ret; } @@ -1731,13 +1731,13 @@ static INLINE int myRsaDec(WOLFSSL* ssl, byte* in, word32 inSz, (void)ssl; (void)ctx; - InitRsaKey(&myKey, NULL); - - ret = RsaPrivateKeyDecode(key, &idx, &myKey, keySz); + wc_InitRsaKey(&myKey, NULL); + + ret = wc_RsaPrivateKeyDecode(key, &idx, &myKey, keySz); if (ret == 0) { - ret = RsaPrivateDecryptInline(in, inSz, out, &myKey); + ret = wc_RsaPrivateDecryptInline(in, inSz, out, &myKey); } - FreeRsaKey(&myKey); + wc_FreeRsaKey(&myKey); return ret; } diff --git a/wolfssl/wolfcrypt/asn.h b/wolfssl/wolfcrypt/asn.h index c61ff7b5f..9b04d4a28 100644 --- a/wolfssl/wolfcrypt/asn.h +++ b/wolfssl/wolfcrypt/asn.h @@ -555,9 +555,9 @@ enum cert_enums { #ifndef WOLFSSL_PEMCERT_TODER_DEFINED #ifndef NO_FILESYSTEM -/* forward from CyaSSL */ +/* forward from wolfSSL */ WOLFSSL_API -int CyaSSL_PemCertToDer(const char* fileName, unsigned char* derBuf, int derSz); +int wolfSSL_PemCertToDer(const char* fileName, unsigned char* derBuf, int derSz); #define WOLFSSL_PEMCERT_TODER_DEFINED #endif #endif diff --git a/wolfssl/wolfcrypt/pwdbased.h b/wolfssl/wolfcrypt/pwdbased.h index 505544a6e..bda41409c 100644 --- a/wolfssl/wolfcrypt/pwdbased.h +++ b/wolfssl/wolfcrypt/pwdbased.h @@ -25,10 +25,9 @@ #ifndef WOLF_CRYPT_PWDBASED_H #define WOLF_CRYPT_PWDBASED_H -#include - -/* included for fips @wc_fips */ -#include +#include +#include /* for hash type */ +#include #ifdef __cplusplus extern "C" { diff --git a/wolfssl/wolfcrypt/sha512.h b/wolfssl/wolfcrypt/sha512.h index c8ad700a1..e05bce546 100644 --- a/wolfssl/wolfcrypt/sha512.h +++ b/wolfssl/wolfcrypt/sha512.h @@ -19,14 +19,6 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -/* check for old macro */ -#if defined(CYASSL_SHA512) && !defined(WOLFSSL_SHA512) - #define WOLFSSL_SHA512 -#endif -#if defined(CYASSL_SHA384) && !defined(WOLFSSL_SHA384) - #define WOLFSSL_SHA384 -#endif - #ifdef WOLFSSL_SHA512 #ifndef WOLF_CRYPT_SHA512_H @@ -35,13 +27,6 @@ #include /* since using old code turn on old macros @wc_fips */ -#if !defined(CYASSL_SHA512) - #define CYASSL_SHA512 -#endif -#if !defined(CYASSL_SHA384) && defined(WOLFSSL_SHA384) - #define CYASSL_SHA384 -#endif - /* for fips */ #ifdef HAVE_FIPS #include