From 77fe5f1bffc60591f1fcbe883701be55da8aa9f0 Mon Sep 17 00:00:00 2001 From: Xynnn007 Date: Mon, 6 Jan 2025 15:40:51 +0800 Subject: [PATCH] cdh/kms: cckbc use AA to get evidence rather than token When we use one AA and multiple CDH to connect to KBSes in one confidential VM, AATokenProvider requires the KBS be the same. If we use AAEvidenceProvider, the different target KBS address can be specified in CDH's config and share a same AA. This will also make the workflow simpler. Before this commit, if we want to get a confidential resource from KBS, AA should connect to a KBS to get a token. Then CDH get the token from AA. Then CDH access the KBS. After this commit, only CDH will access the KBS. This change will require the KBS that does RCAR and stores resource be the same in CoCo, s.t. background check model. which is up to now nearly all the deployments we have met. This will not break the passport model because kbs_protocol crate still provides a way for developers to integrate either passport model or background check model in their own code. Signed-off-by: Xynnn007 --- confidential-data-hub/hub/Cargo.toml | 2 +- .../hub/src/kms/plugins/kbs/cc_kbc.rs | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/confidential-data-hub/hub/Cargo.toml b/confidential-data-hub/hub/Cargo.toml index a36a569f8..36da2231a 100644 --- a/confidential-data-hub/hub/Cargo.toml +++ b/confidential-data-hub/hub/Cargo.toml @@ -50,7 +50,7 @@ image-rs = { path = "../../image-rs", default-features = false, features = [ "kata-cc-rustls-tls", ] } kbs_protocol = { path = "../../attestation-agent/kbs_protocol", default-features = false, features = [ - "passport", + "background_check", "aa_ttrpc", "openssl", ], optional = true } diff --git a/confidential-data-hub/hub/src/kms/plugins/kbs/cc_kbc.rs b/confidential-data-hub/hub/src/kms/plugins/kbs/cc_kbc.rs index 2e8e77052..535befe19 100644 --- a/confidential-data-hub/hub/src/kms/plugins/kbs/cc_kbc.rs +++ b/confidential-data-hub/hub/src/kms/plugins/kbs/cc_kbc.rs @@ -8,7 +8,7 @@ use std::env; use async_trait::async_trait; use kbs_protocol::{ client::KbsClient as KbsProtocolClient, - token_provider::{AATokenProvider, TokenProvider}, + evidence_provider::{AAEvidenceProvider, EvidenceProvider}, KbsClientCapabilities, ResourceUri, }; use log::{info, warn}; @@ -18,16 +18,16 @@ use super::{Error, Result}; use super::Kbc; pub struct CcKbc { - client: KbsProtocolClient>, + client: KbsProtocolClient>, } impl CcKbc { pub async fn new(kbs_host_url: &str) -> Result { - let token_provider = AATokenProvider::new().await.map_err(|e| { - Error::KbsClientError(format!("create AA token provider failed: {e:?}")) + let evidence_provider = AAEvidenceProvider::new().await.map_err(|e| { + Error::KbsClientError(format!("create AA evidence provider failed: {e:?}")) })?; - let client = kbs_protocol::KbsClientBuilder::with_token_provider( - Box::new(token_provider), + let client = kbs_protocol::KbsClientBuilder::with_evidence_provider( + Box::new(evidence_provider), kbs_host_url, );