blob: 73dc88158066943aac8b9bf68122e529bd143967 [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};
Shaquille Johnson9da2e1c2022-09-19 12:39:01 +000023use crate::ks_err;
Janis Danisevskiscdcf4e52021-04-14 15:44:36 -070024use crate::permission::{KeyPerm, KeystorePerm};
Janis Danisevskis0fd25a62022-01-04 19:53:37 -080025use crate::super_key::{SuperKeyManager, UserState};
John Wu16db29e2022-01-13 15:21:43 -080026use crate::utils::{
John Wu889c1cc2022-03-14 16:02:56 -070027 check_key_permission, check_keystore_permission, uid_to_android_user, watchdog as wd,
John Wu16db29e2022-01-13 15:21:43 -080028};
Paul Crowley46c703e2021-08-06 15:13:53 -070029use android_hardware_security_keymint::aidl::android::hardware::security::keymint::{
30 IKeyMintDevice::IKeyMintDevice, SecurityLevel::SecurityLevel,
31};
Hasini Gunasinghe9ee18412021-03-11 20:12:44 +000032use android_security_maintenance::aidl::android::security::maintenance::{
John Wu889c1cc2022-03-14 16:02:56 -070033 IKeystoreMaintenance::{BnKeystoreMaintenance, IKeystoreMaintenance},
Hasini Gunasinghe9ee18412021-03-11 20:12:44 +000034 UserState::UserState as AidlUserState,
Hasini Gunasingheda895552021-01-27 19:34:37 +000035};
Andrew Walbrande45c8b2021-04-13 14:42:38 +000036use android_security_maintenance::binder::{
37 BinderFeatures, Interface, Result as BinderResult, Strong, ThreadState,
38};
Janis Danisevskis5898d152021-06-15 08:23:46 -070039use android_system_keystore2::aidl::android::system::keystore2::KeyDescriptor::KeyDescriptor;
Hasini Gunasingheda895552021-01-27 19:34:37 +000040use android_system_keystore2::aidl::android::system::keystore2::ResponseCode::ResponseCode;
41use anyhow::{Context, Result};
Paul Crowleyf61fee72021-03-17 14:38:44 -070042use keystore2_crypto::Password;
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.
Shaquille Johnson9da2e1c2022-09-19 12:39:01 +000075 check_keystore_permission(KeystorePerm::ChangePassword).context(ks_err!())?;
Hasini Gunasingheda895552021-01-27 19:34:37 +000076
Janis Danisevskis0fd25a62022-01-04 19:53:37 -080077 let mut skm = SUPER_KEY.write().unwrap();
78
Paul Crowley7a658392021-03-18 17:08:20 -070079 if let Some(pw) = password.as_ref() {
80 DB.with(|db| {
Janis Danisevskis0fd25a62022-01-04 19:53:37 -080081 skm.unlock_screen_lock_bound_key(&mut db.borrow_mut(), user_id as u32, pw)
Paul Crowley7a658392021-03-18 17:08:20 -070082 })
Shaquille Johnson9da2e1c2022-09-19 12:39:01 +000083 .context(ks_err!("unlock_screen_lock_bound_key failed"))?;
Paul Crowley7a658392021-03-18 17:08:20 -070084 }
85
Nathan Huckleberry204a0442023-03-30 17:27:47 +000086 if let UserState::LskfLocked = DB
87 .with(|db| skm.get_user_state(&mut db.borrow_mut(), &LEGACY_IMPORTER, user_id as u32))
88 .context(ks_err!("Could not get user state while changing password!"))?
Hasini Gunasingheda895552021-01-27 19:34:37 +000089 {
Nathan Huckleberry204a0442023-03-30 17:27:47 +000090 // Error - password can not be changed when the device is locked
91 return Err(Error::Rc(ResponseCode::LOCKED)).context(ks_err!("Device is locked."));
Hasini Gunasingheda895552021-01-27 19:34:37 +000092 }
Nathan Huckleberry204a0442023-03-30 17:27:47 +000093
94 DB.with(|db| match password {
95 Some(pass) => {
96 skm.init_user(&mut db.borrow_mut(), &LEGACY_IMPORTER, user_id as u32, &pass)
97 }
98 None => {
99 // User transitioned to swipe.
100 skm.reset_user(&mut db.borrow_mut(), &LEGACY_IMPORTER, user_id as u32)
101 }
102 })
103 .context(ks_err!("Failed to change user password!"))
Hasini Gunasingheda895552021-01-27 19:34:37 +0000104 }
105
Janis Danisevskis5898d152021-06-15 08:23:46 -0700106 fn add_or_remove_user(&self, user_id: i32) -> Result<()> {
Hasini Gunasingheda895552021-01-27 19:34:37 +0000107 // Check permission. Function should return if this failed. Therefore having '?' at the end
108 // is very important.
Shaquille Johnson9da2e1c2022-09-19 12:39:01 +0000109 check_keystore_permission(KeystorePerm::ChangeUser).context(ks_err!())?;
Janis Danisevskis0fd25a62022-01-04 19:53:37 -0800110
Janis Danisevskiseed69842021-02-18 20:04:10 -0800111 DB.with(|db| {
Nathan Huckleberry204a0442023-03-30 17:27:47 +0000112 SUPER_KEY.write().unwrap().remove_user(
Janis Danisevskiseed69842021-02-18 20:04:10 -0800113 &mut db.borrow_mut(),
Janis Danisevskis0ffb8a82022-02-06 22:37:21 -0800114 &LEGACY_IMPORTER,
Janis Danisevskiseed69842021-02-18 20:04:10 -0800115 user_id as u32,
Janis Danisevskiseed69842021-02-18 20:04:10 -0800116 )
117 })
Shaquille Johnson9da2e1c2022-09-19 12:39:01 +0000118 .context(ks_err!("Trying to delete keys from db."))?;
Janis Danisevskis5898d152021-06-15 08:23:46 -0700119 self.delete_listener
120 .delete_user(user_id as u32)
Shaquille Johnson9da2e1c2022-09-19 12:39:01 +0000121 .context(ks_err!("While invoking the delete listener."))
Hasini Gunasingheda895552021-01-27 19:34:37 +0000122 }
Janis Danisevskisddd6e752021-02-22 18:46:55 -0800123
Janis Danisevskis5898d152021-06-15 08:23:46 -0700124 fn clear_namespace(&self, domain: Domain, nspace: i64) -> Result<()> {
Janis Danisevskisddd6e752021-02-22 18:46:55 -0800125 // Permission check. Must return on error. Do not touch the '?'.
Janis Danisevskisa916d992021-10-19 15:46:09 -0700126 check_keystore_permission(KeystorePerm::ClearUID).context("In clear_namespace.")?;
Janis Danisevskisddd6e752021-02-22 18:46:55 -0800127
Janis Danisevskis0ffb8a82022-02-06 22:37:21 -0800128 LEGACY_IMPORTER
Janis Danisevskisddd6e752021-02-22 18:46:55 -0800129 .bulk_delete_uid(domain, nspace)
Shaquille Johnson9da2e1c2022-09-19 12:39:01 +0000130 .context(ks_err!("Trying to delete legacy keys."))?;
Janis Danisevskisddd6e752021-02-22 18:46:55 -0800131 DB.with(|db| db.borrow_mut().unbind_keys_for_namespace(domain, nspace))
Shaquille Johnson9da2e1c2022-09-19 12:39:01 +0000132 .context(ks_err!("Trying to delete keys from db."))?;
Janis Danisevskis5898d152021-06-15 08:23:46 -0700133 self.delete_listener
134 .delete_namespace(domain, nspace)
Shaquille Johnson9da2e1c2022-09-19 12:39:01 +0000135 .context(ks_err!("While invoking the delete listener."))
Janis Danisevskisddd6e752021-02-22 18:46:55 -0800136 }
Hasini Gunasinghe9ee18412021-03-11 20:12:44 +0000137
138 fn get_state(user_id: i32) -> Result<AidlUserState> {
139 // Check permission. Function should return if this failed. Therefore having '?' at the end
140 // is very important.
Janis Danisevskisa916d992021-10-19 15:46:09 -0700141 check_keystore_permission(KeystorePerm::GetState).context("In get_state.")?;
Hasini Gunasinghe9ee18412021-03-11 20:12:44 +0000142 let state = DB
143 .with(|db| {
Janis Danisevskis0fd25a62022-01-04 19:53:37 -0800144 SUPER_KEY.read().unwrap().get_user_state(
145 &mut db.borrow_mut(),
Janis Danisevskis0ffb8a82022-02-06 22:37:21 -0800146 &LEGACY_IMPORTER,
Janis Danisevskis0fd25a62022-01-04 19:53:37 -0800147 user_id as u32,
148 )
Hasini Gunasinghe9ee18412021-03-11 20:12:44 +0000149 })
Shaquille Johnson9da2e1c2022-09-19 12:39:01 +0000150 .context(ks_err!("Trying to get UserState."))?;
Hasini Gunasinghe9ee18412021-03-11 20:12:44 +0000151
152 match state {
153 UserState::Uninitialized => Ok(AidlUserState::UNINITIALIZED),
154 UserState::LskfUnlocked(_) => Ok(AidlUserState::LSKF_UNLOCKED),
155 UserState::LskfLocked => Ok(AidlUserState::LSKF_LOCKED),
156 }
157 }
Janis Danisevskis333b7c02021-03-23 18:57:41 -0700158
Paul Crowley46c703e2021-08-06 15:13:53 -0700159 fn call_with_watchdog<F>(sec_level: SecurityLevel, name: &'static str, op: &F) -> Result<()>
160 where
Stephen Crane23cf7242022-01-19 17:49:46 +0000161 F: Fn(Strong<dyn IKeyMintDevice>) -> binder::Result<()>,
Paul Crowley46c703e2021-08-06 15:13:53 -0700162 {
Shaquille Johnson9da2e1c2022-09-19 12:39:01 +0000163 let (km_dev, _, _) =
164 get_keymint_device(&sec_level).context(ks_err!("getting keymint device"))?;
Janis Danisevskis2ee014b2021-05-05 14:29:08 -0700165
Paul Crowley46c703e2021-08-06 15:13:53 -0700166 let _wp = wd::watch_millis_with("In call_with_watchdog", 500, move || {
167 format!("Seclevel: {:?} Op: {}", sec_level, name)
168 });
Shaquille Johnson9da2e1c2022-09-19 12:39:01 +0000169 map_km_error(op(km_dev)).with_context(|| ks_err!("calling {}", name))?;
Satya Tangirala5b9e5b12021-03-09 12:54:21 -0800170 Ok(())
171 }
172
Paul Crowley46c703e2021-08-06 15:13:53 -0700173 fn call_on_all_security_levels<F>(name: &'static str, op: F) -> Result<()>
174 where
Stephen Crane23cf7242022-01-19 17:49:46 +0000175 F: Fn(Strong<dyn IKeyMintDevice>) -> binder::Result<()>,
Paul Crowley46c703e2021-08-06 15:13:53 -0700176 {
177 let sec_levels = [
178 (SecurityLevel::TRUSTED_ENVIRONMENT, "TRUSTED_ENVIRONMENT"),
179 (SecurityLevel::STRONGBOX, "STRONGBOX"),
180 ];
181 sec_levels.iter().fold(Ok(()), move |result, (sec_level, sec_level_string)| {
182 let curr_result = Maintenance::call_with_watchdog(*sec_level, name, &op);
183 match curr_result {
184 Ok(()) => log::info!(
185 "Call to {} succeeded for security level {}.",
186 name,
187 &sec_level_string
188 ),
189 Err(ref e) => log::error!(
190 "Call to {} failed for security level {}: {}.",
191 name,
192 &sec_level_string,
193 e
194 ),
195 }
196 result.and(curr_result)
197 })
198 }
199
Satya Tangirala5b9e5b12021-03-09 12:54:21 -0800200 fn early_boot_ended() -> Result<()> {
Janis Danisevskisa916d992021-10-19 15:46:09 -0700201 check_keystore_permission(KeystorePerm::EarlyBootEnded)
Shaquille Johnson9da2e1c2022-09-19 12:39:01 +0000202 .context(ks_err!("Checking permission"))?;
Paul Crowley44c02da2021-04-08 17:04:43 +0000203 log::info!("In early_boot_ended.");
204
Janis Danisevskis0fd25a62022-01-04 19:53:37 -0800205 if let Err(e) =
206 DB.with(|db| SuperKeyManager::set_up_boot_level_cache(&SUPER_KEY, &mut db.borrow_mut()))
207 {
Paul Crowley44c02da2021-04-08 17:04:43 +0000208 log::error!("SUPER_KEY.set_up_boot_level_cache failed:\n{:?}\n:(", e);
209 }
Paul Crowley46c703e2021-08-06 15:13:53 -0700210 Maintenance::call_on_all_security_levels("earlyBootEnded", |dev| dev.earlyBootEnded())
Satya Tangirala5b9e5b12021-03-09 12:54:21 -0800211 }
212
Janis Danisevskis333b7c02021-03-23 18:57:41 -0700213 fn on_device_off_body() -> Result<()> {
214 // Security critical permission check. This statement must return on fail.
Shaquille Johnson9da2e1c2022-09-19 12:39:01 +0000215 check_keystore_permission(KeystorePerm::ReportOffBody).context(ks_err!())?;
Janis Danisevskis333b7c02021-03-23 18:57:41 -0700216
Matthew Maurerd7815ca2021-05-06 21:58:45 -0700217 DB.with(|db| db.borrow_mut().update_last_off_body(MonotonicRawTime::now()));
218 Ok(())
Janis Danisevskis333b7c02021-03-23 18:57:41 -0700219 }
Janis Danisevskiscdcf4e52021-04-14 15:44:36 -0700220
221 fn migrate_key_namespace(source: &KeyDescriptor, destination: &KeyDescriptor) -> Result<()> {
John Wu889c1cc2022-03-14 16:02:56 -0700222 let calling_uid = ThreadState::get_calling_uid();
Janis Danisevskiscdcf4e52021-04-14 15:44:36 -0700223
John Wu889c1cc2022-03-14 16:02:56 -0700224 match source.domain {
225 Domain::SELINUX | Domain::KEY_ID | Domain::APP => (),
John Wu16db29e2022-01-13 15:21:43 -0800226 _ => {
Shaquille Johnson9da2e1c2022-09-19 12:39:01 +0000227 return Err(Error::Rc(ResponseCode::INVALID_ARGUMENT))
228 .context(ks_err!("Source domain must be one of APP, SELINUX, or KEY_ID."));
John Wu16db29e2022-01-13 15:21:43 -0800229 }
230 };
Janis Danisevskiscdcf4e52021-04-14 15:44:36 -0700231
John Wu889c1cc2022-03-14 16:02:56 -0700232 match destination.domain {
233 Domain::SELINUX | Domain::APP => (),
John Wu16db29e2022-01-13 15:21:43 -0800234 _ => {
Shaquille Johnson9da2e1c2022-09-19 12:39:01 +0000235 return Err(Error::Rc(ResponseCode::INVALID_ARGUMENT))
236 .context(ks_err!("Destination domain must be one of APP or SELINUX."));
John Wu16db29e2022-01-13 15:21:43 -0800237 }
238 };
239
John Wu889c1cc2022-03-14 16:02:56 -0700240 let user_id = uid_to_android_user(calling_uid);
Janis Danisevskisf84d0b02022-01-26 14:11:14 -0800241
242 let super_key = SUPER_KEY.read().unwrap().get_per_boot_key_by_user_id(user_id);
243
244 DB.with(|db| {
John Wu889c1cc2022-03-14 16:02:56 -0700245 let (key_id_guard, _) = LEGACY_IMPORTER
246 .with_try_import(source, calling_uid, super_key, || {
247 db.borrow_mut().load_key_entry(
248 source,
249 KeyType::Client,
250 KeyEntryLoadBits::NONE,
251 calling_uid,
252 |k, av| {
253 check_key_permission(KeyPerm::Use, k, &av)?;
254 check_key_permission(KeyPerm::Delete, k, &av)?;
255 check_key_permission(KeyPerm::Grant, k, &av)
256 },
257 )
Janis Danisevskisf84d0b02022-01-26 14:11:14 -0800258 })
Shaquille Johnson9da2e1c2022-09-19 12:39:01 +0000259 .context(ks_err!("Failed to load key blob."))?;
John Wu889c1cc2022-03-14 16:02:56 -0700260 {
261 db.borrow_mut().migrate_key_namespace(key_id_guard, destination, calling_uid, |k| {
262 check_key_permission(KeyPerm::Rebind, k, &None)
263 })
Janis Danisevskisf84d0b02022-01-26 14:11:14 -0800264 }
Janis Danisevskiscdcf4e52021-04-14 15:44:36 -0700265 })
266 }
Paul Crowley46c703e2021-08-06 15:13:53 -0700267
268 fn delete_all_keys() -> Result<()> {
269 // Security critical permission check. This statement must return on fail.
Janis Danisevskisa916d992021-10-19 15:46:09 -0700270 check_keystore_permission(KeystorePerm::DeleteAllKeys)
Shaquille Johnson9da2e1c2022-09-19 12:39:01 +0000271 .context(ks_err!("Checking permission"))?;
Paul Crowley46c703e2021-08-06 15:13:53 -0700272 log::info!("In delete_all_keys.");
273
274 Maintenance::call_on_all_security_levels("deleteAllKeys", |dev| dev.deleteAllKeys())
275 }
Hasini Gunasingheda895552021-01-27 19:34:37 +0000276}
277
Janis Danisevskis34a0cf22021-03-08 09:19:03 -0800278impl Interface for Maintenance {}
Hasini Gunasingheda895552021-01-27 19:34:37 +0000279
Janis Danisevskis34a0cf22021-03-08 09:19:03 -0800280impl IKeystoreMaintenance for Maintenance {
Hasini Gunasingheda895552021-01-27 19:34:37 +0000281 fn onUserPasswordChanged(&self, user_id: i32, password: Option<&[u8]>) -> BinderResult<()> {
Hasini Gunasinghe5a893e82021-05-05 14:32:32 +0000282 let _wp = wd::watch_millis("IKeystoreMaintenance::onUserPasswordChanged", 500);
Paul Crowleyf61fee72021-03-17 14:38:44 -0700283 map_or_log_err(Self::on_user_password_changed(user_id, password.map(|pw| pw.into())), Ok)
Hasini Gunasingheda895552021-01-27 19:34:37 +0000284 }
285
286 fn onUserAdded(&self, user_id: i32) -> BinderResult<()> {
Hasini Gunasinghe5a893e82021-05-05 14:32:32 +0000287 let _wp = wd::watch_millis("IKeystoreMaintenance::onUserAdded", 500);
Janis Danisevskis5898d152021-06-15 08:23:46 -0700288 map_or_log_err(self.add_or_remove_user(user_id), Ok)
Hasini Gunasingheda895552021-01-27 19:34:37 +0000289 }
290
291 fn onUserRemoved(&self, user_id: i32) -> BinderResult<()> {
Hasini Gunasinghe5a893e82021-05-05 14:32:32 +0000292 let _wp = wd::watch_millis("IKeystoreMaintenance::onUserRemoved", 500);
Janis Danisevskis5898d152021-06-15 08:23:46 -0700293 map_or_log_err(self.add_or_remove_user(user_id), Ok)
Hasini Gunasingheda895552021-01-27 19:34:37 +0000294 }
Janis Danisevskisddd6e752021-02-22 18:46:55 -0800295
296 fn clearNamespace(&self, domain: Domain, nspace: i64) -> BinderResult<()> {
Hasini Gunasinghe5a893e82021-05-05 14:32:32 +0000297 let _wp = wd::watch_millis("IKeystoreMaintenance::clearNamespace", 500);
Janis Danisevskis5898d152021-06-15 08:23:46 -0700298 map_or_log_err(self.clear_namespace(domain, nspace), Ok)
Janis Danisevskisddd6e752021-02-22 18:46:55 -0800299 }
Hasini Gunasinghe9ee18412021-03-11 20:12:44 +0000300
Janis Danisevskis333b7c02021-03-23 18:57:41 -0700301 fn getState(&self, user_id: i32) -> BinderResult<AidlUserState> {
Hasini Gunasinghe5a893e82021-05-05 14:32:32 +0000302 let _wp = wd::watch_millis("IKeystoreMaintenance::getState", 500);
Hasini Gunasinghe9ee18412021-03-11 20:12:44 +0000303 map_or_log_err(Self::get_state(user_id), Ok)
304 }
Janis Danisevskis333b7c02021-03-23 18:57:41 -0700305
Satya Tangirala5b9e5b12021-03-09 12:54:21 -0800306 fn earlyBootEnded(&self) -> BinderResult<()> {
Hasini Gunasinghe5a893e82021-05-05 14:32:32 +0000307 let _wp = wd::watch_millis("IKeystoreMaintenance::earlyBootEnded", 500);
Satya Tangirala5b9e5b12021-03-09 12:54:21 -0800308 map_or_log_err(Self::early_boot_ended(), Ok)
309 }
310
Janis Danisevskis333b7c02021-03-23 18:57:41 -0700311 fn onDeviceOffBody(&self) -> BinderResult<()> {
Hasini Gunasinghe5a893e82021-05-05 14:32:32 +0000312 let _wp = wd::watch_millis("IKeystoreMaintenance::onDeviceOffBody", 500);
Janis Danisevskis333b7c02021-03-23 18:57:41 -0700313 map_or_log_err(Self::on_device_off_body(), Ok)
314 }
Janis Danisevskiscdcf4e52021-04-14 15:44:36 -0700315
316 fn migrateKeyNamespace(
317 &self,
318 source: &KeyDescriptor,
319 destination: &KeyDescriptor,
320 ) -> BinderResult<()> {
Hasini Gunasinghe5a893e82021-05-05 14:32:32 +0000321 let _wp = wd::watch_millis("IKeystoreMaintenance::migrateKeyNamespace", 500);
Janis Danisevskiscdcf4e52021-04-14 15:44:36 -0700322 map_or_log_err(Self::migrate_key_namespace(source, destination), Ok)
323 }
Paul Crowley46c703e2021-08-06 15:13:53 -0700324
325 fn deleteAllKeys(&self) -> BinderResult<()> {
326 let _wp = wd::watch_millis("IKeystoreMaintenance::deleteAllKeys", 500);
327 map_or_log_err(Self::delete_all_keys(), Ok)
328 }
Hasini Gunasingheda895552021-01-27 19:34:37 +0000329}