Keystore 2.0: Use generated KeyMint AIDL bindingis.
This patch adjusts keystore2 to use rust bindings generated from the
KeyMint AIDL spec instead of using pregenerated bindings.
Bug: 160623310
Test: keystore2_test
Change-Id: I77bb0426991381535f9dbe4f32e7e137a8eb7df3
diff --git a/keystore2/src/key_parameter.rs b/keystore2/src/key_parameter.rs
index 8825fc9..0d164f1 100644
--- a/keystore2/src/key_parameter.rs
+++ b/keystore2/src/key_parameter.rs
@@ -606,7 +606,6 @@
/// CallerNonce, CALLER_NONCE, boolValue;
/// UserSecureID, USER_SECURE_ID, longInteger;
/// ApplicationID, APPLICATION_ID, blob;
-/// ActiveDateTime, ACTIVE_DATETIME, dateTime;
/// }
/// ```
/// expands to:
@@ -637,11 +636,6 @@
/// blob: v,
/// ..Default::default()
/// },
-/// KeyParameterValue::ActiveDateTime(v) => KmKeyParameter {
-/// tag: Tag::ACTIVE_DATETIME,
-/// dateTime: v,
-/// ..Default::default()
-/// },
/// }
/// }
/// ```
@@ -673,11 +667,6 @@
/// blob: v,
/// ..
/// } => KeyParameterValue::ApplicationID(v),
-/// KmKeyParameter {
-/// tag: Tag::ACTIVE_DATETIME,
-/// dateTime: v,
-/// ..
-/// } => KeyParameterValue::ActiveDateTime(v),
/// _ => KeyParameterValue::Invalid,
/// }
/// }
@@ -771,7 +760,7 @@
}
};
// This rule handles all variants that are neither invalid nor bool values nor enums
- // (i.e. all variants which correspond to integer, longInteger, dateTime and blob fields in
+ // (i.e. all variants which correspond to integer, longInteger, and blob fields in
// KmKeyParameter).
// On an input like: 'ConfirmationToken, CONFIRMATION_TOKEN, blob;' it generates a match arm
// like: KeyParameterValue::ConfirmationToken(v) => KmKeyParameter {
@@ -855,7 +844,7 @@
}
};
// This rule handles all variants that are neither invalid nor bool values nor enums
- // (i.e. all variants which correspond to integer, longInteger, dateTime and blob fields in
+ // (i.e. all variants which correspond to integer, longInteger, and blob fields in
// KmKeyParameter).
// On an input like: 'ConfirmationToken, CONFIRMATION_TOKEN, blob;' it generates a match arm
// like:
@@ -892,7 +881,7 @@
// Invoke the macro that generates the code for key parameter conversion to/from wire type
// with all possible variants of KeyParameterValue. Each line corresponding to a variant
// contains: variant identifier, tag value, and the related field name (i.e.
- // boolValue/integer/longInteger/dateTime/blob) in the KmKeyParameter.
+ // boolValue/integer/longInteger/blob) in the KmKeyParameter.
implement_key_parameter_conversion_to_from_wire! {
Invalid, INVALID, na;
KeyPurpose, PURPOSE, integer, KeyPurpose;
@@ -908,9 +897,9 @@
IncludeUniqueID, INCLUDE_UNIQUE_ID, boolValue;
BootLoaderOnly, BOOTLOADER_ONLY, boolValue;
RollbackResistance, ROLLBACK_RESISTANCE, boolValue;
- ActiveDateTime, ACTIVE_DATETIME, dateTime;
- OriginationExpireDateTime, ORIGINATION_EXPIRE_DATETIME, dateTime;
- UsageExpireDateTime, USAGE_EXPIRE_DATETIME, dateTime;
+ ActiveDateTime, ACTIVE_DATETIME, longInteger;
+ OriginationExpireDateTime, ORIGINATION_EXPIRE_DATETIME, longInteger;
+ UsageExpireDateTime, USAGE_EXPIRE_DATETIME, longInteger;
MinSecondsBetweenOps, MIN_SECONDS_BETWEEN_OPS, integer;
MaxUsesPerBoot, MAX_USES_PER_BOOT, integer;
UserID, USER_ID, integer;
@@ -924,7 +913,7 @@
UnlockedDeviceRequired, UNLOCKED_DEVICE_REQUIRED, boolValue;
ApplicationID, APPLICATION_ID, blob;
ApplicationData, APPLICATION_DATA, blob;
- CreationDateTime, CREATION_DATETIME, dateTime;
+ CreationDateTime, CREATION_DATETIME, longInteger;
KeyOrigin, ORIGIN, integer, KeyOrigin;
RootOfTrust, ROOT_OF_TRUST, blob;
OSVersion, OS_VERSION, integer;
@@ -1243,13 +1232,12 @@
}
/// The wire_tests module tests the 'convert_to_wire' and 'convert_from_wire' methods for
-/// KeyParameter, for the five different types used in KmKeyParameter, in addition to Invalid
+/// KeyParameter, for the four different types used in KmKeyParameter, in addition to Invalid
/// key parameter.
/// i) bool
/// ii) integer
/// iii) longInteger
-/// iv) dateTime
-/// v) blob
+/// iv) blob
#[cfg(test)]
mod wire_tests {
use crate::key_parameter::*;
@@ -1286,16 +1274,6 @@
assert_eq!(i64::MAX, actual.longInteger);
}
#[test]
- fn test_convert_to_wire_date_time() {
- let kp = KeyParameter::new(
- KeyParameterValue::ActiveDateTime(i64::MAX),
- SecurityLevel::STRONGBOX,
- );
- let actual = KeyParameterValue::convert_to_wire(kp.key_parameter_value);
- assert_eq!(Tag::ACTIVE_DATETIME, actual.tag);
- assert_eq!(i64::MAX, actual.dateTime);
- }
- #[test]
fn test_convert_to_wire_blob() {
let kp = KeyParameter::new(
KeyParameterValue::ConfirmationToken(String::from("ConfirmationToken").into_bytes()),
@@ -1341,13 +1319,6 @@
assert_eq!(KeyParameterValue::UserSecureID(i64::MAX), actual);
}
#[test]
- fn test_convert_from_wire_date_time() {
- let aidl_kp =
- KmKeyParameter { tag: Tag::ACTIVE_DATETIME, dateTime: i64::MAX, ..Default::default() };
- let actual = KeyParameterValue::convert_from_wire(aidl_kp);
- assert_eq!(KeyParameterValue::ActiveDateTime(i64::MAX), actual);
- }
- #[test]
fn test_convert_from_wire_blob() {
let aidl_kp = KmKeyParameter {
tag: Tag::CONFIRMATION_TOKEN,