summaryrefslogtreecommitdiff
path: root/firmware/2lib
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/2lib')
-rw-r--r--firmware/2lib/2secdata.c4
-rw-r--r--firmware/2lib/include/2return_codes.h4
2 files changed, 6 insertions, 2 deletions
diff --git a/firmware/2lib/2secdata.c b/firmware/2lib/2secdata.c
index 0fd6c522..3281f7c3 100644
--- a/firmware/2lib/2secdata.c
+++ b/firmware/2lib/2secdata.c
@@ -20,6 +20,10 @@ int vb2_secdata_check_crc(const struct vb2_context *ctx)
if (sec->crc8 != vb2_crc8(sec, offsetof(struct vb2_secdata, crc8)))
return VB2_ERROR_SECDATA_CRC;
+ /* CRC(<000...00>) is 0, so check version as well (should never be 0) */
+ if (!sec->struct_version)
+ return VB2_ERROR_SECDATA_ZERO;
+
return VB2_SUCCESS;
}
diff --git a/firmware/2lib/include/2return_codes.h b/firmware/2lib/include/2return_codes.h
index 20a7947c..c209d541 100644
--- a/firmware/2lib/include/2return_codes.h
+++ b/firmware/2lib/include/2return_codes.h
@@ -93,8 +93,8 @@ enum vb2_return_code {
/* Bad CRC in vb2_secdata_check_crc() */
VB2_ERROR_SECDATA_CRC,
- /* Bad struct version in vb2_secdata_init() */
- VB2_ERROR_SECDATA_VERSION,
+ /* Secdata is all zeroes (uninitialized) in vb2_secdata_check_crc() */
+ VB2_ERROR_SECDATA_ZERO,
/* Invalid param in vb2_secdata_get() */
VB2_ERROR_SECDATA_GET_PARAM,