Skip to content

Commit ea4c3db

Browse files
authored
Merge pull request #105 from billphipps/client_crypto_fixups
Fix a few compile errors due to config
2 parents 6c305a8 + 0d8cc01 commit ea4c3db

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

src/wh_client_crypto.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,7 @@ static int _getCryptoResponse(uint8_t* respBuf, uint16_t type,
118118
/* Helper function to prepare a crypto request buffer with generic header */
119119
static uint8_t* _createCryptoRequest(uint8_t* reqBuf, uint16_t type)
120120
{
121-
whMessageCrypto_GenericRequestHeader* header =
122-
(whMessageCrypto_GenericRequestHeader*)reqBuf;
123-
header->algoType = type;
124-
header->algoSubType = WH_MESSAGE_CRYPTO_ALGO_SUBTYPE_NONE;
125-
return reqBuf + sizeof(whMessageCrypto_GenericRequestHeader);
121+
return _createCryptoRequestWithSubtype(reqBuf, type, WH_MESSAGE_CRYPTO_ALGO_SUBTYPE_NONE);
126122
}
127123

128124
/* Helper function to prepare a crypto request buffer with generic header and
@@ -2549,9 +2545,11 @@ int wh_Client_Sha256(whClientContext* ctx, wc_Sha256* sha256, const uint8_t* in,
25492545

25502546
/* reset the state of the sha context (without blowing away devId) */
25512547
sha256->buffLen = 0;
2552-
sha256->flags = 0;
25532548
sha256->hiLen = 0;
25542549
sha256->loLen = 0;
2550+
#ifdef WOLFSSL_HASH_FLAGS
2551+
sha256->flags = 0;
2552+
#endif
25552553
memset(sha256->digest, 0, sizeof(sha256->digest));
25562554
}
25572555

src/wh_server_keystore.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -707,14 +707,19 @@ int wh_Server_HandleKeyRequest(whServerContext* server, uint16_t magic,
707707
ret = WH_ERROR_OK;
708708

709709
if (ret == WH_ERROR_OK) {
710-
resp.len = keySz;
710+
/* Only provide key output if no error */
711+
if (resp.rc == WH_ERROR_OK) {
712+
resp.len = keySz;
713+
} else {
714+
resp.len = 0;
715+
}
711716
memcpy(resp.label, meta->label, sizeof(meta->label));
712717

713718
(void)wh_MessageKeystore_TranslateExportResponse(
714719
magic, &resp,
715720
(whMessageKeystore_ExportResponse*)resp_packet);
716721

717-
*out_resp_size = sizeof(resp) + keySz;
722+
*out_resp_size = sizeof(resp) + resp.len;
718723
}
719724
} break;
720725

0 commit comments

Comments
 (0)