Skip to content

Commit

Permalink
Merge pull request #81 from bigbrett/eccVerifyBugfix
Browse files Browse the repository at this point in the history
Fix ECC verify bug
  • Loading branch information
billphipps authored Oct 25, 2024
2 parents f8e2b9c + 0cce370 commit 3ed835b
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/wh_server_crypto.c
Original file line number Diff line number Diff line change
Expand Up @@ -697,7 +697,7 @@ static int _HandleEccVerify(whServerContext* ctx, whPacket* packet,
byte* res_pub = (uint8_t*)(res + 1);
word32 max_size = (word32)(WOLFHSM_CFG_COMM_DATA_LEN -
(res_pub - (uint8_t*)packet));
uint16_t pub_size = 0;
uint32_t pub_size = 0;
int result;

/* init public key */
Expand All @@ -712,11 +712,14 @@ static int _HandleEccVerify(whServerContext* ctx, whPacket* packet,
if ( (ret == 0) &&
(export_pub_key != 0) ) {
/* Export the public key to the result message*/
pub_size = wc_EccPublicKeyToDer(key, (byte*)res_pub,
ret = wc_EccPublicKeyToDer(key, (byte*)res_pub,
max_size, 1);
if (pub_size < 0) {
if (ret < 0) {
/* Problem dumping the public key. Set to 0 length */
pub_size = 0;
} else {
pub_size = ret;
ret = 0;
}
}
}
Expand Down

0 comments on commit 3ed835b

Please sign in to comment.