diff options
author | Oscar Montemayor <oam@google.com> | 2010-01-14 16:38:40 -0800 |
---|---|---|
committer | Oscar Montemayor <oam@google.com> | 2010-01-15 11:16:31 -0800 |
commit | b62e8132df0d19a39a700324475b3df2de78e0b0 (patch) | |
tree | e5679e990fc995de73fc2c35dd03082c0efd7ebb /keystore/tests | |
parent | 013b9c249dbcb5ca293c5cfe6a0e7908ced32418 (diff) | |
download | frameworks_base-b62e8132df0d19a39a700324475b3df2de78e0b0.zip frameworks_base-b62e8132df0d19a39a700324475b3df2de78e0b0.tar.gz frameworks_base-b62e8132df0d19a39a700324475b3df2de78e0b0.tar.bz2 |
Apps on SD card.
Added support for retrieving and generating keys as Hex Strings.
Diffstat (limited to 'keystore/tests')
-rw-r--r-- | keystore/tests/src/android/security/SystemKeyStoreTest.java | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/keystore/tests/src/android/security/SystemKeyStoreTest.java b/keystore/tests/src/android/security/SystemKeyStoreTest.java index a85f889..bbeceeb 100644 --- a/keystore/tests/src/android/security/SystemKeyStoreTest.java +++ b/keystore/tests/src/android/security/SystemKeyStoreTest.java @@ -32,6 +32,7 @@ import android.test.suitebuilder.annotation.MediumTest; public class SystemKeyStoreTest extends ActivityUnitTestCase<Activity> { private static final String keyName = "TestKey"; + private static final String keyName2 = "TestKey2"; private SystemKeyStore mSysKeyStore = null; public SystemKeyStoreTest() { @@ -43,6 +44,7 @@ public class SystemKeyStoreTest extends ActivityUnitTestCase<Activity> { mSysKeyStore = SystemKeyStore.getInstance(); try { mSysKeyStore.deleteKey(keyName); + mSysKeyStore.deleteKey(keyName2); } catch (Exception e) { } super.setUp(); } @@ -51,6 +53,7 @@ public class SystemKeyStoreTest extends ActivityUnitTestCase<Activity> { protected void tearDown() throws Exception { try { mSysKeyStore.deleteKey(keyName); + mSysKeyStore.deleteKey(keyName2); } catch (Exception e) { } super.tearDown(); } @@ -67,6 +70,14 @@ public class SystemKeyStoreTest extends ActivityUnitTestCase<Activity> { mSysKeyStore.deleteKey(keyName); byte[] nullKey = mSysKeyStore.retrieveKey(keyName); assertNull(nullKey); + + String newKeyStr = mSysKeyStore.generateNewKeyHexString(128, "AES", keyName2); + assertNotNull(newKeyStr); + String recKeyStr = mSysKeyStore.retrieveKeyHexString(keyName2); + assertEquals(newKeyStr, recKeyStr); + mSysKeyStore.deleteKey(keyName2); + String nullKey2 = mSysKeyStore.retrieveKeyHexString(keyName); + assertNull(nullKey2); } catch (Exception e) { fail(); } |