From 7a82cafb8af860bb8c9aadbec5c44bce5d2e55ac Mon Sep 17 00:00:00 2001 From: Qi Feng Huo Date: Wed, 29 May 2024 08:55:23 +0800 Subject: [PATCH] Merge branch 'main' into s390x-verifier fix Signed-off-by: Qi Feng Huo --- .../attestation-service/src/bin/grpc/mod.rs | 6 ++-- attestation-service/verifier/src/se/ibmse.rs | 10 +++---- attestation-service/verifier/src/se/mod.rs | 6 ++-- kbs/src/api/src/attestation/coco/grpc.rs | 28 ++++++++++--------- 4 files changed, 26 insertions(+), 24 deletions(-) diff --git a/attestation-service/attestation-service/src/bin/grpc/mod.rs b/attestation-service/attestation-service/src/bin/grpc/mod.rs index 0425a6006..c13d17f04 100644 --- a/attestation-service/attestation-service/src/bin/grpc/mod.rs +++ b/attestation-service/attestation-service/src/bin/grpc/mod.rs @@ -15,8 +15,10 @@ use tonic::transport::Server; use tonic::{Request, Response, Status}; use crate::as_api::attestation_service_server::{AttestationService, AttestationServiceServer}; -use crate::as_api::{AttestationRequest, AttestationResponse, ChallengeRequest, ChallengeResponse, SetPolicyRequest, - SetPolicyResponse}; +use crate::as_api::{ + AttestationRequest, AttestationResponse, ChallengeRequest, ChallengeResponse, SetPolicyRequest, + SetPolicyResponse, +}; use crate::rvps_api::reference_value_provider_service_server::{ ReferenceValueProviderService, ReferenceValueProviderServiceServer, diff --git a/attestation-service/verifier/src/se/ibmse.rs b/attestation-service/verifier/src/se/ibmse.rs index 54854aedc..c294b4dcb 100644 --- a/attestation-service/verifier/src/se/ibmse.rs +++ b/attestation-service/verifier/src/se/ibmse.rs @@ -91,7 +91,7 @@ impl SeAttestationRequest { Ok(serde_json::from_slice(request).unwrap()) } - pub fn from_str(request: &str) -> Result { + pub fn from_string(request: &str) -> Result { Ok(serde_json::from_str(request).unwrap()) } @@ -176,7 +176,7 @@ impl SeAttestationResponse { Ok(serde_json::from_slice(response).unwrap()) } - pub fn from_str(request: &str) -> Result { + pub fn from_string(request: &str) -> Result { Ok(serde_json::from_str(request).unwrap()) } @@ -241,8 +241,8 @@ impl SeAttestationResponse { return Err(anyhow!("Failed to verify the measurement!")); } - let userdata = serde_json::from_slice(&self.user_data)?; - debug!("user_data: {:?}", userdata); + // let userdata = serde_json::from_slice(&self.user_data)?; + // debug!("user_data: {:?}", userdata); // TODO check UserData.image_btph with previous saved value let mut att_flags = AttestationFlags::default(); @@ -309,7 +309,7 @@ pub fn verify(response: &[u8], priv_key_file: &str) -> Result GrpcTee { +fn to_grpc_tee(tee: Tee) -> Option { match tee { - Tee::AzSnpVtpm => GrpcTee::AzSnpVtpm, - Tee::AzTdxVtpm => GrpcTee::AzTdxVtpm, - Tee::Cca => GrpcTee::Cca, - Tee::Csv => GrpcTee::Csv, - Tee::Sample => GrpcTee::Sample, - Tee::Sev => GrpcTee::Sev, - Tee::Sgx => GrpcTee::Sgx, - Tee::Snp => GrpcTee::Snp, - Tee::Tdx => GrpcTee::Tdx, - Tee::Se => GrpcTee::Se, + Tee::AzSnpVtpm => Some(String::from("azsnpvtpm")), + Tee::AzTdxVtpm => Some(String::from("aztdxvtpm")), + Tee::Cca => Some(String::from("cca")), + Tee::Csv => Some(String::from("csv")), + Tee::Sample => Some(String::from("sample")), + Tee::Sev => Some(String::from("sev")), + Tee::Sgx => Some(String::from("sgx")), + Tee::Snp => Some(String::from("snp")), + Tee::Tdx => Some(String::from("tdx")), + Tee::Se => Some(String::from("se")), + _ => None, } } @@ -139,8 +140,9 @@ impl Attest for GrpcClientPool { tee: Tee, tee_parameters: String, ) -> Result { + let grpc_tee = to_grpc_tee(tee).unwrap(); let req = tonic::Request::new(ChallengeRequest { - tee: to_grpc_tee(tee).into(), + tee: grpc_tee, tee_params: tee_parameters, });