blob: 71f43d6a1c2169bc0fe696f986ddda62c38903f1 [file] [log] [blame]
Hasini Gunasingheda895552021-01-27 19:34:37 +00001// Copyright 2021, The Android Open Source Project
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
Janis Danisevskis34a0cf22021-03-08 09:19:03 -080015//! This module implements IKeystoreMaintenance AIDL interface.
Hasini Gunasingheda895552021-01-27 19:34:37 +000016
Janis Danisevskiscdcf4e52021-04-14 15:44:36 -070017use crate::database::{KeyEntryLoadBits, KeyType, MonotonicRawTime};
Satya Tangirala5b9e5b12021-03-09 12:54:21 -080018use crate::error::map_km_error;
Janis Danisevskiscdcf4e52021-04-14 15:44:36 -070019use crate::error::map_or_log_err;
20use crate::error::Error;
Satya Tangirala5b9e5b12021-03-09 12:54:21 -080021use crate::globals::get_keymint_device;
Janis Danisevskis0ffb8a82022-02-06 22:37:21 -080022use crate::globals::{DB, LEGACY_IMPORTER, SUPER_KEY};
Janis Danisevskiscdcf4e52021-04-14 15:44:36 -070023use crate::permission::{KeyPerm, KeystorePerm};
Janis Danisevskis0fd25a62022-01-04 19:53:37 -080024use crate::super_key::{SuperKeyManager, UserState};
John Wu16db29e2022-01-13 15:21:43 -080025use crate::utils::{
26 check_key_permission, check_keystore_permission, list_key_entries, watchdog as wd,
27};
Paul Crowley46c703e2021-08-06 15:13:53 -070028use android_hardware_security_keymint::aidl::android::hardware::security::keymint::{
29 IKeyMintDevice::IKeyMintDevice, SecurityLevel::SecurityLevel,
30};
Hasini Gunasinghe9ee18412021-03-11 20:12:44 +000031use android_security_maintenance::aidl::android::security::maintenance::{
John Wu16db29e2022-01-13 15:21:43 -080032 IKeystoreMaintenance::{BnKeystoreMaintenance, IKeystoreMaintenance, UID_SELF},
Hasini Gunasinghe9ee18412021-03-11 20:12:44 +000033 UserState::UserState as AidlUserState,
Hasini Gunasingheda895552021-01-27 19:34:37 +000034};
Andrew Walbrande45c8b2021-04-13 14:42:38 +000035use android_security_maintenance::binder::{
36 BinderFeatures, Interface, Result as BinderResult, Strong, ThreadState,
37};
Janis Danisevskis5898d152021-06-15 08:23:46 -070038use android_system_keystore2::aidl::android::system::keystore2::KeyDescriptor::KeyDescriptor;
Hasini Gunasingheda895552021-01-27 19:34:37 +000039use android_system_keystore2::aidl::android::system::keystore2::ResponseCode::ResponseCode;
40use anyhow::{Context, Result};
Paul Crowleyf61fee72021-03-17 14:38:44 -070041use keystore2_crypto::Password;
John Wu16db29e2022-01-13 15:21:43 -080042use keystore2_selinux as selinux;
Hasini Gunasingheda895552021-01-27 19:34:37 +000043
Janis Danisevskis5898d152021-06-15 08:23:46 -070044/// Reexport Domain for the benefit of DeleteListener
45pub use android_system_keystore2::aidl::android::system::keystore2::Domain::Domain;
46
47/// The Maintenance module takes a delete listener argument which observes user and namespace
48/// deletion events.
49pub trait DeleteListener {
50 /// Called by the maintenance module when an app/namespace is deleted.
51 fn delete_namespace(&self, domain: Domain, namespace: i64) -> Result<()>;
52 /// Called by the maintenance module when a user is deleted.
53 fn delete_user(&self, user_id: u32) -> Result<()>;
54}
55
Hasini Gunasingheda895552021-01-27 19:34:37 +000056/// This struct is defined to implement the aforementioned AIDL interface.
Janis Danisevskis5898d152021-06-15 08:23:46 -070057pub struct Maintenance {
58 delete_listener: Box<dyn DeleteListener + Send + Sync + 'static>,
59}
Hasini Gunasingheda895552021-01-27 19:34:37 +000060
Janis Danisevskis34a0cf22021-03-08 09:19:03 -080061impl Maintenance {
Janis Danisevskis5898d152021-06-15 08:23:46 -070062 /// Create a new instance of Keystore Maintenance service.
63 pub fn new_native_binder(
64 delete_listener: Box<dyn DeleteListener + Send + Sync + 'static>,
65 ) -> Result<Strong<dyn IKeystoreMaintenance>> {
Andrew Walbrande45c8b2021-04-13 14:42:38 +000066 Ok(BnKeystoreMaintenance::new_binder(
Janis Danisevskis5898d152021-06-15 08:23:46 -070067 Self { delete_listener },
Andrew Walbrande45c8b2021-04-13 14:42:38 +000068 BinderFeatures { set_requesting_sid: true, ..BinderFeatures::default() },
69 ))
Hasini Gunasingheda895552021-01-27 19:34:37 +000070 }
71
Paul Crowleyf61fee72021-03-17 14:38:44 -070072 fn on_user_password_changed(user_id: i32, password: Option<Password>) -> Result<()> {
Janis Danisevskis0fd25a62022-01-04 19:53:37 -080073 // Check permission. Function should return if this failed. Therefore having '?' at the end
74 // is very important.
Janis Danisevskisa916d992021-10-19 15:46:09 -070075 check_keystore_permission(KeystorePerm::ChangePassword)
Hasini Gunasingheda895552021-01-27 19:34:37 +000076 .context("In on_user_password_changed.")?;
77
Janis Danisevskis0fd25a62022-01-04 19:53:37 -080078 let mut skm = SUPER_KEY.write().unwrap();
79
Paul Crowley7a658392021-03-18 17:08:20 -070080 if let Some(pw) = password.as_ref() {
81 DB.with(|db| {
Janis Danisevskis0fd25a62022-01-04 19:53:37 -080082 skm.unlock_screen_lock_bound_key(&mut db.borrow_mut(), user_id as u32, pw)
Paul Crowley7a658392021-03-18 17:08:20 -070083 })
Paul Crowley8d5b2532021-03-19 10:53:07 -070084 .context("In on_user_password_changed: unlock_screen_lock_bound_key failed")?;
Paul Crowley7a658392021-03-18 17:08:20 -070085 }
86
Hasini Gunasingheda895552021-01-27 19:34:37 +000087 match DB
88 .with(|db| {
Janis Danisevskis0fd25a62022-01-04 19:53:37 -080089 skm.reset_or_init_user_and_get_user_state(
Hasini Gunasingheda895552021-01-27 19:34:37 +000090 &mut db.borrow_mut(),
Janis Danisevskis0ffb8a82022-02-06 22:37:21 -080091 &LEGACY_IMPORTER,
Hasini Gunasingheda895552021-01-27 19:34:37 +000092 user_id as u32,
Paul Crowleyf61fee72021-03-17 14:38:44 -070093 password.as_ref(),
Hasini Gunasingheda895552021-01-27 19:34:37 +000094 )
95 })
96 .context("In on_user_password_changed.")?
97 {
98 UserState::LskfLocked => {
Janis Danisevskiseed69842021-02-18 20:04:10 -080099 // Error - password can not be changed when the device is locked
Janis Danisevskiscdcf4e52021-04-14 15:44:36 -0700100 Err(Error::Rc(ResponseCode::LOCKED))
Hasini Gunasingheda895552021-01-27 19:34:37 +0000101 .context("In on_user_password_changed. Device is locked.")
102 }
103 _ => {
Janis Danisevskiseed69842021-02-18 20:04:10 -0800104 // LskfLocked is the only error case for password change
Hasini Gunasingheda895552021-01-27 19:34:37 +0000105 Ok(())
106 }
107 }
108 }
109
Janis Danisevskis5898d152021-06-15 08:23:46 -0700110 fn add_or_remove_user(&self, user_id: i32) -> Result<()> {
Hasini Gunasingheda895552021-01-27 19:34:37 +0000111 // Check permission. Function should return if this failed. Therefore having '?' at the end
112 // is very important.
Janis Danisevskisa916d992021-10-19 15:46:09 -0700113 check_keystore_permission(KeystorePerm::ChangeUser).context("In add_or_remove_user.")?;
Janis Danisevskis0fd25a62022-01-04 19:53:37 -0800114
Janis Danisevskiseed69842021-02-18 20:04:10 -0800115 DB.with(|db| {
Janis Danisevskis0fd25a62022-01-04 19:53:37 -0800116 SUPER_KEY.write().unwrap().reset_user(
Janis Danisevskiseed69842021-02-18 20:04:10 -0800117 &mut db.borrow_mut(),
Janis Danisevskis0ffb8a82022-02-06 22:37:21 -0800118 &LEGACY_IMPORTER,
Janis Danisevskiseed69842021-02-18 20:04:10 -0800119 user_id as u32,
120 false,
121 )
122 })
Janis Danisevskis5898d152021-06-15 08:23:46 -0700123 .context("In add_or_remove_user: Trying to delete keys from db.")?;
124 self.delete_listener
125 .delete_user(user_id as u32)
126 .context("In add_or_remove_user: While invoking the delete listener.")
Hasini Gunasingheda895552021-01-27 19:34:37 +0000127 }
Janis Danisevskisddd6e752021-02-22 18:46:55 -0800128
Janis Danisevskis5898d152021-06-15 08:23:46 -0700129 fn clear_namespace(&self, domain: Domain, nspace: i64) -> Result<()> {
Janis Danisevskisddd6e752021-02-22 18:46:55 -0800130 // Permission check. Must return on error. Do not touch the '?'.
Janis Danisevskisa916d992021-10-19 15:46:09 -0700131 check_keystore_permission(KeystorePerm::ClearUID).context("In clear_namespace.")?;
Janis Danisevskisddd6e752021-02-22 18:46:55 -0800132
Janis Danisevskis0ffb8a82022-02-06 22:37:21 -0800133 LEGACY_IMPORTER
Janis Danisevskisddd6e752021-02-22 18:46:55 -0800134 .bulk_delete_uid(domain, nspace)
135 .context("In clear_namespace: Trying to delete legacy keys.")?;
136 DB.with(|db| db.borrow_mut().unbind_keys_for_namespace(domain, nspace))
Janis Danisevskis5898d152021-06-15 08:23:46 -0700137 .context("In clear_namespace: Trying to delete keys from db.")?;
138 self.delete_listener
139 .delete_namespace(domain, nspace)
140 .context("In clear_namespace: While invoking the delete listener.")
Janis Danisevskisddd6e752021-02-22 18:46:55 -0800141 }
Hasini Gunasinghe9ee18412021-03-11 20:12:44 +0000142
143 fn get_state(user_id: i32) -> Result<AidlUserState> {
144 // Check permission. Function should return if this failed. Therefore having '?' at the end
145 // is very important.
Janis Danisevskisa916d992021-10-19 15:46:09 -0700146 check_keystore_permission(KeystorePerm::GetState).context("In get_state.")?;
Hasini Gunasinghe9ee18412021-03-11 20:12:44 +0000147 let state = DB
148 .with(|db| {
Janis Danisevskis0fd25a62022-01-04 19:53:37 -0800149 SUPER_KEY.read().unwrap().get_user_state(
150 &mut db.borrow_mut(),
Janis Danisevskis0ffb8a82022-02-06 22:37:21 -0800151 &LEGACY_IMPORTER,
Janis Danisevskis0fd25a62022-01-04 19:53:37 -0800152 user_id as u32,
153 )
Hasini Gunasinghe9ee18412021-03-11 20:12:44 +0000154 })
155 .context("In get_state. Trying to get UserState.")?;
156
157 match state {
158 UserState::Uninitialized => Ok(AidlUserState::UNINITIALIZED),
159 UserState::LskfUnlocked(_) => Ok(AidlUserState::LSKF_UNLOCKED),
160 UserState::LskfLocked => Ok(AidlUserState::LSKF_LOCKED),
161 }
162 }
Janis Danisevskis333b7c02021-03-23 18:57:41 -0700163
Paul Crowley46c703e2021-08-06 15:13:53 -0700164 fn call_with_watchdog<F>(sec_level: SecurityLevel, name: &'static str, op: &F) -> Result<()>
165 where
Stephen Crane23cf7242022-01-19 17:49:46 +0000166 F: Fn(Strong<dyn IKeyMintDevice>) -> binder::Result<()>,
Paul Crowley46c703e2021-08-06 15:13:53 -0700167 {
Janis Danisevskis5f3a0572021-06-18 11:26:42 -0700168 let (km_dev, _, _) = get_keymint_device(&sec_level)
Paul Crowley46c703e2021-08-06 15:13:53 -0700169 .context("In call_with_watchdog: getting keymint device")?;
Janis Danisevskis2ee014b2021-05-05 14:29:08 -0700170
Paul Crowley46c703e2021-08-06 15:13:53 -0700171 let _wp = wd::watch_millis_with("In call_with_watchdog", 500, move || {
172 format!("Seclevel: {:?} Op: {}", sec_level, name)
173 });
174 map_km_error(op(km_dev)).with_context(|| format!("In keymint device: calling {}", name))?;
Satya Tangirala5b9e5b12021-03-09 12:54:21 -0800175 Ok(())
176 }
177
Paul Crowley46c703e2021-08-06 15:13:53 -0700178 fn call_on_all_security_levels<F>(name: &'static str, op: F) -> Result<()>
179 where
Stephen Crane23cf7242022-01-19 17:49:46 +0000180 F: Fn(Strong<dyn IKeyMintDevice>) -> binder::Result<()>,
Paul Crowley46c703e2021-08-06 15:13:53 -0700181 {
182 let sec_levels = [
183 (SecurityLevel::TRUSTED_ENVIRONMENT, "TRUSTED_ENVIRONMENT"),
184 (SecurityLevel::STRONGBOX, "STRONGBOX"),
185 ];
186 sec_levels.iter().fold(Ok(()), move |result, (sec_level, sec_level_string)| {
187 let curr_result = Maintenance::call_with_watchdog(*sec_level, name, &op);
188 match curr_result {
189 Ok(()) => log::info!(
190 "Call to {} succeeded for security level {}.",
191 name,
192 &sec_level_string
193 ),
194 Err(ref e) => log::error!(
195 "Call to {} failed for security level {}: {}.",
196 name,
197 &sec_level_string,
198 e
199 ),
200 }
201 result.and(curr_result)
202 })
203 }
204
Satya Tangirala5b9e5b12021-03-09 12:54:21 -0800205 fn early_boot_ended() -> Result<()> {
Janis Danisevskisa916d992021-10-19 15:46:09 -0700206 check_keystore_permission(KeystorePerm::EarlyBootEnded)
Satya Tangirala5b9e5b12021-03-09 12:54:21 -0800207 .context("In early_boot_ended. Checking permission")?;
Paul Crowley44c02da2021-04-08 17:04:43 +0000208 log::info!("In early_boot_ended.");
209
Janis Danisevskis0fd25a62022-01-04 19:53:37 -0800210 if let Err(e) =
211 DB.with(|db| SuperKeyManager::set_up_boot_level_cache(&SUPER_KEY, &mut db.borrow_mut()))
212 {
Paul Crowley44c02da2021-04-08 17:04:43 +0000213 log::error!("SUPER_KEY.set_up_boot_level_cache failed:\n{:?}\n:(", e);
214 }
Paul Crowley46c703e2021-08-06 15:13:53 -0700215 Maintenance::call_on_all_security_levels("earlyBootEnded", |dev| dev.earlyBootEnded())
Satya Tangirala5b9e5b12021-03-09 12:54:21 -0800216 }
217
Janis Danisevskis333b7c02021-03-23 18:57:41 -0700218 fn on_device_off_body() -> Result<()> {
219 // Security critical permission check. This statement must return on fail.
Janis Danisevskisa916d992021-10-19 15:46:09 -0700220 check_keystore_permission(KeystorePerm::ReportOffBody).context("In on_device_off_body.")?;
Janis Danisevskis333b7c02021-03-23 18:57:41 -0700221
Matthew Maurerd7815ca2021-05-06 21:58:45 -0700222 DB.with(|db| db.borrow_mut().update_last_off_body(MonotonicRawTime::now()));
223 Ok(())
Janis Danisevskis333b7c02021-03-23 18:57:41 -0700224 }
Janis Danisevskiscdcf4e52021-04-14 15:44:36 -0700225
226 fn migrate_key_namespace(source: &KeyDescriptor, destination: &KeyDescriptor) -> Result<()> {
Ashwini Orugantidaf73bc2021-11-15 10:46:31 -0800227 let migrate_any_key_permission =
228 check_keystore_permission(KeystorePerm::MigrateAnyKey).is_ok();
Janis Danisevskiscdcf4e52021-04-14 15:44:36 -0700229
John Wu16db29e2022-01-13 15:21:43 -0800230 let src_uid = match source.domain {
231 Domain::SELINUX | Domain::KEY_ID => ThreadState::get_calling_uid(),
232 Domain::APP if source.nspace == UID_SELF.into() => ThreadState::get_calling_uid(),
233 Domain::APP if source.nspace != UID_SELF.into() && migrate_any_key_permission => {
234 source.nspace as u32
235 }
236 _ => {
237 return Err(Error::Rc(ResponseCode::INVALID_ARGUMENT)).context(
Janis Danisevskis478a9a22022-01-28 08:22:59 -0800238 "In migrate_key_namespace: \
John Wu16db29e2022-01-13 15:21:43 -0800239 Source domain must be one of APP, SELINUX, or KEY_ID.",
240 )
241 }
242 };
Janis Danisevskiscdcf4e52021-04-14 15:44:36 -0700243
John Wu16db29e2022-01-13 15:21:43 -0800244 let dest_uid = match destination.domain {
245 Domain::SELINUX => ThreadState::get_calling_uid(),
246 Domain::APP if destination.nspace == UID_SELF.into() => ThreadState::get_calling_uid(),
247 Domain::APP if destination.nspace != UID_SELF.into() && migrate_any_key_permission => {
248 destination.nspace as u32
249 }
250 _ => {
251 return Err(Error::Rc(ResponseCode::INVALID_ARGUMENT)).context(
Janis Danisevskis478a9a22022-01-28 08:22:59 -0800252 "In migrate_key_namespace: \
John Wu16db29e2022-01-13 15:21:43 -0800253 Destination domain must be one of APP or SELINUX.",
254 )
255 }
256 };
257
258 DB.with(|db| {
Janis Danisevskis0ffb8a82022-02-06 22:37:21 -0800259 let (key_id_guard, _) = LEGACY_IMPORTER
260 .with_try_import(source, src_uid, || {
John Wu16db29e2022-01-13 15:21:43 -0800261 db.borrow_mut().load_key_entry(
262 source,
263 KeyType::Client,
264 KeyEntryLoadBits::NONE,
265 src_uid,
266 |k, av| {
267 if migrate_any_key_permission {
268 Ok(())
269 } else {
270 check_key_permission(KeyPerm::Use, k, &av)?;
271 check_key_permission(KeyPerm::Delete, k, &av)?;
272 check_key_permission(KeyPerm::Grant, k, &av)
273 }
274 },
275 )
276 })
277 .context("In migrate_key_namespace: Failed to load key blob.")?;
278
279 db.borrow_mut().migrate_key_namespace(key_id_guard, destination, dest_uid, |k| {
280 if migrate_any_key_permission {
281 Ok(())
282 } else {
283 check_key_permission(KeyPerm::Rebind, k, &None)
Ashwini Orugantidaf73bc2021-11-15 10:46:31 -0800284 }
Janis Danisevskiscdcf4e52021-04-14 15:44:36 -0700285 })
286 })
287 }
Paul Crowley46c703e2021-08-06 15:13:53 -0700288
289 fn delete_all_keys() -> Result<()> {
290 // Security critical permission check. This statement must return on fail.
Janis Danisevskisa916d992021-10-19 15:46:09 -0700291 check_keystore_permission(KeystorePerm::DeleteAllKeys)
Paul Crowley46c703e2021-08-06 15:13:53 -0700292 .context("In delete_all_keys. Checking permission")?;
293 log::info!("In delete_all_keys.");
294
295 Maintenance::call_on_all_security_levels("deleteAllKeys", |dev| dev.deleteAllKeys())
296 }
John Wu16db29e2022-01-13 15:21:43 -0800297
298 fn list_entries(domain: Domain, nspace: i64) -> Result<Vec<KeyDescriptor>> {
299 let k = match domain {
300 Domain::APP | Domain::SELINUX => KeyDescriptor{domain, nspace, ..Default::default()},
301 _ => return Err(Error::perm()).context(
302 "In list_entries: List entries is only supported for Domain::APP and Domain::SELINUX."
303 ),
304 };
305
306 // The caller has to have either GetInfo for the namespace or List permission
307 check_key_permission(KeyPerm::GetInfo, &k, &None)
308 .or_else(|e| {
309 if Some(&selinux::Error::PermissionDenied)
310 == e.root_cause().downcast_ref::<selinux::Error>()
311 {
312 check_keystore_permission(KeystorePerm::List)
313 } else {
314 Err(e)
315 }
316 })
317 .context("In list_entries: While checking key and keystore permission.")?;
318
319 DB.with(|db| list_key_entries(&mut db.borrow_mut(), domain, nspace))
320 }
Hasini Gunasingheda895552021-01-27 19:34:37 +0000321}
322
Janis Danisevskis34a0cf22021-03-08 09:19:03 -0800323impl Interface for Maintenance {}
Hasini Gunasingheda895552021-01-27 19:34:37 +0000324
Janis Danisevskis34a0cf22021-03-08 09:19:03 -0800325impl IKeystoreMaintenance for Maintenance {
Hasini Gunasingheda895552021-01-27 19:34:37 +0000326 fn onUserPasswordChanged(&self, user_id: i32, password: Option<&[u8]>) -> BinderResult<()> {
Hasini Gunasinghe5a893e82021-05-05 14:32:32 +0000327 let _wp = wd::watch_millis("IKeystoreMaintenance::onUserPasswordChanged", 500);
Paul Crowleyf61fee72021-03-17 14:38:44 -0700328 map_or_log_err(Self::on_user_password_changed(user_id, password.map(|pw| pw.into())), Ok)
Hasini Gunasingheda895552021-01-27 19:34:37 +0000329 }
330
331 fn onUserAdded(&self, user_id: i32) -> BinderResult<()> {
Hasini Gunasinghe5a893e82021-05-05 14:32:32 +0000332 let _wp = wd::watch_millis("IKeystoreMaintenance::onUserAdded", 500);
Janis Danisevskis5898d152021-06-15 08:23:46 -0700333 map_or_log_err(self.add_or_remove_user(user_id), Ok)
Hasini Gunasingheda895552021-01-27 19:34:37 +0000334 }
335
336 fn onUserRemoved(&self, user_id: i32) -> BinderResult<()> {
Hasini Gunasinghe5a893e82021-05-05 14:32:32 +0000337 let _wp = wd::watch_millis("IKeystoreMaintenance::onUserRemoved", 500);
Janis Danisevskis5898d152021-06-15 08:23:46 -0700338 map_or_log_err(self.add_or_remove_user(user_id), Ok)
Hasini Gunasingheda895552021-01-27 19:34:37 +0000339 }
Janis Danisevskisddd6e752021-02-22 18:46:55 -0800340
341 fn clearNamespace(&self, domain: Domain, nspace: i64) -> BinderResult<()> {
Hasini Gunasinghe5a893e82021-05-05 14:32:32 +0000342 let _wp = wd::watch_millis("IKeystoreMaintenance::clearNamespace", 500);
Janis Danisevskis5898d152021-06-15 08:23:46 -0700343 map_or_log_err(self.clear_namespace(domain, nspace), Ok)
Janis Danisevskisddd6e752021-02-22 18:46:55 -0800344 }
Hasini Gunasinghe9ee18412021-03-11 20:12:44 +0000345
Janis Danisevskis333b7c02021-03-23 18:57:41 -0700346 fn getState(&self, user_id: i32) -> BinderResult<AidlUserState> {
Hasini Gunasinghe5a893e82021-05-05 14:32:32 +0000347 let _wp = wd::watch_millis("IKeystoreMaintenance::getState", 500);
Hasini Gunasinghe9ee18412021-03-11 20:12:44 +0000348 map_or_log_err(Self::get_state(user_id), Ok)
349 }
Janis Danisevskis333b7c02021-03-23 18:57:41 -0700350
Satya Tangirala5b9e5b12021-03-09 12:54:21 -0800351 fn earlyBootEnded(&self) -> BinderResult<()> {
Hasini Gunasinghe5a893e82021-05-05 14:32:32 +0000352 let _wp = wd::watch_millis("IKeystoreMaintenance::earlyBootEnded", 500);
Satya Tangirala5b9e5b12021-03-09 12:54:21 -0800353 map_or_log_err(Self::early_boot_ended(), Ok)
354 }
355
Janis Danisevskis333b7c02021-03-23 18:57:41 -0700356 fn onDeviceOffBody(&self) -> BinderResult<()> {
Hasini Gunasinghe5a893e82021-05-05 14:32:32 +0000357 let _wp = wd::watch_millis("IKeystoreMaintenance::onDeviceOffBody", 500);
Janis Danisevskis333b7c02021-03-23 18:57:41 -0700358 map_or_log_err(Self::on_device_off_body(), Ok)
359 }
Janis Danisevskiscdcf4e52021-04-14 15:44:36 -0700360
361 fn migrateKeyNamespace(
362 &self,
363 source: &KeyDescriptor,
364 destination: &KeyDescriptor,
365 ) -> BinderResult<()> {
Hasini Gunasinghe5a893e82021-05-05 14:32:32 +0000366 let _wp = wd::watch_millis("IKeystoreMaintenance::migrateKeyNamespace", 500);
Janis Danisevskiscdcf4e52021-04-14 15:44:36 -0700367 map_or_log_err(Self::migrate_key_namespace(source, destination), Ok)
368 }
Paul Crowley46c703e2021-08-06 15:13:53 -0700369
John Wu16db29e2022-01-13 15:21:43 -0800370 fn listEntries(&self, domain: Domain, namespace: i64) -> BinderResult<Vec<KeyDescriptor>> {
371 let _wp = wd::watch_millis("IKeystoreMaintenance::listEntries", 500);
372 map_or_log_err(Self::list_entries(domain, namespace), Ok)
373 }
374
Paul Crowley46c703e2021-08-06 15:13:53 -0700375 fn deleteAllKeys(&self) -> BinderResult<()> {
376 let _wp = wd::watch_millis("IKeystoreMaintenance::deleteAllKeys", 500);
377 map_or_log_err(Self::delete_all_keys(), Ok)
378 }
Hasini Gunasingheda895552021-01-27 19:34:37 +0000379}