aboutsummaryrefslogtreecommitdiff
path: root/ks_attribute.c
diff options
context:
space:
mode:
authorRob Austein <sra@hactrn.net>2017-03-02 20:34:19 -0500
committerRob Austein <sra@hactrn.net>2017-03-02 20:34:19 -0500
commit91bb0444d8830569bfc09900d599c9ae39953f01 (patch)
tree3d4030a905aa3c6865b7fad0943f813a17fc4087 /ks_attribute.c
parentc2f499e0a301d4ad0f92d58f436d01087ceae1bb (diff)
parenta33470b2f899a94b50304a73721ba6d0d6d447b4 (diff)
Merge branch 'pymux' into hw_ecdsa_p256
Diffstat (limited to 'ks_attribute.c')
-rw-r--r--ks_attribute.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/ks_attribute.c b/ks_attribute.c
index 92e450d..ec674f5 100644
--- a/ks_attribute.c
+++ b/ks_attribute.c
@@ -120,11 +120,18 @@ hal_error_t hal_ks_attribute_delete(uint8_t *bytes, const size_t bytes_len,
if (bytes == NULL || attributes == NULL || attributes_len == NULL || total_len == NULL)
return HAL_ERROR_BAD_ARGUMENTS;
+ /*
+ * Search for attribute by type. Note that there can be only one
+ * attribute of any given type.
+ */
+
int i = 0;
while (i < *attributes_len && attributes[i].type != type)
i++;
+ /* If not found, great, it's already deleted from the key. */
+
if (i == *attributes_len)
return HAL_OK;
@@ -152,6 +159,8 @@ hal_error_t hal_ks_attribute_insert(uint8_t *bytes, const size_t bytes_len,
total_len == NULL || value == NULL)
return HAL_ERROR_BAD_ARGUMENTS;
+ /* Delete the existing attribute value (if present), then write the new value. */
+
hal_error_t err
= hal_ks_attribute_delete(bytes, bytes_len, attributes, attributes_len, total_len, type);