Loading core/java/android/security/IKeystoreService.aidl +1 −1 Original line number Diff line number Diff line Loading @@ -48,7 +48,7 @@ interface IKeystoreService { byte[] sign(String name, in byte[] data); int verify(String name, in byte[] data, in byte[] signature); byte[] get_pubkey(String name); int grant(String name, int granteeUid); String grant(String name, int granteeUid); int ungrant(String name, int granteeUid); long getmtime(String name, int uid); int duplicate(String srcKey, int srcUid, String destKey, int destUid); Loading keystore/java/android/security/KeyStore.java +5 −3 Original line number Diff line number Diff line Loading @@ -341,12 +341,14 @@ public class KeyStore { } } public boolean grant(String key, int uid) { public String grant(String key, int uid) { try { return mBinder.grant(key, uid) == NO_ERROR; String grantAlias = mBinder.grant(key, uid); if (grantAlias == "") return null; return grantAlias; } catch (RemoteException e) { Log.w(TAG, "Cannot connect to keystore", e); return false; return null; } } Loading keystore/tests/src/android/security/KeyStoreTest.java +9 −9 Original line number Diff line number Diff line Loading @@ -483,7 +483,7 @@ public class KeyStoreTest extends ActivityUnitTestCase<Activity> { mKeyStore.generate(TEST_KEYNAME, KeyStore.UID_SELF, NativeConstants.EVP_PKEY_RSA, RSA_KEY_SIZE, KeyStore.FLAG_ENCRYPTED, null)); assertTrue("Should be able to grant key to other user", assertNotNull("Should be able to grant key to other user", mKeyStore.grant(TEST_KEYNAME, 0)); } Loading @@ -493,19 +493,19 @@ public class KeyStoreTest extends ActivityUnitTestCase<Activity> { assertTrue("Should be able to import key for testcase", mKeyStore.importKey(TEST_KEYNAME, PRIVKEY_BYTES, KeyStore.UID_SELF, KeyStore.FLAG_ENCRYPTED)); assertTrue("Should be able to grant key to other user", mKeyStore.grant(TEST_KEYNAME, 0)); assertNotNull("Should be able to grant key to other user", mKeyStore.grant(TEST_KEYNAME, 0)); } public void testGrant_NoKey_Failure() throws Exception { assertTrue("Should be able to unlock keystore for test", mKeyStore.onUserPasswordChanged(TEST_PASSWD)); assertFalse("Should not be able to grant without first initializing the keystore", assertNull("Should not be able to grant without first initializing the keystore", mKeyStore.grant(TEST_KEYNAME, 0)); } public void testGrant_NotInitialized_Failure() throws Exception { assertFalse("Should not be able to grant without first initializing the keystore", assertNull("Should not be able to grant without first initializing the keystore", mKeyStore.grant(TEST_KEYNAME, 0)); } Loading @@ -517,7 +517,7 @@ public class KeyStoreTest extends ActivityUnitTestCase<Activity> { mKeyStore.generate(TEST_KEYNAME, KeyStore.UID_SELF, NativeConstants.EVP_PKEY_RSA, RSA_KEY_SIZE, KeyStore.FLAG_ENCRYPTED, null)); assertTrue("Should be able to grant key to other user", assertNotNull("Should be able to grant key to other user", mKeyStore.grant(TEST_KEYNAME, 0)); assertTrue("Should be able to ungrant key to other user", Loading @@ -531,7 +531,7 @@ public class KeyStoreTest extends ActivityUnitTestCase<Activity> { assertTrue("Should be able to import key for testcase", mKeyStore.importKey(TEST_KEYNAME, PRIVKEY_BYTES, KeyStore.UID_SELF, KeyStore.FLAG_ENCRYPTED)); assertTrue("Should be able to grant key to other user", assertNotNull("Should be able to grant key to other user", mKeyStore.grant(TEST_KEYNAME, 0)); assertTrue("Should be able to ungrant key to other user", Loading Loading @@ -563,7 +563,7 @@ public class KeyStoreTest extends ActivityUnitTestCase<Activity> { mKeyStore.generate(TEST_KEYNAME, KeyStore.UID_SELF, NativeConstants.EVP_PKEY_RSA, RSA_KEY_SIZE, KeyStore.FLAG_ENCRYPTED, null)); assertTrue("Should be able to grant key to other user", assertNotNull("Should be able to grant key to other user", mKeyStore.grant(TEST_KEYNAME, 0)); assertTrue("Should be able to ungrant key to other user", Loading @@ -581,10 +581,10 @@ public class KeyStoreTest extends ActivityUnitTestCase<Activity> { mKeyStore.generate(TEST_KEYNAME, KeyStore.UID_SELF, NativeConstants.EVP_PKEY_RSA, RSA_KEY_SIZE, KeyStore.FLAG_ENCRYPTED, null)); assertTrue("Should be able to grant key to other user", assertNotNull("Should be able to grant key to other user", mKeyStore.grant(TEST_KEYNAME, 0)); assertTrue("Should be able to grant key to other user a second time", assertNotNull("Should be able to grant key to other user a second time", mKeyStore.grant(TEST_KEYNAME, 0)); assertTrue("Should be able to ungrant key to other user", Loading Loading
core/java/android/security/IKeystoreService.aidl +1 −1 Original line number Diff line number Diff line Loading @@ -48,7 +48,7 @@ interface IKeystoreService { byte[] sign(String name, in byte[] data); int verify(String name, in byte[] data, in byte[] signature); byte[] get_pubkey(String name); int grant(String name, int granteeUid); String grant(String name, int granteeUid); int ungrant(String name, int granteeUid); long getmtime(String name, int uid); int duplicate(String srcKey, int srcUid, String destKey, int destUid); Loading
keystore/java/android/security/KeyStore.java +5 −3 Original line number Diff line number Diff line Loading @@ -341,12 +341,14 @@ public class KeyStore { } } public boolean grant(String key, int uid) { public String grant(String key, int uid) { try { return mBinder.grant(key, uid) == NO_ERROR; String grantAlias = mBinder.grant(key, uid); if (grantAlias == "") return null; return grantAlias; } catch (RemoteException e) { Log.w(TAG, "Cannot connect to keystore", e); return false; return null; } } Loading
keystore/tests/src/android/security/KeyStoreTest.java +9 −9 Original line number Diff line number Diff line Loading @@ -483,7 +483,7 @@ public class KeyStoreTest extends ActivityUnitTestCase<Activity> { mKeyStore.generate(TEST_KEYNAME, KeyStore.UID_SELF, NativeConstants.EVP_PKEY_RSA, RSA_KEY_SIZE, KeyStore.FLAG_ENCRYPTED, null)); assertTrue("Should be able to grant key to other user", assertNotNull("Should be able to grant key to other user", mKeyStore.grant(TEST_KEYNAME, 0)); } Loading @@ -493,19 +493,19 @@ public class KeyStoreTest extends ActivityUnitTestCase<Activity> { assertTrue("Should be able to import key for testcase", mKeyStore.importKey(TEST_KEYNAME, PRIVKEY_BYTES, KeyStore.UID_SELF, KeyStore.FLAG_ENCRYPTED)); assertTrue("Should be able to grant key to other user", mKeyStore.grant(TEST_KEYNAME, 0)); assertNotNull("Should be able to grant key to other user", mKeyStore.grant(TEST_KEYNAME, 0)); } public void testGrant_NoKey_Failure() throws Exception { assertTrue("Should be able to unlock keystore for test", mKeyStore.onUserPasswordChanged(TEST_PASSWD)); assertFalse("Should not be able to grant without first initializing the keystore", assertNull("Should not be able to grant without first initializing the keystore", mKeyStore.grant(TEST_KEYNAME, 0)); } public void testGrant_NotInitialized_Failure() throws Exception { assertFalse("Should not be able to grant without first initializing the keystore", assertNull("Should not be able to grant without first initializing the keystore", mKeyStore.grant(TEST_KEYNAME, 0)); } Loading @@ -517,7 +517,7 @@ public class KeyStoreTest extends ActivityUnitTestCase<Activity> { mKeyStore.generate(TEST_KEYNAME, KeyStore.UID_SELF, NativeConstants.EVP_PKEY_RSA, RSA_KEY_SIZE, KeyStore.FLAG_ENCRYPTED, null)); assertTrue("Should be able to grant key to other user", assertNotNull("Should be able to grant key to other user", mKeyStore.grant(TEST_KEYNAME, 0)); assertTrue("Should be able to ungrant key to other user", Loading @@ -531,7 +531,7 @@ public class KeyStoreTest extends ActivityUnitTestCase<Activity> { assertTrue("Should be able to import key for testcase", mKeyStore.importKey(TEST_KEYNAME, PRIVKEY_BYTES, KeyStore.UID_SELF, KeyStore.FLAG_ENCRYPTED)); assertTrue("Should be able to grant key to other user", assertNotNull("Should be able to grant key to other user", mKeyStore.grant(TEST_KEYNAME, 0)); assertTrue("Should be able to ungrant key to other user", Loading Loading @@ -563,7 +563,7 @@ public class KeyStoreTest extends ActivityUnitTestCase<Activity> { mKeyStore.generate(TEST_KEYNAME, KeyStore.UID_SELF, NativeConstants.EVP_PKEY_RSA, RSA_KEY_SIZE, KeyStore.FLAG_ENCRYPTED, null)); assertTrue("Should be able to grant key to other user", assertNotNull("Should be able to grant key to other user", mKeyStore.grant(TEST_KEYNAME, 0)); assertTrue("Should be able to ungrant key to other user", Loading @@ -581,10 +581,10 @@ public class KeyStoreTest extends ActivityUnitTestCase<Activity> { mKeyStore.generate(TEST_KEYNAME, KeyStore.UID_SELF, NativeConstants.EVP_PKEY_RSA, RSA_KEY_SIZE, KeyStore.FLAG_ENCRYPTED, null)); assertTrue("Should be able to grant key to other user", assertNotNull("Should be able to grant key to other user", mKeyStore.grant(TEST_KEYNAME, 0)); assertTrue("Should be able to grant key to other user a second time", assertNotNull("Should be able to grant key to other user a second time", mKeyStore.grant(TEST_KEYNAME, 0)); assertTrue("Should be able to ungrant key to other user", Loading