Skip to content

Commit fff6f3f

Browse files
committed
se050: fix RSA Encrypt with only pubkey setting keyId
1 parent 931893c commit fff6f3f

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

wolfcrypt/src/port/nxp/se050_port.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1710,8 +1710,17 @@ int se050_rsa_public_encrypt(const byte* in, word32 inLen, byte* out,
17101710
}
17111711

17121712
if (status == kStatus_SSS_Success) {
1713-
key->keyId = keyId;
1714-
key->keyIdSet = 1;
1713+
if (keyCreated) {
1714+
/* Public-key encrypt imported a temporary public object only.
1715+
* Do not bind that SE050 object to the caller's RsaKey or later
1716+
* private-key operations will try to reuse a public handle. */
1717+
sss_key_store_erase_key(&host_keystore, &newKey);
1718+
sss_key_object_free(&newKey);
1719+
}
1720+
else {
1721+
key->keyId = keyId;
1722+
key->keyIdSet = 1;
1723+
}
17151724
ret = encSz;
17161725
}
17171726
else {

0 commit comments

Comments
 (0)