summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--firmware/2lib/2secdata_fwmp.c19
-rw-r--r--firmware/2lib/include/2api.h9
2 files changed, 28 insertions, 0 deletions
diff --git a/firmware/2lib/2secdata_fwmp.c b/firmware/2lib/2secdata_fwmp.c
index a28b5bbf..cec24813 100644
--- a/firmware/2lib/2secdata_fwmp.c
+++ b/firmware/2lib/2secdata_fwmp.c
@@ -60,6 +60,25 @@ vb2_error_t vb2api_secdata_fwmp_check(struct vb2_context *ctx, uint8_t *size)
return VB2_SUCCESS;
}
+uint32_t vb2api_secdata_fwmp_create(struct vb2_context *ctx)
+{
+ struct vb2_secdata_fwmp *sec = (void *)&ctx->secdata_fwmp;
+
+ /* Clear the entire struct */
+ memset(sec, 0, sizeof(*sec));
+
+ /* Set to current version */
+ sec->struct_version = VB2_SECDATA_FWMP_VERSION;
+
+ /* Set the structure size */
+ sec->struct_size = sizeof(*sec);
+
+ /* Calculate initial CRC */
+ sec->crc8 = vb2_secdata_fwmp_crc(sec);
+
+ return sizeof(*sec);
+}
+
vb2_error_t vb2_secdata_fwmp_init(struct vb2_context *ctx)
{
struct vb2_shared_data *sd = vb2_get_sd(ctx);
diff --git a/firmware/2lib/include/2api.h b/firmware/2lib/include/2api.h
index bd3b05f1..fb8bc51b 100644
--- a/firmware/2lib/include/2api.h
+++ b/firmware/2lib/include/2api.h
@@ -578,6 +578,15 @@ uint32_t vb2api_secdata_kernel_create(struct vb2_context *ctx);
uint32_t vb2api_secdata_kernel_create_v0(struct vb2_context *ctx);
/**
+ * Create an empty Firmware Management Parameters (FWMP) in secure storage
+ * context.
+ *
+ * @param ctx Context pointer
+ * @return size of created FWMP secure storage data in bytes
+ */
+uint32_t vb2api_secdata_fwmp_create(struct vb2_context *ctx);
+
+/**
* Check the validity of firmware management parameters (FWMP) space.
*
* Checks size, version, and CRC. If the struct size is larger than the size