diff options
Diffstat (limited to 'firmware/2lib/2packed_key2.c')
-rw-r--r-- | firmware/2lib/2packed_key2.c | 29 |
1 files changed, 9 insertions, 20 deletions
diff --git a/firmware/2lib/2packed_key2.c b/firmware/2lib/2packed_key2.c index 22fa0a40..e8289273 100644 --- a/firmware/2lib/2packed_key2.c +++ b/firmware/2lib/2packed_key2.c @@ -14,21 +14,6 @@ const uint8_t *vb2_packed_key2_data(const struct vb2_packed_key2 *key) return (const uint8_t *)key + key->key_offset; } -int vb2_verify_packed_key2_inside(const void *parent, - uint32_t parent_size, - const struct vb2_packed_key2 *key) -{ - int rv; - - rv = vb2_verify_member_inside(parent, parent_size, - key, sizeof(*key), - key->key_offset, key->key_size); - if (rv) - return rv; - - return vb2_verify_common_header(parent, parent_size, &key->c); -} - int vb2_unpack_key2(struct vb2_public_key *key, const uint8_t *buf, uint32_t size) @@ -38,6 +23,7 @@ int vb2_unpack_key2(struct vb2_public_key *key, const uint32_t *buf32; uint32_t expected_key_size; uint32_t sig_size; + uint32_t min_offset = 0; int rv; /* @@ -51,8 +37,13 @@ int vb2_unpack_key2(struct vb2_public_key *key, if (pkey->c.magic != VB2_MAGIC_PACKED_KEY2) return vb2_unpack_key(key, buf, size); - /* Make sure passed buffer is big enough for the packed key */ - rv = vb2_verify_packed_key2_inside(buf, size, pkey); + rv = vb2_verify_common_header(buf, size); + if (rv) + return rv; + + /* Make sure key data is inside */ + rv = vb2_verify_common_member(pkey, &min_offset, + pkey->key_offset, pkey->key_size); if (rv) return rv; @@ -80,10 +71,8 @@ int vb2_unpack_key2(struct vb2_public_key *key, return VB2_ERROR_UNPACK_KEY_SIZE; } - /* Make sure source buffer is 32-bit aligned */ + /* Unpack key data */ buf32 = (const uint32_t *)vb2_packed_key2_data(pkey); - if (!vb2_aligned(buf32, sizeof(uint32_t))) - return VB2_ERROR_UNPACK_KEY_ALIGN; /* Sanity check key array size */ key->arrsize = buf32[0]; |