Skip to content

Commit

Permalink
WOLFSSL_DEBUG_TRACE_ERROR_CODES: restore several initializations, one…
Browse files Browse the repository at this point in the history
… because needed (in wolfSSL_UseSecureRenegotiation()), the rest in an abundance of caution, and rearrange wolfSSL_CryptHwMutexInit() and wolfSSL_CryptHwMutexUnLock() in a similar abundance of caution.
  • Loading branch information
douzzer committed Jun 10, 2024
1 parent b3e8f0a commit 1b907d0
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/internal.c
Original file line number Diff line number Diff line change
Expand Up @@ -12549,7 +12549,7 @@ int CheckForAltNames(DecodedCert* dCert, const char* domain, word32 domainLen,
int CheckHostName(DecodedCert* dCert, const char *domainName, size_t domainNameLen)
{
int checkCN;
int ret;
int ret = WC_NO_ERR_TRACE(DOMAIN_NAME_MISMATCH);

if (CheckForAltNames(dCert, domainName, (word32)domainNameLen,
&checkCN) != 1) {
Expand Down
2 changes: 1 addition & 1 deletion src/ssl.c
Original file line number Diff line number Diff line change
Expand Up @@ -3532,7 +3532,7 @@ int wolfSSL_ALPN_FreePeerProtocol(WOLFSSL* ssl, char **list)
/* user is forcing ability to use secure renegotiation, we discourage it */
int wolfSSL_UseSecureRenegotiation(WOLFSSL* ssl)
{
int ret;
int ret = WC_NO_ERR_TRACE(BAD_FUNC_ARG);
#if defined(NO_TLS)
(void)ssl;
#else
Expand Down
4 changes: 2 additions & 2 deletions src/tls.c
Original file line number Diff line number Diff line change
Expand Up @@ -883,7 +883,7 @@ static int Hmac_HashFinalRaw(Hmac* hmac, unsigned char* hash)
*/
static int Hmac_OuterHash(Hmac* hmac, unsigned char* mac)
{
int ret;
int ret = WC_NO_ERR_TRACE(BAD_FUNC_ARG);
wc_HashAlg hash;
enum wc_HashType hashType = (enum wc_HashType)hmac->macType;
int digestSz = wc_HashGetDigestSize(hashType);
Expand Down Expand Up @@ -9745,7 +9745,7 @@ int TLSX_KeyShare_Choose(const WOLFSSL *ssl, TLSX* extensions,

if (extension && extension->resp == 1) {
/* Outside of the async case this path should not be taken. */
int ret;
int ret = WC_NO_ERR_TRACE(INCOMPLETE_DATA);
#ifdef WOLFSSL_ASYNC_CRYPT
/* in async case make sure key generation is finalized */
KeyShareEntry* serverKSE = (KeyShareEntry*)extension->data;
Expand Down
10 changes: 5 additions & 5 deletions wolfcrypt/src/sakke.c
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ static int sakke_load_base_point(SakkeKey* key)
static int sakke_mulmod_base(SakkeKey* key, const mp_int* n, ecc_point* res,
int map)
{
int err;
int err = WC_NO_ERR_TRACE(NOT_COMPILED_IN);

#ifdef WOLFSSL_SP_1024
if ((key->ecc.idx != ECC_CUSTOM_IDX) &&
Expand Down Expand Up @@ -357,7 +357,7 @@ static int sakke_mulmod_base(SakkeKey* key, const mp_int* n, ecc_point* res,
static int sakke_mulmod_base_add(SakkeKey* key, const mp_int* n,
const ecc_point* a, ecc_point* res, int map)
{
int err;
int err = WC_NO_ERR_TRACE(NOT_COMPILED_IN);

#ifdef WOLFSSL_SP_1024
if ((key->ecc.idx != ECC_CUSTOM_IDX) &&
Expand Down Expand Up @@ -448,7 +448,7 @@ static int sakke_mulmod_base_add(SakkeKey* key, const mp_int* n, ecc_point* a,
static int sakke_mulmod_point(SakkeKey* key, const mp_int* n,
const ecc_point* p, byte* table, ecc_point* res, int map)
{
int err;
int err = WC_NO_ERR_TRACE(NOT_COMPILED_IN);

#ifdef WOLFSSL_SP_1024
if ((key->ecc.idx != ECC_CUSTOM_IDX) &&
Expand Down Expand Up @@ -1363,7 +1363,7 @@ int wc_GenerateSakkeRskTable(const SakkeKey* key, const ecc_point* rsk,
static int sakke_pairing(const SakkeKey* key, const ecc_point* p,
const ecc_point* q, mp_int* r, const byte* table, word32 len)
{
int err;
int err = WC_NO_ERR_TRACE(NOT_COMPILED_IN);

#ifdef WOLFSSL_SP_1024
if ((key->ecc.idx != ECC_CUSTOM_IDX) &&
Expand Down Expand Up @@ -2539,7 +2539,7 @@ int wc_GetSakkeAuthSize(SakkeKey* key, word16* authSz)
static int sakke_modexp(const SakkeKey* key, const mp_int* b, mp_int* e,
mp_int* r)
{
int err;
int err = WC_NO_ERR_TRACE(NOT_COMPILED_IN);

#ifdef WOLFSSL_SP_1024
if ((key->ecc.idx != ECC_CUSTOM_IDX) &&
Expand Down
6 changes: 2 additions & 4 deletions wolfcrypt/src/wc_port.c
Original file line number Diff line number Diff line change
Expand Up @@ -1303,9 +1303,8 @@ int wolfSSL_CryptHwMutexInit(void)
}
int wolfSSL_CryptHwMutexLock(void)
{
int ret;
/* Make sure HW Mutex has been initialized */
ret = wolfSSL_CryptHwMutexInit();
int ret = wolfSSL_CryptHwMutexInit();
if (ret == 0) {
ret = wc_LockMutex(&wcCryptHwMutex);
}
Expand Down Expand Up @@ -1700,9 +1699,8 @@ int wolfSSL_CryptHwMutexUnLock(void)

int maxq_CryptHwMutexTryLock()
{
int ret;
/* Make sure HW Mutex has been initialized */
ret = wolfSSL_CryptHwMutexInit();
int ret = wolfSSL_CryptHwMutexInit();
if (ret == 0) {
ret = maxq_LockMutex(&wcCryptHwMutex, 1);
}
Expand Down
4 changes: 2 additions & 2 deletions wolfcrypt/src/wc_xmss.c
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ static const wc_XmssString wc_xmss_alg[] = {
static int wc_xmss_str_to_params(const char *s, word32* oid,
const XmssParams** params)
{
int ret;
int ret = WC_NO_ERR_TRACE(NOT_COMPILED_IN);
#if WOLFSSL_XMSS_MIN_HEIGHT <= 20
unsigned int i;

Expand Down Expand Up @@ -614,7 +614,7 @@ static const wc_XmssString wc_xmssmt_alg[] = {
static int wc_xmssmt_str_to_params(const char *s, word32* oid,
const XmssParams** params)
{
int ret;
int ret = WC_NO_ERR_TRACE(NOT_COMPILED_IN);
#if WOLFSSL_XMSS_MAX_HEIGHT >= 20
unsigned int i;

Expand Down

0 comments on commit 1b907d0

Please sign in to comment.