Skip to content

Commit 6d55ebe

Browse files
committed
review: fixes for CC-RH compatibility
1 parent d1fcfff commit 6d55ebe

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

src/wh_server_crypto.c

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -522,13 +522,8 @@ int wh_Server_CacheImportCurve25519Key(whServerContext* server,
522522
uint8_t* cacheBuf;
523523
whNvmMetadata* cacheMeta;
524524
int ret;
525-
/* Max size of a DER encoded curve25519 keypair with SubjectPublicKeyInfo
526-
* included. Determined by experiment */
527-
const uint16_t MAX_DER_SIZE = 128;
528-
uint16_t keySz = keySz;
529-
530-
uint8_t der_buf[MAX_DER_SIZE];
531-
525+
uint8_t der_buf[CURVE25519_MAX_KEY_TO_DER_SZ];
526+
uint16_t keySz = sizeof(der_buf);
532527

533528
if ((server == NULL) || (key == NULL) || (WH_KEYID_ISERASED(keyId)) ||
534529
((label != NULL) && (label_len > sizeof(cacheMeta->label)))) {
@@ -922,7 +917,7 @@ static int _HandleEccVerify(whServerContext* ctx, uint16_t magic,
922917

923918
/* Response message */
924919
byte* res_pub =
925-
(uint8_t*)(cryptoDataOut + sizeof(whMessageCrypto_EccVerifyResponse));
920+
(uint8_t*)(cryptoDataOut) + sizeof(whMessageCrypto_EccVerifyResponse);
926921
word32 max_size = (word32)(WOLFHSM_CFG_COMM_DATA_LEN -
927922
(res_pub - (uint8_t*)cryptoDataOut));
928923
uint32_t pub_size = 0;
@@ -1240,12 +1235,12 @@ static int _HandleAesCbc(whServerContext* ctx, uint16_t magic, const void* crypt
12401235

12411236
/* in, key, iv, and out are after fixed size fields */
12421237
uint8_t* in =
1243-
(uint8_t*)(cryptoDataIn + sizeof(whMessageCrypto_AesCbcRequest));
1238+
(uint8_t*)(cryptoDataIn) + sizeof(whMessageCrypto_AesCbcRequest);
12441239
uint8_t* key = in + len;
12451240
uint8_t* iv = key + key_len;
12461241

12471242
uint8_t* out =
1248-
(uint8_t*)(cryptoDataOut + sizeof(whMessageCrypto_AesCbcResponse));
1243+
(uint8_t*)(cryptoDataOut) + sizeof(whMessageCrypto_AesCbcResponse);
12491244

12501245
/* Debug printouts */
12511246
#ifdef DEBUG_CRYPTOCB_VERBOSE

0 commit comments

Comments
 (0)