From 91769c011466910b2b4e9c6bc663f4cd944b535c Mon Sep 17 00:00:00 2001 From: Ajinkya Kulkarni Date: Wed, 4 Dec 2024 20:48:38 +0100 Subject: [PATCH] changed type of tcbinfo --- crates/utils/tcbinfo-updater/src/main.rs | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/crates/utils/tcbinfo-updater/src/main.rs b/crates/utils/tcbinfo-updater/src/main.rs index 8fca88e..ca907cd 100644 --- a/crates/utils/tcbinfo-updater/src/main.rs +++ b/crates/utils/tcbinfo-updater/src/main.rs @@ -9,14 +9,14 @@ use std::fs; use cw_client::{CliClient, CwClient}; use reqwest::Url; use quartz_tcbinfo_msgs::ExecuteMsg; -type TcbInfo = Value; +type TcbInfo = String; type Fmspc = String; type Update = String; const TCB_SIGNER: &str = include_str!("../tcb_signer.pem"); -async fn get_tcbinfo(fmspc: Fmspc, update: Update) -> Value { +async fn get_tcbinfo(fmspc: Fmspc, update: Update) -> String { let url = format!("https://api.trustedservices.intel.com/sgx/certification/v4/tcb?fmspc={fmspc}&update={update}"); let body: String = reqwest::get(url) .await @@ -25,8 +25,7 @@ async fn get_tcbinfo(fmspc: Fmspc, update: Update) -> Value { .await .expect("could not read https response"); println!("{body}"); - let tcbinfo: Value = serde_json::from_str(&body).expect("could not convert to JSON"); - tcbinfo + body } async fn get_fmspc_list() -> Vec { @@ -98,18 +97,11 @@ async fn upsert_tcbinfo() -> Result<(), &'static str> { // } } -fn verify_signature (tcbinfo: Value, key: VerifyingKey) -> bool { - let tcbinfo_str = tcbinfo.as_str(); - if let Some(st) = tcbinfo_str { - let signed_tcbinfo = SignedTcbInfo::try_from(st).expect("tcbinfo string parsing failed"); +fn verify_signature (tcbinfo: String, key: VerifyingKey) -> bool { + + let signed_tcbinfo = SignedTcbInfo::try_from(tcbinfo.as_ref()).expect("tcbinfo string parsing failed"); signed_tcbinfo.verify(Some(&key), None).expect("could not verify signature"); true - } - else { - println!("{tcbinfo:?}"); - false - } - } #[tokio::main]