From 3f25ad7c76e4cf90bd82d70a429fa474a079ab2b Mon Sep 17 00:00:00 2001 From: Andrew Gunnerson Date: Tue, 5 Nov 2024 17:53:01 -0500 Subject: [PATCH] Add more context for avb::Header::set_algo_for_key() calls Previously, it was not always obvious which key was problematic. Issue: #366 Signed-off-by: Andrew Gunnerson --- avbroot/src/cli/avb.rs | 4 +++- avbroot/src/cli/ota.rs | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/avbroot/src/cli/avb.rs b/avbroot/src/cli/avb.rs index 71a2195..aea0084 100644 --- a/avbroot/src/cli/avb.rs +++ b/avbroot/src/cli/avb.rs @@ -398,7 +398,9 @@ fn sign_or_clear(info: &mut AvbInfo, orig_header: &Header, key_group: &KeyGroup) RsaSigningKey::Internal(private_key) }; - info.header.set_algo_for_key(&signing_key)?; + info.header + .set_algo_for_key(&signing_key) + .context("Failed to set signature algorithm")?; info.header .sign(&signing_key) .context("Failed to sign new AVB header")?; diff --git a/avbroot/src/cli/ota.rs b/avbroot/src/cli/ota.rs index 37da545..a4e2846 100644 --- a/avbroot/src/cli/ota.rs +++ b/avbroot/src/cli/ota.rs @@ -593,7 +593,9 @@ fn update_vbmeta_headers( // have no dependencies and are only being processed to ensure that the // flags are set to a sane value. if parent_header != &orig_parent_header { - parent_header.set_algo_for_key(key)?; + parent_header + .set_algo_for_key(key) + .with_context(|| format!("Failed to set signature algorithm: {name}"))?; parent_header .sign(key) .with_context(|| format!("Failed to sign vbmeta header for image: {name}"))?;