Loading keystore/java/android/security/KeyStore.java +27 −4 Original line number Original line Diff line number Diff line Loading @@ -77,6 +77,7 @@ public class KeyStore { public static final int VALUE_CORRUPTED = 8; public static final int VALUE_CORRUPTED = 8; public static final int UNDEFINED_ACTION = 9; public static final int UNDEFINED_ACTION = 9; public static final int WRONG_PASSWORD = 10; public static final int WRONG_PASSWORD = 10; public static final int KEY_ALREADY_EXISTS = 16; public static final int CANNOT_ATTEST_IDS = -66; public static final int CANNOT_ATTEST_IDS = -66; public static final int HARDWARE_TYPE_UNAVAILABLE = -68; public static final int HARDWARE_TYPE_UNAVAILABLE = -68; Loading Loading @@ -247,7 +248,12 @@ public class KeyStore { if (value == null) { if (value == null) { value = new byte[0]; value = new byte[0]; } } return mBinder.insert(key, value, uid, flags); int error = mBinder.insert(key, value, uid, flags); if (error == KEY_ALREADY_EXISTS) { mBinder.del(key, uid); error = mBinder.insert(key, value, uid, flags); } return error; } catch (RemoteException e) { } catch (RemoteException e) { Log.w(TAG, "Cannot connect to keystore", e); Log.w(TAG, "Cannot connect to keystore", e); return SYSTEM_ERROR; return SYSTEM_ERROR; Loading Loading @@ -457,7 +463,12 @@ public class KeyStore { try { try { entropy = entropy != null ? entropy : new byte[0]; entropy = entropy != null ? entropy : new byte[0]; args = args != null ? args : new KeymasterArguments(); args = args != null ? args : new KeymasterArguments(); return mBinder.generateKey(alias, args, entropy, uid, flags, outCharacteristics); int error = mBinder.generateKey(alias, args, entropy, uid, flags, outCharacteristics); if (error == KEY_ALREADY_EXISTS) { mBinder.del(alias, uid); error = mBinder.generateKey(alias, args, entropy, uid, flags, outCharacteristics); } return error; } catch (RemoteException e) { } catch (RemoteException e) { Log.w(TAG, "Cannot connect to keystore", e); Log.w(TAG, "Cannot connect to keystore", e); return SYSTEM_ERROR; return SYSTEM_ERROR; Loading Loading @@ -489,8 +500,14 @@ public class KeyStore { public int importKey(String alias, KeymasterArguments args, int format, byte[] keyData, public int importKey(String alias, KeymasterArguments args, int format, byte[] keyData, int uid, int flags, KeyCharacteristics outCharacteristics) { int uid, int flags, KeyCharacteristics outCharacteristics) { try { try { return mBinder.importKey(alias, args, format, keyData, uid, flags, int error = mBinder.importKey(alias, args, format, keyData, uid, flags, outCharacteristics); if (error == KEY_ALREADY_EXISTS) { mBinder.del(alias, uid); error = mBinder.importKey(alias, args, format, keyData, uid, flags, outCharacteristics); outCharacteristics); } return error; } catch (RemoteException e) { } catch (RemoteException e) { Log.w(TAG, "Cannot connect to keystore", e); Log.w(TAG, "Cannot connect to keystore", e); return SYSTEM_ERROR; return SYSTEM_ERROR; Loading Loading @@ -566,8 +583,14 @@ public class KeyStore { byte[] maskingKey, KeymasterArguments args, long rootSid, long fingerprintSid, int uid, byte[] maskingKey, KeymasterArguments args, long rootSid, long fingerprintSid, int uid, KeyCharacteristics outCharacteristics) { KeyCharacteristics outCharacteristics) { try { try { return mBinder.importWrappedKey(wrappedKeyAlias, wrappedKey, wrappingKeyAlias, int error = mBinder.importWrappedKey(wrappedKeyAlias, wrappedKey, wrappingKeyAlias, maskingKey, args, rootSid, fingerprintSid, outCharacteristics); if (error == KEY_ALREADY_EXISTS) { mBinder.del(wrappedKeyAlias, -1); error = mBinder.importWrappedKey(wrappedKeyAlias, wrappedKey, wrappingKeyAlias, maskingKey, args, rootSid, fingerprintSid, outCharacteristics); maskingKey, args, rootSid, fingerprintSid, outCharacteristics); } return error; } catch (RemoteException e) { } catch (RemoteException e) { Log.w(TAG, "Cannot connect to keystore", e); Log.w(TAG, "Cannot connect to keystore", e); return SYSTEM_ERROR; return SYSTEM_ERROR; Loading Loading
keystore/java/android/security/KeyStore.java +27 −4 Original line number Original line Diff line number Diff line Loading @@ -77,6 +77,7 @@ public class KeyStore { public static final int VALUE_CORRUPTED = 8; public static final int VALUE_CORRUPTED = 8; public static final int UNDEFINED_ACTION = 9; public static final int UNDEFINED_ACTION = 9; public static final int WRONG_PASSWORD = 10; public static final int WRONG_PASSWORD = 10; public static final int KEY_ALREADY_EXISTS = 16; public static final int CANNOT_ATTEST_IDS = -66; public static final int CANNOT_ATTEST_IDS = -66; public static final int HARDWARE_TYPE_UNAVAILABLE = -68; public static final int HARDWARE_TYPE_UNAVAILABLE = -68; Loading Loading @@ -247,7 +248,12 @@ public class KeyStore { if (value == null) { if (value == null) { value = new byte[0]; value = new byte[0]; } } return mBinder.insert(key, value, uid, flags); int error = mBinder.insert(key, value, uid, flags); if (error == KEY_ALREADY_EXISTS) { mBinder.del(key, uid); error = mBinder.insert(key, value, uid, flags); } return error; } catch (RemoteException e) { } catch (RemoteException e) { Log.w(TAG, "Cannot connect to keystore", e); Log.w(TAG, "Cannot connect to keystore", e); return SYSTEM_ERROR; return SYSTEM_ERROR; Loading Loading @@ -457,7 +463,12 @@ public class KeyStore { try { try { entropy = entropy != null ? entropy : new byte[0]; entropy = entropy != null ? entropy : new byte[0]; args = args != null ? args : new KeymasterArguments(); args = args != null ? args : new KeymasterArguments(); return mBinder.generateKey(alias, args, entropy, uid, flags, outCharacteristics); int error = mBinder.generateKey(alias, args, entropy, uid, flags, outCharacteristics); if (error == KEY_ALREADY_EXISTS) { mBinder.del(alias, uid); error = mBinder.generateKey(alias, args, entropy, uid, flags, outCharacteristics); } return error; } catch (RemoteException e) { } catch (RemoteException e) { Log.w(TAG, "Cannot connect to keystore", e); Log.w(TAG, "Cannot connect to keystore", e); return SYSTEM_ERROR; return SYSTEM_ERROR; Loading Loading @@ -489,8 +500,14 @@ public class KeyStore { public int importKey(String alias, KeymasterArguments args, int format, byte[] keyData, public int importKey(String alias, KeymasterArguments args, int format, byte[] keyData, int uid, int flags, KeyCharacteristics outCharacteristics) { int uid, int flags, KeyCharacteristics outCharacteristics) { try { try { return mBinder.importKey(alias, args, format, keyData, uid, flags, int error = mBinder.importKey(alias, args, format, keyData, uid, flags, outCharacteristics); if (error == KEY_ALREADY_EXISTS) { mBinder.del(alias, uid); error = mBinder.importKey(alias, args, format, keyData, uid, flags, outCharacteristics); outCharacteristics); } return error; } catch (RemoteException e) { } catch (RemoteException e) { Log.w(TAG, "Cannot connect to keystore", e); Log.w(TAG, "Cannot connect to keystore", e); return SYSTEM_ERROR; return SYSTEM_ERROR; Loading Loading @@ -566,8 +583,14 @@ public class KeyStore { byte[] maskingKey, KeymasterArguments args, long rootSid, long fingerprintSid, int uid, byte[] maskingKey, KeymasterArguments args, long rootSid, long fingerprintSid, int uid, KeyCharacteristics outCharacteristics) { KeyCharacteristics outCharacteristics) { try { try { return mBinder.importWrappedKey(wrappedKeyAlias, wrappedKey, wrappingKeyAlias, int error = mBinder.importWrappedKey(wrappedKeyAlias, wrappedKey, wrappingKeyAlias, maskingKey, args, rootSid, fingerprintSid, outCharacteristics); if (error == KEY_ALREADY_EXISTS) { mBinder.del(wrappedKeyAlias, -1); error = mBinder.importWrappedKey(wrappedKeyAlias, wrappedKey, wrappingKeyAlias, maskingKey, args, rootSid, fingerprintSid, outCharacteristics); maskingKey, args, rootSid, fingerprintSid, outCharacteristics); } return error; } catch (RemoteException e) { } catch (RemoteException e) { Log.w(TAG, "Cannot connect to keystore", e); Log.w(TAG, "Cannot connect to keystore", e); return SYSTEM_ERROR; return SYSTEM_ERROR; Loading