@@ -1483,7 +1483,7 @@ int se050_rsa_verify(const byte* in, word32 inLen, byte* out, word32 outLen,
14831483 keyId = se050_allocate_key (SE050_RSA_KEY );
14841484 status = sss_key_object_allocate_handle (& newKey , keyId ,
14851485 kSSS_KeyPart_Public , kSSS_CipherType_RSA , keySz ,
1486- kKeyObject_Mode_Persistent );
1486+ kKeyObject_Mode_Transient );
14871487 }
14881488 if (status == kStatus_SSS_Success ) {
14891489 /* Try to delete existing key first, ignore return since will
@@ -1540,7 +1540,7 @@ int se050_rsa_verify(const byte* in, word32 inLen, byte* out, word32 outLen,
15401540 if (status == kStatus_SSS_Success ) {
15411541 if (keyCreated ) {
15421542 /* We uploaded only the public part of the key for this verify.
1543- * Don't persist keyIdSet=1 — a later sign on the same RsaKey
1543+ * Don't persist keyIdSet=1 -- a later sign on the same RsaKey
15441544 * would reuse this binding and fail because the SE050 object has
15451545 * no private material. Erase the transient object so the next
15461546 * SE050 op (sign or verify) re-uploads from whatever the host
@@ -3053,6 +3053,10 @@ int se050_ed25519_verify_msg(const byte* signature, word32 signatureLen,
30533053 key , signature , signatureLen , msg , msgLen );
30543054#endif
30553055
3056+ if (signature == NULL || msg == NULL || key == NULL || res == NULL ) {
3057+ return BAD_FUNC_ARG ;
3058+ }
3059+
30563060 * res = 0 ;
30573061
30583062 if (cfg_se050_i2c_pi == NULL ) {
@@ -3115,8 +3119,21 @@ int se050_ed25519_verify_msg(const byte* signature, word32 signatureLen,
31153119 }
31163120
31173121 if (status == kStatus_SSS_Success ) {
3118- key -> keyId = keyId ;
3119- key -> keyIdSet = 1 ;
3122+ if (keyCreated ) {
3123+ /* We uploaded only the public part of the key for this verify.
3124+ * Don't persist keyIdSet=1 -- a later sign on the same ed25519_key
3125+ * would reuse this binding and fail because the SE050 object has
3126+ * no private material. Erase the transient object so the next
3127+ * SE050 op re-uploads. Mirrors the fix in se050_rsa_verify. */
3128+ sss_key_store_erase_key (& host_keystore , & newKey );
3129+ sss_key_object_free (& newKey );
3130+ }
3131+ else {
3132+ /* Pre-existing keyIdSet=1 binding (from prior sign that uploaded
3133+ * a keypair, or explicit caller setup). Preserve it. */
3134+ key -> keyId = keyId ;
3135+ key -> keyIdSet = 1 ;
3136+ }
31203137 * res = 1 ;
31213138 ret = 0 ;
31223139 }
0 commit comments