diff options
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(); } |