Skip to content

Commit abdcf4d

Browse files
committed
improve ED25519 key handling in CryptoCb function
1 parent 394a25b commit abdcf4d

1 file changed

Lines changed: 18 additions & 10 deletions

File tree

wolfcrypt/src/port/tropicsquare/tropic01.c

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -243,19 +243,28 @@ int Tropic01_CryptoCb(int devId, wc_CryptoInfo* info, void* ctx)
243243
TROPIC01_ED25519_PRIV_KEY_SIZE);
244244
if (ret != 0) {
245245
WOLFSSL_MSG_EX(
246-
"TROPIC01: CryptoCB: Failed to get ED25519 key, ret=%d",
246+
"TROPIC01: CryptoCB: Failed to get ED25519 PRIVkey,ret=%d",
247+
ret);
248+
return ret;
249+
}
250+
ret = Tropic01_GetKeyECC(
251+
info->pk.ed25519sign.key->p,
252+
TROPIC01_ED25519_PUB_RMEM_SLOT_DEFAULT,
253+
TROPIC01_ED25519_PUB_KEY_SIZE);
254+
if (ret != 0) {
255+
WOLFSSL_MSG_EX(
256+
"TROPIC01: CryptoCB: Failed to get ED25519 PUBkey,ret=%d",
247257
ret);
248258
return ret;
249259
}
250260
/* set devId to invalid, so software is used */
251261
info->pk.ed25519sign.key->devId = INVALID_DEVID;
262+
info->pk.ed25519sign.key->privKeySet = 1;
252263
info->pk.ed25519sign.key->pubKeySet = 1;
253-
254-
ret = wc_ed25519_sign_msg_ex(
264+
ret = wc_ed25519_sign_msg(
255265
info->pk.ed25519sign.in, info->pk.ed25519sign.inLen,
256266
info->pk.ed25519sign.out, info->pk.ed25519sign.outLen,
257-
info->pk.ed25519sign.key, info->pk.ed25519sign.type,
258-
info->pk.ed25519sign.context, info->pk.ed25519sign.contextLen);
267+
info->pk.ed25519sign.key);
259268

260269
/* reset devId */
261270
info->pk.ed25519sign.key->devId = devId;
@@ -266,7 +275,7 @@ int Tropic01_CryptoCb(int devId, wc_CryptoInfo* info, void* ctx)
266275
WOLFSSL_MSG("TROPIC01: CryptoCB: ED25519 verification request");
267276
/* retrieve public key from TROPIC01 secure R memory */
268277
ret = Tropic01_GetKeyECC(
269-
info->pk.ed25519sign.key->p,
278+
info->pk.ed25519verify.key->p,
270279
TROPIC01_ED25519_PUB_RMEM_SLOT_DEFAULT,
271280
TROPIC01_ED25519_PUB_KEY_SIZE);
272281
if (ret != 0) {
@@ -278,12 +287,11 @@ int Tropic01_CryptoCb(int devId, wc_CryptoInfo* info, void* ctx)
278287

279288
/* set devId to invalid, so software is used */
280289
info->pk.ed25519verify.key->devId = INVALID_DEVID;
281-
282-
ret = wc_ed25519_verify_msg_ex(
290+
info->pk.ed25519verify.key->pubKeySet = 1;
291+
ret = wc_ed25519_verify_msg(
283292
info->pk.ed25519verify.sig, info->pk.ed25519verify.sigLen,
284293
info->pk.ed25519verify.msg, info->pk.ed25519verify.msgLen,
285-
info->pk.ed25519verify.res, info->pk.ed25519verify.key,
286-
info->pk.ed25519verify.type, NULL, 0);
294+
info->pk.ed25519verify.res, info->pk.ed25519verify.key);
287295

288296
/* reset devId */
289297
info->pk.ed25519verify.key->devId = devId;

0 commit comments

Comments
 (0)