Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b4158e25 authored by Arve Hjønnevåg's avatar Arve Hjønnevåg Committed by Alice Wang
Browse files

trusty: keymint: Add commandline option to specify device name

Bug: 300338484
Test: VtsAidlKeyMintTargetTest (emulator subset)
Change-Id: Ibaa89dd0a3db65565101c0a37303c7155f999fb7
parent 31154a9e
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -24,11 +24,12 @@ rust_binary {
    init_rc: ["android.hardware.security.keymint-service.rust.trusty.rc"],
    vintf_fragments: ["android.hardware.security.keymint-service.rust.trusty.xml"],
    srcs: [
        "src/keymint_hal_main.rs"
        "src/keymint_hal_main.rs",
    ],
    rustlibs: [
        "libandroid_logger",
        "libbinder_rs",
        "libclap",
        "libkmr_wire",
        "libkmr_hal",
        "libtrusty-rs",
+18 −4
Original line number Diff line number Diff line
@@ -14,6 +14,7 @@
// limitations under the License.

//! This module implements the HAL service for Keymint (Rust) in Trusty.
use clap::Parser;
use kmr_hal::{
    extract_rsp, keymint, rpc, secureclock, send_hal_info, sharedsecret, SerializedChannel,
};
@@ -81,6 +82,13 @@ impl SerializedChannel for TipcChannel {
    }
}

#[derive(Parser, Debug)]
struct Args {
    /// Tipc device path
    #[arg(short, long, default_value_t = DEFAULT_DEVICE.to_string())]
    dev: String,
}

fn main() {
    if let Err(HalServiceError(e)) = inner_main() {
        panic!("HAL service failed: {:?}", e);
@@ -88,6 +96,7 @@ fn main() {
}

fn inner_main() -> Result<(), HalServiceError> {
    let args = Args::parse();
    // Initialize Android logging.
    android_logger::init_once(
        android_logger::Config::default()
@@ -106,10 +115,15 @@ fn inner_main() -> Result<(), HalServiceError> {
    binder::ProcessState::start_thread_pool();

    // Create connection to the TA
    let connection = trusty::TipcChannel::connect(DEFAULT_DEVICE, TRUSTY_KEYMINT_RUST_SERVICE_NAME)
        .map_err(|e| {
            HalServiceError(format!("Failed to connect to Trusty Keymint TA because of {:?}.", e))
        })?;
    let connection =
        trusty::TipcChannel::connect(args.dev.as_str(), TRUSTY_KEYMINT_RUST_SERVICE_NAME).map_err(
            |e| {
                HalServiceError(format!(
                    "Failed to connect to Trusty Keymint TA at {} because of {:?}.",
                    args.dev, e
                ))
            },
        )?;
    let tipc_channel = Arc::new(Mutex::new(TipcChannel(connection)));

    // Register the Keymint service