Skip to content

Commit cd024f7

Browse files
committed
pass keysize for rsa/ecc by bytes
1 parent d7fec71 commit cd024f7

3 files changed

Lines changed: 12 additions & 6 deletions

File tree

wolfcrypt/src/asn.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8283,7 +8283,8 @@ int wc_RsaPrivateKeyDecode(const byte* input, word32* inOutIdx, RsaKey* key,
82838283
tmpErr = _RsaPrivateKeyDecode(input, &tmpIdx, tmpKey, NULL, inSz);
82848284
if (tmpErr == 0) {
82858285
cbRet = wc_CryptoCb_SetKey(key->devId,
8286-
WC_SETKEY_RSA_PRIV, key, tmpKey, 0, NULL, 0, 0);
8286+
WC_SETKEY_RSA_PRIV, key, tmpKey,
8287+
wc_RsaEncryptSize(tmpKey), NULL, 0, 0);
82878288
}
82888289

82898290
wc_FreeRsaKey(tmpKey);
@@ -45143,7 +45144,8 @@ int wc_RsaPublicKeyDecodeRaw(const byte* n, word32 nSz, const byte* e,
4514345144
tmpErr = wc_RsaPublicKeyDecodeRaw(n, nSz, e, eSz, tmpKey);
4514445145
if (tmpErr == 0) {
4514545146
cbRet = wc_CryptoCb_SetKey(key->devId,
45146-
WC_SETKEY_RSA_PUB, key, tmpKey, 0, NULL, 0, 0);
45147+
WC_SETKEY_RSA_PUB, key, tmpKey,
45148+
wc_RsaEncryptSize(tmpKey), NULL, 0, 0);
4514745149
}
4514845150

4514945151
wc_FreeRsaKey(tmpKey);

wolfcrypt/src/ecc.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10698,7 +10698,8 @@ int wc_ecc_import_x963_ex2(const byte* in, word32 inLen, ecc_key* key,
1069810698
err = wc_ecc_import_x963_ex2(in, inLen, tmpKey, curve_id, untrusted);
1069910699
if (err == MP_OKAY) {
1070010700
cbRet = wc_CryptoCb_SetKey(key->devId,
10701-
WC_SETKEY_ECC_PUB, key, tmpKey, 0, NULL, 0, 0);
10701+
WC_SETKEY_ECC_PUB, key, tmpKey,
10702+
wc_ecc_size(tmpKey), NULL, 0, 0);
1070210703
}
1070310704

1070410705
wc_ecc_free(tmpKey);
@@ -11219,7 +11220,8 @@ int wc_ecc_import_private_key_ex(const byte* priv, word32 privSz,
1121911220
tmpKey, curve_id);
1122011221
if (tmpErr == 0) {
1122111222
cbRet = wc_CryptoCb_SetKey(key->devId,
11222-
WC_SETKEY_ECC_PRIV, key, tmpKey, 0, NULL, 0, 0);
11223+
WC_SETKEY_ECC_PRIV, key, tmpKey,
11224+
wc_ecc_size(tmpKey), NULL, 0, 0);
1122311225
}
1122411226

1122511227
wc_ecc_free(tmpKey);
@@ -11605,7 +11607,8 @@ static int wc_ecc_import_raw_private(ecc_key* key, const char* qx,
1160511607
setKeyType = WC_SETKEY_ECC_PUB;
1160611608
}
1160711609
cbRet = wc_CryptoCb_SetKey(key->devId,
11608-
setKeyType, key, tmpKey, 0, NULL, 0, 0);
11610+
setKeyType, key, tmpKey,
11611+
wc_ecc_size(tmpKey), NULL, 0, 0);
1160911612
}
1161011613

1161111614
wc_ecc_free(tmpKey);

wolfcrypt/src/rsa.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5401,7 +5401,8 @@ int wc_RsaPrivateKeyDecodeRaw(const byte* n, word32 nSz,
54015401
u, uSz, p, pSz, q, qSz, dP, dPSz, dQ, dQSz, tmpKey);
54025402
if (err == MP_OKAY) {
54035403
cbRet = wc_CryptoCb_SetKey(key->devId,
5404-
WC_SETKEY_RSA_PRIV, key, tmpKey, 0, NULL, 0, 0);
5404+
WC_SETKEY_RSA_PRIV, key, tmpKey,
5405+
wc_RsaEncryptSize(tmpKey), NULL, 0, 0);
54055406
}
54065407

54075408
/* wc_FreeRsaKey does mp_forcezero on private components */

0 commit comments

Comments
 (0)