summaryrefslogtreecommitdiff
path: root/keystore2/test_utils
diff options
context:
space:
mode:
authorRajesh Nyamagoud <nyamagoud@google.com>2023-06-05 17:31:20 +0000
committerRajesh Nyamagoud <nyamagoud@google.com>2023-10-27 19:25:09 +0000
commit290dd7386fcf436e2bc0b4267054a921082a6d1f (patch)
tree097ac8966a0704edcbd46b85154c1e91595acf4b /keystore2/test_utils
parentf692f4232708f7447a0f801b66dcbd74e067065b (diff)
downloadsecurity-290dd7386fcf436e2bc0b4267054a921082a6d1f.tar.gz
Adding tests using APPLICATION_DATA and APPLICATION_ID.
1. Generate a key with application-data and use the generated key to create an operation using the same application-data. Test should create an operation successfully. 2. Generate a key with application-data and use the generated key to create an operation using different application-data. Test should fail to create an operation with `INVALID_KEY_BLOB` error code. 3. Generate a key with application-id and use the generated key to create an operation using the same application-id. Test should create an operation successfully. 4. Generate a key with application-id and use the generated key to create an operation using different application-id. Test should fail to create an operation with `INVALID_KEY_BLOB` error code. 5. Generate an attestation key without app-id and app-data. Test should generate a new key with specifying app-id, app-data and using previously generated attestation key. Test should be able to generate a new key successfully. 6. Generate an attestation key with app-id and app-data. Test should try to generate an attested key using previously generated attestation key without specifying same app-id, app-data. Test should fail to generate a new key with an error code `INVALID_KEY_BLOB`. It is an oversight of the Keystore API that `APPLICATION_ID` and `APPLICATION_DATA` tags cannot be provided to generateKey for an attestation key that was generated with them. Bug: 279721870 Test: atest keystore2_client_tests Change-Id: I56fad4806c6d96c5994f4affdd7aa6620b1f1be8
Diffstat (limited to 'keystore2/test_utils')
-rw-r--r--keystore2/test_utils/authorizations.rs12
1 files changed, 12 insertions, 0 deletions
diff --git a/keystore2/test_utils/authorizations.rs b/keystore2/test_utils/authorizations.rs
index ebe2665e..02ceb83e 100644
--- a/keystore2/test_utils/authorizations.rs
+++ b/keystore2/test_utils/authorizations.rs
@@ -323,6 +323,18 @@ impl AuthSetBuilder {
});
self
}
+
+ /// Add app-data.
+ pub fn app_data(mut self, b: Vec<u8>) -> Self {
+ self.0.push(KeyParameter { tag: Tag::APPLICATION_DATA, value: KeyParameterValue::Blob(b) });
+ self
+ }
+
+ /// Add app-id.
+ pub fn app_id(mut self, b: Vec<u8>) -> Self {
+ self.0.push(KeyParameter { tag: Tag::APPLICATION_ID, value: KeyParameterValue::Blob(b) });
+ self
+ }
}
impl Deref for AuthSetBuilder {