[dice] Pass DICE data to process_request API in service VM
Bug: 287233786
Test: atest rialto_test
Change-Id: I673195a0fd42d8518d5dc4ab28f4112e6f688aea
diff --git a/rialto/src/requests/api.rs b/rialto/src/requests/api.rs
index 5ea0106..59a7aed 100644
--- a/rialto/src/requests/api.rs
+++ b/rialto/src/requests/api.rs
@@ -17,18 +17,21 @@
use super::rkp;
use crate::error::Result;
use alloc::vec::Vec;
+use diced_open_dice::DiceArtifacts;
use service_vm_comm::{Request, Response};
/// Processes a request and returns the corresponding response.
/// This function serves as the entry point for the request processing
/// module.
-pub fn process_request(request: Request) -> Result<Response> {
+pub fn process_request(request: Request, dice_artifacts: &dyn DiceArtifacts) -> Result<Response> {
let response = match request {
Request::Reverse(v) => Response::Reverse(reverse(v)),
- Request::GenerateEcdsaP256KeyPair => rkp::generate_ecdsa_p256_key_pair()
+ Request::GenerateEcdsaP256KeyPair => rkp::generate_ecdsa_p256_key_pair(dice_artifacts)
.map_or_else(Response::Err, Response::GenerateEcdsaP256KeyPair),
- Request::GenerateCertificateRequest(p) => rkp::generate_certificate_request(p)
- .map_or_else(Response::Err, Response::GenerateCertificateRequest),
+ Request::GenerateCertificateRequest(p) => {
+ rkp::generate_certificate_request(p, dice_artifacts)
+ .map_or_else(Response::Err, Response::GenerateCertificateRequest)
+ }
};
Ok(response)
}
diff --git a/rialto/src/requests/rkp.rs b/rialto/src/requests/rkp.rs
index d74bb43..a73b9f4 100644
--- a/rialto/src/requests/rkp.rs
+++ b/rialto/src/requests/rkp.rs
@@ -17,11 +17,14 @@
use alloc::vec::Vec;
use core::result;
+use diced_open_dice::DiceArtifacts;
use service_vm_comm::{EcdsaP256KeyPair, GenerateCertificateRequestParams, RequestProcessingError};
type Result<T> = result::Result<T, RequestProcessingError>;
-pub(super) fn generate_ecdsa_p256_key_pair() -> Result<EcdsaP256KeyPair> {
+pub(super) fn generate_ecdsa_p256_key_pair(
+ _dice_artifacts: &dyn DiceArtifacts,
+) -> Result<EcdsaP256KeyPair> {
// TODO(b/299055662): Generate the key pair.
let key_pair = EcdsaP256KeyPair { maced_public_key: Vec::new(), key_blob: Vec::new() };
Ok(key_pair)
@@ -29,6 +32,7 @@
pub(super) fn generate_certificate_request(
_params: GenerateCertificateRequestParams,
+ _dice_artifacts: &dyn DiceArtifacts,
) -> Result<Vec<u8>> {
// TODO(b/299256925): Generate the certificate request
Ok(Vec::new())