Update ks_err on Keystore security code
Test: Run and tested using `atest keystore2_test` for Rust test and CTS test with `atest CtsKeystoreTestCases`
Change-Id: Id53c870260e9757227f6cb5d57787796f60fe9d5
diff --git a/keystore2/src/security_level.rs b/keystore2/src/security_level.rs
index b928fb0..cc1f816 100644
--- a/keystore2/src/security_level.rs
+++ b/keystore2/src/security_level.rs
@@ -612,7 +612,7 @@
})
},
)
- .context("While generating Key with remote provisioned attestation key.")
+ .context(ks_err!("While generating Key with remote provisioned attestation key."))
.map(|(mut result, _)| {
result.certificateChain.push(attestation_certs);
result
@@ -635,7 +635,7 @@
self.keymint.generateKey(¶ms, dynamic_attest_key.as_ref())
})
})
- .context("While generating Key with remote provisioned attestation key.")
+ .context(ks_err!("While generating Key with remote provisioned attestation key."))
.map(|(mut result, _)| {
result.certificateChain.push(attestation_certs);
result
@@ -651,7 +651,7 @@
);
self.keymint.generateKey(¶ms, None)
})
- .context("While generating Key without explicit attestation key."),
+ .context(ks_err!("While generating Key without explicit attestation key.")),
}
.context(ks_err!())?;
@@ -684,7 +684,7 @@
};
// import_key requires the rebind permission.
- check_key_permission(KeyPerm::Rebind, &key, &None).context("In import_key.")?;
+ check_key_permission(KeyPerm::Rebind, &key, &None).context(ks_err!("In import_key."))?;
let params = self
.add_required_parameters(caller_uid, params, &key)
@@ -694,7 +694,7 @@
.iter()
.find(|p| p.tag == Tag::ALGORITHM)
.ok_or(error::Error::Km(ErrorCode::INVALID_ARGUMENT))
- .context("No KeyParameter 'Algorithm'.")
+ .context(ks_err!("No KeyParameter 'Algorithm'."))
.and_then(|p| match &p.value {
KeyParameterValue::Algorithm(Algorithm::AES)
| KeyParameterValue::Algorithm(Algorithm::HMAC)
@@ -780,7 +780,7 @@
)
})
})
- .context("Failed to load wrapping key.")?;
+ .context(ks_err!("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(