refactor: move crypto reg API to measure
Declare event_log_init_and_reg() in event_measure.h instead of
event_record.h. This keeps crypto/measurement concerns together and
hides it from users who only record events. No behavior changes.
Signed-off-by: Harrison Mutai <harrison.mutai@arm.com>
Change-Id: I2d5edb1707f9e07d0c14735381c83725ba9726e2
Signed-off-by: Harrison Mutai <harrison.mutai@arm.com>
diff --git a/include/event_log.h b/include/event_log.h
index ad5ba2a..e5870ad 100644
--- a/include/event_log.h
+++ b/include/event_log.h
@@ -22,21 +22,6 @@
#define MEMBER_SIZE(type, member) sizeof(((type *)0)->member)
-typedef struct {
- unsigned int id;
- const char *name;
- unsigned int pcr;
-} event_log_metadata_t;
-
-typedef int (*evlog_hash_func_t)(uint32_t alg, void *data, unsigned int len,
- uint8_t *digest);
-
-struct event_log_hash_info {
- evlog_hash_func_t func;
- const uint32_t *ids;
- size_t count;
-};
-
struct event_log_algorithm {
uint16_t id;
const char *name;
diff --git a/include/event_measure.h b/include/event_measure.h
index f40b33c..64d5be4 100644
--- a/include/event_measure.h
+++ b/include/event_measure.h
@@ -10,6 +10,44 @@
#include "event_log.h"
#include "event_record.h"
+typedef struct {
+ unsigned int id;
+ const char *name;
+ unsigned int pcr;
+} event_log_metadata_t;
+
+typedef int (*evlog_hash_func_t)(uint32_t alg, void *data, unsigned int len,
+ uint8_t *digest);
+
+struct event_log_hash_info {
+ evlog_hash_func_t func;
+ const uint32_t *ids;
+ size_t count;
+};
+
+/**
+ * Initialize the Event Log and register supported hash functions.
+ *
+ * Initializes the Event Log subsystem using the provided memory region
+ * and registers one or more cryptographic hash functions for use in
+ * event measurements. This function must be called before any measurements
+ * or event recording can take place.
+ *
+ * @param[in] start Pointer to the beginning of the Event Log buffer.
+ * @param[in] finish Pointer to the end of the Event Log buffer.
+ * @param[in] pos Previous cursor position.
+ * @param[in] hash_info Pointer to a structure containing the hash function
+ * pointer and associated algorithm identifiers.
+ *
+ * @return 0 on success,
+ * -EEXIST if hash functions have already been registered,
+ *
+ * -EINVAL if the input parameters are invalid,
+ * or a negative error code from the underlying initialization logic.
+ */
+int event_log_init_and_reg(uint8_t *start, uint8_t *finish, size_t pos,
+ const struct event_log_hash_info *hash_info);
+
/**
* Measure input data and log its hash to the Event Log.
*
diff --git a/include/event_record.h b/include/event_record.h
index 2e8e14b..ab849e2 100644
--- a/include/event_record.h
+++ b/include/event_record.h
@@ -49,29 +49,6 @@
int event_log_init_from_pos(uint8_t *start, uint8_t *finish, size_t pos);
/**
- * Initialize the Event Log and register supported hash functions.
- *
- * Initializes the Event Log subsystem using the provided memory region
- * and registers one or more cryptographic hash functions for use in
- * event measurements. This function must be called before any measurements
- * or event recording can take place.
- *
- * @param[in] start Pointer to the beginning of the Event Log buffer.
- * @param[in] finish Pointer to the end of the Event Log buffer.
- * @param[in] pos Previous cursor position.
- * @param[in] hash_info Pointer to a structure containing the hash function
- * pointer and associated algorithm identifiers.
- *
- * @return 0 on success,
- * -EEXIST if hash functions have already been registered,
- *
- * -EINVAL if the input parameters are invalid,
- * or a negative error code from the underlying initialization logic.
- */
-int event_log_init_and_reg(uint8_t *start, uint8_t *finish, size_t pos,
- const struct event_log_hash_info *hash_info);
-
-/**
* @brief Write a PCR event with multiple digests.
*
* @param[in] pcr_index PCR index of the event.
diff --git a/src/event_log.c b/src/event_log.c
index 5beff45..83afcdd 100644
--- a/src/event_log.c
+++ b/src/event_log.c
@@ -13,6 +13,7 @@
#include "debug.h"
#include "digest.h"
#include "event_log.h"
+#include "event_measure.h"
#include "event_record.h"
/* Running Event Log Pointer */