1 /* 2 * Copyright (C) 2024 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 //! VTS test library for HwCrypto functionality. 18 //! It provides the base clases necessaries to write HwCrypto VTS tests 19 20 use anyhow::Result; 21 use android_hardware_security_see_hwcrypto::aidl::android::hardware::security::see::hwcrypto::IHwCryptoKey::IHwCryptoKey; 22 23 pub const HWCRYPTO_SERVICE: &str = "android.hardware.security.see.hwcrypto.IHwCryptoKey"; 24 25 /// Get a HwCryptoKey binder service object using the service manager get_hwcryptokey() -> Result<binder::Strong<dyn IHwCryptoKey>, binder::Status>26pub fn get_hwcryptokey() -> Result<binder::Strong<dyn IHwCryptoKey>, binder::Status> { 27 let interface_name = HWCRYPTO_SERVICE.to_owned() + "/default"; 28 Ok(binder::get_interface(&interface_name)?) 29 } 30 get_supported_instances() -> Vec<(String, String)>31pub fn get_supported_instances() -> Vec<(String, String)> { 32 // Determine which instances are available. 33 binder::get_declared_instances(HWCRYPTO_SERVICE) 34 .unwrap_or_default() 35 .into_iter() 36 .map(|v| (v.clone(), v)) 37 .collect() 38 } 39 ignore_test() -> bool40pub fn ignore_test() -> bool { 41 let instances = get_supported_instances(); 42 instances.len() == 0 43 } 44