Skip to content

Commit 58fb82b

Browse files
committed
fix: use prehashed signature verification for SPDM v1.1
Signed-off-by: leongross <leon.gross@9elements.com>
1 parent 2766d12 commit 58fb82b

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

examples/spdm_requester.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -616,6 +616,7 @@ fn verify_challenge_auth_signature(
616616
signature: Signature,
617617
config: &RequesterConfig,
618618
) -> bool {
619+
use p384::ecdsa::signature::hazmat::PrehashVerifier;
619620
use signature::Verifier;
620621

621622
let mut sig_combined_context = Vec::new();
@@ -646,13 +647,11 @@ fn verify_challenge_auth_signature(
646647
// M denotes the message that is signed. M shall be the concatenation of the combined_spdm_prefix and unverified_message_hash.
647648
let m = [sig_combined_context.as_slice(), &transcript_hash].concat();
648649

649-
let res = pubkey.verify(&m, &signature);
650-
if config.verbose {
651-
if let Err(e) = &res {
652-
println!("Signature verify error: {e}");
653-
}
650+
if ctx.connection_info().version_number() >= SpdmVersion::V12 {
651+
pubkey.verify(&m, &signature).is_ok()
652+
} else {
653+
pubkey.verify_prehash(&m, &signature).is_ok()
654654
}
655-
res.is_ok()
656655
}
657656

658657
#[derive(Debug)]

0 commit comments

Comments
 (0)