This commit is contained in:
Ajinkya Kulkarni 2024-12-04 20:35:48 +01:00
parent 84dac5a47e
commit 23e085b70d

View file

@ -64,7 +64,7 @@ async fn upsert_tcbinfo() -> Result<(), &'static str> {
for fmspc in fmspc_list { for fmspc in fmspc_list {
let tcbinfo = get_tcbinfo(fmspc.clone(), "standard".to_string()).await; let tcbinfo = get_tcbinfo(fmspc.clone(), "standard".to_string()).await;
verify_signature(tcbinfo.clone(), key); assert!(verify_signature(tcbinfo.clone(), key));
let store_entry = &store[&fmspc]; let store_entry = &store[&fmspc];
if *store_entry != tcbinfo { if *store_entry != tcbinfo {
println!("updating local TCBInfo for FMSPC: {fmspc}"); println!("updating local TCBInfo for FMSPC: {fmspc}");
@ -97,14 +97,16 @@ async fn upsert_tcbinfo() -> Result<(), &'static str> {
// } // }
} }
fn verify_signature (tcbinfo: Value, key: VerifyingKey) { fn verify_signature (tcbinfo: Value, key: VerifyingKey) -> bool {
let tcbinfo_str = tcbinfo.as_str(); let tcbinfo_str = tcbinfo.as_str();
if let Some(st) = tcbinfo_str { if let Some(st) = tcbinfo_str {
let signed_tcbinfo = SignedTcbInfo::try_from(st).expect("tcbinfo string parsing failed"); let signed_tcbinfo = SignedTcbInfo::try_from(st).expect("tcbinfo string parsing failed");
signed_tcbinfo.verify(Some(&key), None).expect("could not verify signature"); signed_tcbinfo.verify(Some(&key), None).expect("could not verify signature");
true
} }
else { else {
println!("{tcbinfo:?}"); println!("{tcbinfo:?}");
false
} }
} }