From f2117ff77cbf4bbe6ff44b51187a907d5c8f50e7 Mon Sep 17 00:00:00 2001 From: David Drysdale Date: Fri, 3 Nov 2023 12:18:24 +0000 Subject: [PATCH] AuthGraph: reduce dependency on authgraph_core The authgraph_hal library should only depend on libauthgraph_wire, not on libauthgraph_core, so adjust error processing accordingly. Test: VtsAidlAuthGraphSessionTest Bug: 284470121 Change-Id: I48056db6ceeab409d0f165f8e051809129643c6f --- security/authgraph/default/Android.bp | 1 + security/authgraph/default/src/main.rs | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/security/authgraph/default/Android.bp b/security/authgraph/default/Android.bp index 9de3bc11da..c0f2106c3e 100644 --- a/security/authgraph/default/Android.bp +++ b/security/authgraph/default/Android.bp @@ -36,6 +36,7 @@ rust_binary { "libauthgraph_core", "libauthgraph_boringssl", "libauthgraph_hal", + "libauthgraph_wire", "libbinder_rs", "liblibc", "liblog_rust", diff --git a/security/authgraph/default/src/main.rs b/security/authgraph/default/src/main.rs index 2112e58176..dc4a8e41fd 100644 --- a/security/authgraph/default/src/main.rs +++ b/security/authgraph/default/src/main.rs @@ -30,7 +30,7 @@ use android_hardware_security_authgraph::aidl::android::hardware::security::auth }; use authgraph_boringssl as boring; use authgraph_core::{key::MillisecondsSinceEpoch, keyexchange as ke, traits}; -use authgraph_hal::{err_to_binder, Innto, TryInnto}; +use authgraph_hal::{errcode_to_binder, Innto, TryInnto}; use log::{error, info}; use std::ffi::CString; use std::sync::Mutex; @@ -130,6 +130,13 @@ fn unsigned_pub_key(pub_key: &PubKey) -> binder::Result<&[u8]> { } } +fn err_to_binder(err: authgraph_core::error::Error) -> binder::Status { + if err.0 != authgraph_wire::ErrorCode::Ok && !err.1.is_empty() { + error!("failure {:?} message: '{}'", err.0, err.1); + } + errcode_to_binder(err.0) +} + /// This nonsecure implementation of the AuthGraph HAL interface directly calls the AuthGraph /// reference implementation library code; a real implementation requires the AuthGraph /// code to run in a secure environment, not within Android.