Merge pull request #5341 from dgarske/various_20220708

Various fixes and cleanups
This commit is contained in:
JacobBarthelmeh
2022-07-08 13:56:51 -06:00
committed by GitHub
5 changed files with 33 additions and 20 deletions

View File

@@ -700,7 +700,9 @@
* wrapper around macros until they are changed in cyassl code * 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 */ #ifdef NO_CYASSL_ALLOC_ALIGN
#define NO_WOLFSSL_ALLOC_ALIGN NO_CYASSL_ALLOC_ALIGN
#endif
/* examples/client/client.h */ /* examples/client/client.h */

View File

@@ -10375,7 +10375,7 @@ WOLFSSL_ECDSA_SIG *wolfSSL_ECDSA_do_sign(const unsigned char *d, int dlen,
} }
} }
else { else {
WOLFSSL_MSG("wc_ecc_sign_hash_ex failed"); WOLFSSL_MSG("wc_ecc_sign_hash failed");
} }
} }

View File

@@ -13548,32 +13548,43 @@ ClientSession* AddSessionToClientCache(int side, int row, int idx, byte* serverI
clientRow = HashSession(sessionID, clientRow = HashSession(sessionID,
ID_LEN, &error) % CLIENT_SESSION_ROWS; ID_LEN, &error) % CLIENT_SESSION_ROWS;
} }
else else {
error = -1; error = -1;
}
if (error == 0 && wc_LockMutex(&clisession_mutex) == 0) { if (error == 0 && wc_LockMutex(&clisession_mutex) == 0) {
clientIdx = ClientCache[clientRow].nextIdx++; clientIdx = ClientCache[clientRow].nextIdx;
ClientCache[clientRow].Clients[clientIdx].serverRow = if (clientIdx < CLIENT_SESSIONS_PER_ROW) {
(word16)row; ClientCache[clientRow].Clients[clientIdx].serverRow =
ClientCache[clientRow].Clients[clientIdx].serverIdx = (word16)row;
(word16)idx; ClientCache[clientRow].Clients[clientIdx].serverIdx =
if (sessionID != NULL) { (word16)idx;
sessionIDHash = HashSession(sessionID, ID_LEN, &error); if (sessionID != NULL) {
if (error == 0) { sessionIDHash = HashSession(sessionID, ID_LEN, &error);
ClientCache[clientRow].Clients[clientIdx].sessionIDHash if (error == 0) {
= sessionIDHash; ClientCache[clientRow].Clients[clientIdx].sessionIDHash
= sessionIDHash;
}
} }
} }
else {
error = -1;
ClientCache[clientRow].nextIdx = 0; /* reset index as saftey */
WOLFSSL_MSG("Invalid client cache index! "
"Possible corrupted memory");
}
if (error == 0) { if (error == 0) {
WOLFSSL_MSG("Adding client cache entry"); WOLFSSL_MSG("Adding client cache entry");
if (ClientCache[clientRow].totalCount < CLIENT_SESSIONS_PER_ROW) if (ClientCache[clientRow].totalCount < CLIENT_SESSIONS_PER_ROW)
ClientCache[clientRow].totalCount++; ClientCache[clientRow].totalCount++;
ClientCache[clientRow].nextIdx++;
ClientCache[clientRow].nextIdx %= CLIENT_SESSIONS_PER_ROW; ClientCache[clientRow].nextIdx %= CLIENT_SESSIONS_PER_ROW;
} }
wc_UnLockMutex(&clisession_mutex); wc_UnLockMutex(&clisession_mutex);
} }
else { else {
WOLFSSL_MSG("Hash session failed"); WOLFSSL_MSG("Hash session or lock failed");
error = -1;
} }
} }
else { else {

View File

@@ -4308,8 +4308,6 @@ static int wc_ecc_shared_secret_gen_sync(ecc_key* private_key, ecc_point* point,
#endif #endif
#endif #endif
WOLFSSL_ENTER("wc_ecc_shared_secret_gen_sync");
#ifdef HAVE_ECC_CDH #ifdef HAVE_ECC_CDH
/* if cofactor flag has been set */ /* if cofactor flag has been set */
if (private_key->flags & WC_ECC_FLAG_COFACTOR) { if (private_key->flags & WC_ECC_FLAG_COFACTOR) {
@@ -4464,8 +4462,6 @@ static int wc_ecc_shared_secret_gen_sync(ecc_key* private_key, ecc_point* point,
#endif #endif
#endif #endif
WOLFSSL_LEAVE("wc_ecc_shared_secret_gen_sync", err);
return err; return err;
} }
@@ -4650,8 +4646,6 @@ int wc_ecc_shared_secret_ex(ecc_key* private_key, ecc_point* point,
RESTORE_VECTOR_REGISTERS(); RESTORE_VECTOR_REGISTERS();
WOLFSSL_LEAVE("wc_ecc_shared_secret_ex", err);
/* if async pending then return and skip done cleanup below */ /* if async pending then return and skip done cleanup below */
if (err == WC_PENDING_E) { if (err == WC_PENDING_E) {
private_key->state++; private_key->state++;

View File

@@ -57,6 +57,7 @@
#ifdef WOLFSSL_KCAPI_HMAC #ifdef WOLFSSL_KCAPI_HMAC
#include <wolfssl/wolfcrypt/port/kcapi/kcapi_hmac.h> #include <wolfssl/wolfcrypt/port/kcapi/kcapi_hmac.h>
/* map the _Software calls used by kcapi_hmac.c */
#define wc_HmacSetKey wc_HmacSetKey_Software #define wc_HmacSetKey wc_HmacSetKey_Software
#define wc_HmacUpdate wc_HmacUpdate_Software #define wc_HmacUpdate wc_HmacUpdate_Software
#define wc_HmacFinal wc_HmacFinal_Software #define wc_HmacFinal wc_HmacFinal_Software
@@ -994,6 +995,11 @@ int wc_HmacFinal(Hmac* hmac, byte* hash)
#ifdef WOLFSSL_KCAPI_HMAC #ifdef WOLFSSL_KCAPI_HMAC
/* implemented in wolfcrypt/src/port/kcapi/kcapi_hmac.c */ /* implemented in wolfcrypt/src/port/kcapi/kcapi_hmac.c */
/* unmap the _Software calls used by kcapi_hmac.c */
#undef wc_HmacSetKey
#undef wc_HmacUpdate
#undef wc_HmacFinal
#else #else
/* Initialize Hmac for use with async device */ /* Initialize Hmac for use with async device */
int wc_HmacInit(Hmac* hmac, void* heap, int devId) int wc_HmacInit(Hmac* hmac, void* heap, int devId)