diff options
author | Alex Klyubin <klyubin@google.com> | 2015-05-11 10:31:12 -0700 |
---|---|---|
committer | Alex Klyubin <klyubin@google.com> | 2015-05-11 11:12:34 -0700 |
commit | 292102459b07188b72575260b693fa962654aa19 (patch) | |
tree | 156b507790332a793b3a40b246b136328945ad14 /keystore/tests/src/android/security | |
parent | 0a775ce9801f03071d1e9bcc177d79e6fe350702 (diff) | |
download | frameworks_base-292102459b07188b72575260b693fa962654aa19.zip frameworks_base-292102459b07188b72575260b693fa962654aa19.tar.gz frameworks_base-292102459b07188b72575260b693fa962654aa19.tar.bz2 |
Fix KeyStoreTest now that begin requires parameters.
Keystore's begin operation now requires parameters which describe the
operation (e.g., algorithm, block mode, padding). This adjusts
KeyStoreTest to provide the necessary parameters.
(cherry-picked from commit c5e4d7af22793072a2620805f5e0e23bf15e7110)
Bug: 19509156
Change-Id: Ibc665fbc893766a683a4aadc97a64ffdf2d0d85f
Diffstat (limited to 'keystore/tests/src/android/security')
-rw-r--r-- | keystore/tests/src/android/security/KeyStoreTest.java | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/keystore/tests/src/android/security/KeyStoreTest.java b/keystore/tests/src/android/security/KeyStoreTest.java index f261079..d138c24 100644 --- a/keystore/tests/src/android/security/KeyStoreTest.java +++ b/keystore/tests/src/android/security/KeyStoreTest.java @@ -817,6 +817,9 @@ public class KeyStoreTest extends ActivityUnitTestCase<Activity> { KeymasterArguments out = new KeymasterArguments(); args = new KeymasterArguments(); + args.addInt(KeymasterDefs.KM_TAG_ALGORITHM, KeymasterDefs.KM_ALGORITHM_AES); + args.addInt(KeymasterDefs.KM_TAG_BLOCK_MODE, KeymasterDefs.KM_MODE_GCM); + args.addInt(KeymasterDefs.KM_TAG_PADDING, KeymasterDefs.KM_PAD_NONE); OperationResult result = mKeyStore.begin(name, KeymasterDefs.KM_PURPOSE_ENCRYPT, true, args, null, out); IBinder token = result.token; @@ -881,14 +884,18 @@ public class KeyStoreTest extends ActivityUnitTestCase<Activity> { hexToBytes("591ccb10d410ed26dc5ba74a31362870"), hexToBytes("b6ed21b99ca6f4f9f153e7b1beafed1d"), hexToBytes("23304b7a39f9f3ff067d8d8f9e24ecc7")}; + KeymasterArguments beginArgs = new KeymasterArguments(); + beginArgs.addInt(KeymasterDefs.KM_TAG_ALGORITHM, KeymasterDefs.KM_ALGORITHM_AES); + beginArgs.addInt(KeymasterDefs.KM_TAG_BLOCK_MODE, KeymasterDefs.KM_MODE_ECB); + beginArgs.addInt(KeymasterDefs.KM_TAG_PADDING, KeymasterDefs.KM_PAD_NONE); for (int i = 0; i < testVectors.length; i++) { byte[] cipherText = doOperation(name, KeymasterDefs.KM_PURPOSE_ENCRYPT, testVectors[i], - new KeymasterArguments()); + beginArgs); MoreAsserts.assertEquals(cipherVectors[i], cipherText); } for (int i = 0; i < testVectors.length; i++) { byte[] plainText = doOperation(name, KeymasterDefs.KM_PURPOSE_DECRYPT, - cipherVectors[i], new KeymasterArguments()); + cipherVectors[i], beginArgs); MoreAsserts.assertEquals(testVectors[i], plainText); } } @@ -912,6 +919,9 @@ public class KeyStoreTest extends ActivityUnitTestCase<Activity> { KeymasterArguments out = new KeymasterArguments(); args = new KeymasterArguments(); + args.addInt(KeymasterDefs.KM_TAG_ALGORITHM, KeymasterDefs.KM_ALGORITHM_AES); + args.addInt(KeymasterDefs.KM_TAG_BLOCK_MODE, KeymasterDefs.KM_MODE_CTR); + args.addInt(KeymasterDefs.KM_TAG_PADDING, KeymasterDefs.KM_PAD_NONE); OperationResult result = mKeyStore.begin(name, KeymasterDefs.KM_PURPOSE_ENCRYPT, true, args, null, out); assertEquals("Begin should succeed", KeyStore.NO_ERROR, result.resultCode); |