From 5164e7bbe3da043f045aeea859f3ebec5cf09adc Mon Sep 17 00:00:00 2001 From: Chris Frantz Date: Wed, 18 Dec 2024 10:20:35 -0800 Subject: [PATCH] [hsmtool] Correctly handle missing SPX IDs It is legal for SPX key entities to be missing a PKCS#11 `id`. Signed-off-by: Chris Frantz --- sw/host/hsmtool/src/commands/spx/generate.rs | 2 +- sw/host/hsmtool/src/commands/spx/import.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sw/host/hsmtool/src/commands/spx/generate.rs b/sw/host/hsmtool/src/commands/spx/generate.rs index f36428ce67091..4d45f38f20203 100644 --- a/sw/host/hsmtool/src/commands/spx/generate.rs +++ b/sw/host/hsmtool/src/commands/spx/generate.rs @@ -53,7 +53,7 @@ impl Dispatch for Generate { Ok(Box::new(BasicResult { success: true, - id: AttrData::Str(key.hash.expect("key hash")), + id: key.hash.map_or(AttrData::None, AttrData::Str), label: AttrData::Str(key.alias), value: None, error: None, diff --git a/sw/host/hsmtool/src/commands/spx/import.rs b/sw/host/hsmtool/src/commands/spx/import.rs index f5494c534994e..cac4357c461ca 100644 --- a/sw/host/hsmtool/src/commands/spx/import.rs +++ b/sw/host/hsmtool/src/commands/spx/import.rs @@ -48,7 +48,7 @@ impl Dispatch for Import { )?; Ok(Box::new(BasicResult { success: true, - id: AttrData::Str(key.hash.expect("key hash")), + id: key.hash.map_or(AttrData::None, AttrData::Str), label: AttrData::Str(key.alias), value: None, error: None,