Skip to content

Commit 08e2b7a

Browse files
srpatchaclaude
andcommitted
fix(secure-boot): take the verification key from the keystore
eos_image_verify_signature() referenced two symbols that do not exist anywhere in the repository: extern int eos_keystore_get_compiled_key(const uint8_t **key, size_t *len); extern const uint8_t ebldr_default_pubkey[32]; The first was declared and never called. The second was assigned straight to pub_key, and is defined in no translation unit, so any build that links the signature path failed: image_verify.c:(.text+0x404): undefined reference to `ebldr_default_pubkey' That is why -DEBLDR_BUILD_TESTS=ON did not link. Beyond not linking, reaching for a raw key symbol bypassed the keystore entirely — and the keystore is where the security properties live. Its init() prefers OTP-provisioned keys over the compiled-in one, reads the revocation flags, picks the first valid non-revoked slot, and seeds the monotonic security version. get_active_key() then refuses to hand back a slot that is invalid or revoked. None of that was running: a revoked key would still have verified images. Now calls eos_keystore_init() followed by eos_keystore_get_active_key(), returning EOS_ERR_KEY if either fails, so an unprovisioned or fully revoked keystore cannot verify anything. The existing dual verification for fault-injection resistance is unchanged. With tests enabled the tree now builds with 0 errors and all 11 ctest cases pass. Note for deployment, unchanged by this commit: with EBLDR_PRODUCTION_KEY unset, keystore.c falls back to default_dev_key, which is the RFC 8032 test vector public key — its private half is public. That fallback is clearly commented in keystore.c, but it means a default build trusts a key anyone can sign with. Production builds must define EBLDR_PRODUCTION_KEY and provide ebldr_production_key, or provision OTP. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
1 parent 519f5d7 commit 08e2b7a

1 file changed

Lines changed: 13 additions & 6 deletions

File tree

core/image_verify.c

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
#include "eos_image.h"
1414
#include "eos_crypto_boot.h"
15+
#include "eos_keystore.h"
1516
#include "eos_hal.h"
1617
#include <string.h>
1718

@@ -130,15 +131,21 @@ int eos_image_verify_signature(const eos_image_header_t *hdr)
130131

131132
/* Phase 2: Ed25519 signature verification */
132133
if (hdr->sig_type == EOS_SIG_ED25519) {
133-
/* Get public key from keystore */
134-
extern int eos_keystore_get_compiled_key(const uint8_t **key, size_t *len);
134+
/* Take the public key from the keystore rather than reaching for a
135+
* symbol directly. Two reasons: ebldr_default_pubkey was never
136+
* defined anywhere, so this did not link; and going through the
137+
* keystore is what applies OTP provisioning, slot selection and
138+
* revocation. A key that has been revoked must not verify anything,
139+
* and only eos_keystore_get_active_key() enforces that. */
140+
eos_keystore_t ks;
135141
const uint8_t *pub_key = NULL;
136142
size_t key_len = 0;
137143

138-
/* Try compiled-in key directly */
139-
extern const uint8_t ebldr_default_pubkey[32];
140-
pub_key = ebldr_default_pubkey;
141-
key_len = 32;
144+
if (eos_keystore_init(&ks) != EOS_OK)
145+
return EOS_ERR_KEY;
146+
147+
if (eos_keystore_get_active_key(&ks, &pub_key, &key_len) != EOS_OK)
148+
return EOS_ERR_KEY;
142149

143150
/* Verify signature over the hash */
144151
int rc = eos_crypto_verify_signature(

0 commit comments

Comments
 (0)