summaryrefslogtreecommitdiff
path: root/keystore2/test_utils
diff options
context:
space:
mode:
authorRajesh Nyamagoud <nyamagoud@google.com>2022-08-05 17:38:25 +0000
committerRajesh Nyamagoud <nyamagoud@google.com>2022-08-12 02:09:46 +0000
commitc3523bacffde6061170458e5092b2fbf53fc9079 (patch)
tree7c0a1fefa84cc2565f2d6852adb75cd98edd6dc1 /keystore2/test_utils
parenta00741ceb6fff4ab670fa3942c030254efcf8769 (diff)
downloadsecurity-c3523bacffde6061170458e5092b2fbf53fc9079.tar.gz
Added tests using 3DES algorithm.
- Generate 3DES keys with block modes [ECB, CBC] and padding modes [NONE, PKCS7]. Should be able to create operations successfully with these generated keys. - Try to generate a key and create an operation with invalid inputs, it should fail with proper error codes - with unsupported key size - with unsupported padding mode - with padding mode NONE and input text whose length isn't a multiple of the DES block size - with unsupported blockmode Bug: 194359114 Test: atest keystore2_client_test Change-Id: Ida98fd2e6f9b7ba84b8beba9ea979d5aeb2240ee
Diffstat (limited to 'keystore2/test_utils')
-rw-r--r--keystore2/test_utils/key_generations.rs7
1 files changed, 4 insertions, 3 deletions
diff --git a/keystore2/test_utils/key_generations.rs b/keystore2/test_utils/key_generations.rs
index 047df284..c25d9280 100644
--- a/keystore2/test_utils/key_generations.rs
+++ b/keystore2/test_utils/key_generations.rs
@@ -254,9 +254,10 @@ pub fn generate_rsa_key(
Ok(key_metadata)
}
-/// Generate AES key.
-pub fn generate_aes_key(
+/// Generate AES/3DES key.
+pub fn generate_sym_key(
sec_level: &binder::Strong<dyn IKeystoreSecurityLevel>,
+ algorithm: Algorithm,
size: i32,
alias: &str,
padding_mode: &PaddingMode,
@@ -265,7 +266,7 @@ pub fn generate_aes_key(
) -> binder::Result<KeyMetadata> {
let mut gen_params = AuthSetBuilder::new()
.no_auth_required()
- .algorithm(Algorithm::AES)
+ .algorithm(algorithm)
.purpose(KeyPurpose::ENCRYPT)
.purpose(KeyPurpose::DECRYPT)
.key_size(size)