[bssl] Add no_std compatible BoringSSL wrapper library for AVF
Bug: 301068421
Test: atest rialto_test
Change-Id: I8af77d457f7a956b0bc88ba4a0498483651426b0
diff --git a/service_vm/comm/Android.bp b/service_vm/comm/Android.bp
index a7481e5..3a18052 100644
--- a/service_vm/comm/Android.bp
+++ b/service_vm/comm/Android.bp
@@ -21,6 +21,7 @@
"libcore.rust_sysroot",
],
rustlibs: [
+ "libbssl_avf_error_nostd",
"libciborium_nostd",
"libcoset_nostd",
"liblog_rust_nostd",
@@ -32,6 +33,7 @@
name: "libservice_vm_comm",
defaults: ["libservice_vm_comm_defaults"],
rustlibs: [
+ "libbssl_avf_error",
"libciborium",
"libcoset",
"liblog_rust",
diff --git a/service_vm/comm/src/lib.rs b/service_vm/comm/src/lib.rs
index 7bcb9cd..d8f7bd7 100644
--- a/service_vm/comm/src/lib.rs
+++ b/service_vm/comm/src/lib.rs
@@ -23,7 +23,7 @@
mod vsock;
pub use message::{
- BoringSSLApiName, EcdsaP256KeyPair, GenerateCertificateRequestParams, Request,
- RequestProcessingError, Response, ServiceVmRequest,
+ EcdsaP256KeyPair, GenerateCertificateRequestParams, Request, RequestProcessingError, Response,
+ ServiceVmRequest,
};
pub use vsock::VmType;
diff --git a/service_vm/comm/src/message.rs b/service_vm/comm/src/message.rs
index 570cf38..443c285 100644
--- a/service_vm/comm/src/message.rs
+++ b/service_vm/comm/src/message.rs
@@ -70,31 +70,11 @@
Err(RequestProcessingError),
}
-/// BoringSSL API names.
-#[allow(missing_docs)]
-#[allow(non_camel_case_types)]
-#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
-pub enum BoringSSLApiName {
- BN_new,
- BN_bn2bin_padded,
- CBB_flush,
- CBB_len,
- EC_KEY_check_key,
- EC_KEY_generate_key,
- EC_KEY_get0_group,
- EC_KEY_get0_public_key,
- EC_KEY_marshal_private_key,
- EC_KEY_new_by_curve_name,
- EC_POINT_get_affine_coordinates,
- EVP_sha256,
- HMAC,
-}
-
/// Errors related to request processing.
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub enum RequestProcessingError {
- /// Failed to invoke a BoringSSL API.
- BoringSSLCallFailed(BoringSSLApiName),
+ /// An error happened during the interaction with BoringSSL.
+ BoringSslError(bssl_avf_error::Error),
/// An error happened during the interaction with coset.
CosetError,
@@ -112,8 +92,8 @@
impl fmt::Display for RequestProcessingError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self {
- Self::BoringSSLCallFailed(api_name) => {
- write!(f, "Failed to invoke a BoringSSL API: {api_name:?}")
+ Self::BoringSslError(e) => {
+ write!(f, "An error happened during the interaction with BoringSSL: {e}")
}
Self::CosetError => write!(f, "Encountered an error with coset"),
Self::InvalidMac => write!(f, "A key to sign lacks a valid MAC."),
@@ -125,6 +105,12 @@
}
}
+impl From<bssl_avf_error::Error> for RequestProcessingError {
+ fn from(e: bssl_avf_error::Error) -> Self {
+ Self::BoringSslError(e)
+ }
+}
+
impl From<coset::CoseError> for RequestProcessingError {
fn from(e: coset::CoseError) -> Self {
error!("Coset error: {e}");