summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2022-05-16 17:55:06 +0000
committerAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2022-05-16 17:55:06 +0000
commit4b3796605179ac92e8cf88ed58e4147739fbf4e1 (patch)
treea063cce66a64d87a9ffa555f3314aace3f5f7d9b
parent9101bffada5faf80a44ea6e83d96899ca986a865 (diff)
parentadf6692b3e024ba997730474b3db0068209a97a4 (diff)
downloadsecurity-4b3796605179ac92e8cf88ed58e4147739fbf4e1.tar.gz
Snap for 8598309 from adf6692b3e024ba997730474b3db0068209a97a4 to tm-frc-documentsui-release
Change-Id: I3e232c01e96f9cc762455d24bbc0ae642d4971e5
-rw-r--r--keystore2/aidl/android/security/metrics/RkpErrorStats.aidl2
-rw-r--r--keystore2/src/database.rs5
-rw-r--r--keystore2/src/metrics_store.rs5
-rw-r--r--keystore2/src/remote_provisioning.rs3
4 files changed, 11 insertions, 4 deletions
diff --git a/keystore2/aidl/android/security/metrics/RkpErrorStats.aidl b/keystore2/aidl/android/security/metrics/RkpErrorStats.aidl
index 616d129e..dcd51227 100644
--- a/keystore2/aidl/android/security/metrics/RkpErrorStats.aidl
+++ b/keystore2/aidl/android/security/metrics/RkpErrorStats.aidl
@@ -17,6 +17,7 @@
package android.security.metrics;
import android.security.metrics.RkpError;
+import android.security.metrics.SecurityLevel;
/**
* Atom that encapsulates error information in remote key provisioning events.
* @hide
@@ -24,4 +25,5 @@ import android.security.metrics.RkpError;
@RustDerive(Clone=true, Eq=true, PartialEq=true, Ord=true, PartialOrd=true, Hash=true)
parcelable RkpErrorStats {
RkpError rkpError;
+ SecurityLevel security_level;
} \ No newline at end of file
diff --git a/keystore2/src/database.rs b/keystore2/src/database.rs
index 77136188..6b74e3c8 100644
--- a/keystore2/src/database.rs
+++ b/keystore2/src/database.rs
@@ -46,6 +46,7 @@ pub(crate) mod utils;
mod versioning;
use crate::gc::Gc;
+use crate::globals::get_keymint_dev_by_uuid;
use crate::impl_metadata; // This is in db_utils.rs
use crate::key_parameter::{KeyParameter, Tag};
use crate::metrics_store::log_rkp_error_stats;
@@ -1863,7 +1864,9 @@ impl KeystoreDB {
)
.context("Failed to assign attestation key")?;
if result == 0 {
- log_rkp_error_stats(MetricsRkpError::OUT_OF_KEYS);
+ let (_, hw_info) = get_keymint_dev_by_uuid(km_uuid)
+ .context("Error in retrieving keymint device by UUID.")?;
+ log_rkp_error_stats(MetricsRkpError::OUT_OF_KEYS, &hw_info.securityLevel);
return Err(KsError::Rc(ResponseCode::OUT_OF_KEYS)).context("Out of keys.");
} else if result > 1 {
return Err(KsError::sys())
diff --git a/keystore2/src/metrics_store.rs b/keystore2/src/metrics_store.rs
index b6f13431..62a7d135 100644
--- a/keystore2/src/metrics_store.rs
+++ b/keystore2/src/metrics_store.rs
@@ -599,8 +599,9 @@ fn pull_attestation_pool_stats() -> Result<Vec<KeystoreAtom>> {
}
/// Log error events related to Remote Key Provisioning (RKP).
-pub fn log_rkp_error_stats(rkp_error: MetricsRkpError) {
- let rkp_error_stats = KeystoreAtomPayload::RkpErrorStats(RkpErrorStats { rkpError: rkp_error });
+pub fn log_rkp_error_stats(rkp_error: MetricsRkpError, sec_level: &SecurityLevel) {
+ let rkp_error_stats = KeystoreAtomPayload::RkpErrorStats(
+ RkpErrorStats { rkpError: rkp_error, security_level: process_security_level(*sec_level) });
METRICS_STORE.insert_atom(AtomID::RKP_ERROR_STATS, rkp_error_stats);
}
diff --git a/keystore2/src/remote_provisioning.rs b/keystore2/src/remote_provisioning.rs
index b47b3731..ea2698f0 100644
--- a/keystore2/src/remote_provisioning.rs
+++ b/keystore2/src/remote_provisioning.rs
@@ -159,7 +159,8 @@ impl RemProvState {
if self.is_rkp_only() {
return Err(e);
}
- log_rkp_error_stats(MetricsRkpError::FALL_BACK_DURING_HYBRID);
+ log_rkp_error_stats(MetricsRkpError::FALL_BACK_DURING_HYBRID,
+ &self.security_level);
Ok(None)
}
Ok(v) => match v {