Skip to content

Commit 82bd418

Browse files
committed
[nrf noup] Add ASN.1 bypass to bootutil_verify_img
Allow ASN.1 bypass for image verification. Signed-off-by: Dominik Ermel <[email protected]>
1 parent a3e4730 commit 82bd418

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

boot/bootutil/src/image_ed25519.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,11 +143,25 @@ bootutil_verify_img(const uint8_t *img, uint32_t size,
143143
pubkey = (uint8_t *)bootutil_keys[key_id].key;
144144
end = pubkey + *bootutil_keys[key_id].len;
145145

146+
#if !defined(MCUBOOT_KEY_IMPORT_BYPASS_ASN)
146147
rc = bootutil_import_key(&pubkey, end);
147148
if (rc) {
148149
FIH_SET(fih_rc, FIH_FAILURE);
149150
goto out;
150151
}
152+
#else
153+
/* Directly use the key contents from the ASN stream,
154+
* these are the last NUM_ED25519_BYTES.
155+
* There is no check whether this is the correct key,
156+
* here, by the algorithm selected.
157+
*/
158+
if (*bootutil_keys[key_id].len < NUM_ED25519_BYTES) {
159+
FIH_SET(fih_rc, FIH_FAILURE);
160+
goto out;
161+
}
162+
163+
pubkey = end - NUM_ED25519_BYTES;
164+
#endif
151165

152166
rc = ED25519_verify(img, size, sig, pubkey);
153167

0 commit comments

Comments
 (0)