[Cryptech-Commits] [sw/libhal] 04/13: Add hal_ks_available

git at cryptech.is git at cryptech.is
Fri Apr 20 01:06:11 UTC 2018


This is an automated email from the git hooks/post-receive script.

paul at psgd.org pushed a commit to branch hashsig
in repository sw/libhal.

commit efc47f47581bb164440b86e9e57382972a32dbe8
Author: Paul Selkirk <paul at psgd.org>
AuthorDate: Tue Feb 27 18:00:08 2018 +0100

    Add hal_ks_available
---
 ks.c | 12 ++++++++++++
 ks.h |  2 ++
 2 files changed, 14 insertions(+)

diff --git a/ks.c b/ks.c
index 1598679..f145adc 100644
--- a/ks.c
+++ b/ks.c
@@ -1010,6 +1010,18 @@ hal_error_t hal_ks_rewrite_der(hal_ks_t *ks,
   return err;
 }
 
+hal_error_t hal_ks_available(hal_ks_t *ks, size_t *count)
+{
+  if (ks == NULL || count == NULL)
+    return HAL_ERROR_BAD_ARGUMENTS;
+
+  hal_ks_lock();
+  *count = ks->size - ks->used;
+  hal_ks_unlock();
+
+  return HAL_OK;
+}
+
 /*
  * Local variables:
  * indent-tabs-mode: nil
diff --git a/ks.h b/ks.h
index 559e46f..e1f865c 100644
--- a/ks.h
+++ b/ks.h
@@ -426,6 +426,8 @@ extern hal_error_t hal_ks_block_update(hal_ks_t *ks,
                                        const hal_uuid_t * const uuid,
                                        int *hint);
 
+extern hal_error_t hal_ks_available(hal_ks_t *ks, size_t *count);
+
 #endif /* _KS_H_ */
 
 /*



More information about the Commits mailing list