Update logs to use ks_err in rust code
Test: Run and tested using `atest keystore2_test` for Rust test and CTS test with `atest CtsKeystoreTestCases`
Change-Id: Ic8e62f1c5d19c6203945fefeb18b066bf8a32ed7
diff --git a/keystore2/src/security_level.rs b/keystore2/src/security_level.rs
index ae49bc8..66fcb26 100644
--- a/keystore2/src/security_level.rs
+++ b/keystore2/src/security_level.rs
@@ -148,7 +148,7 @@
SecurityLevel::SOFTWARE,
));
- let creation_date = DateTime::now().context("Trying to make creation time.")?;
+ let creation_date = DateTime::now().context(ks_err!("Trying to make creation time."))?;
let key = match key.domain {
Domain::BLOB => KeyDescriptor {
@@ -677,7 +677,7 @@
KeyParameterValue::Algorithm(Algorithm::RSA)
| KeyParameterValue::Algorithm(Algorithm::EC) => Ok(KeyFormat::PKCS8),
v => Err(error::Error::Km(ErrorCode::INVALID_ARGUMENT))
- .context(format!("Unknown Algorithm {:?}.", v)),
+ .context(ks_err!("Unknown Algorithm {:?}.", v)),
})
.context(ks_err!())?;
@@ -757,10 +757,10 @@
})
.context("Failed to load wrapping key.")?;
- let (wrapping_key_blob, wrapping_blob_metadata) = wrapping_key_entry
- .take_key_blob_info()
- .ok_or_else(error::Error::sys)
- .context("No km_blob after successfully loading key. This should never happen.")?;
+ let (wrapping_key_blob, wrapping_blob_metadata) =
+ wrapping_key_entry.take_key_blob_info().ok_or_else(error::Error::sys).context(
+ ks_err!("No km_blob after successfully loading key. This should never happen."),
+ )?;
let wrapping_key_blob = SUPER_KEY
.read()