File tree 1 file changed +16
-0
lines changed
1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -196,6 +196,14 @@ CHIP_ERROR PSASessionKeystore::PersistICDKey(Aes128KeyHandle & key)
196
196
CHIP_ERROR err;
197
197
AesKeyAttributes attrs;
198
198
psa_key_id_t previousKeyId = key.As <psa_key_id_t >();
199
+ psa_key_attributes_t previousKeyAttrs;
200
+
201
+ psa_get_key_attributes (previousKeyId, &previousKeyAttrs);
202
+ // Exit early if key is already persistent
203
+ if (psa_get_key_lifetime (&previousKeyAttrs) == PSA_KEY_LIFETIME_PERSISTENT)
204
+ {
205
+ ExitNow (err = CHIP_NO_ERROR);
206
+ }
199
207
200
208
SuccessOrExit (err = Crypto::FindFreeKeySlotInRange (key.AsMutable <psa_key_id_t >(),
201
209
to_underlying (KeyIdOptional::ICDAesKeyRangeStart), kMaxICDClientKeys ));
@@ -221,6 +229,14 @@ CHIP_ERROR PSASessionKeystore::PersistICDKey(Hmac128KeyHandle & key)
221
229
CHIP_ERROR err;
222
230
HmacKeyAttributes attrs;
223
231
psa_key_id_t previousKeyId = key.As <psa_key_id_t >();
232
+ psa_key_attributes_t previousKeyAttrs;
233
+
234
+ psa_get_key_attributes (previousKeyId, &previousKeyAttrs);
235
+ // Exit early if key is already persistent
236
+ if (psa_get_key_lifetime (&previousKeyAttrs) == PSA_KEY_LIFETIME_PERSISTENT)
237
+ {
238
+ ExitNow (err = CHIP_NO_ERROR);
239
+ }
224
240
225
241
SuccessOrExit (err = Crypto::FindFreeKeySlotInRange (key.AsMutable <psa_key_id_t >(),
226
242
to_underlying (KeyIdOptional::ICDHmacKeyRangeStart), kMaxICDClientKeys ));
You can’t perform that action at this time.
0 commit comments