Loading services/core/java/com/android/server/MountService.java +5 −23 Original line number Original line Diff line number Diff line Loading @@ -76,7 +76,6 @@ import android.util.Xml; import libcore.io.IoUtils; import libcore.io.IoUtils; import libcore.util.EmptyArray; import libcore.util.EmptyArray; import libcore.util.HexEncoding; import com.android.internal.annotations.GuardedBy; import com.android.internal.annotations.GuardedBy; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.annotations.VisibleForTesting; Loading Loading @@ -2078,23 +2077,6 @@ class MountService extends IMountService.Stub } } } } private static String toHex(String password) { if (password == null) { return ""; } byte[] bytes = password.getBytes(StandardCharsets.UTF_8); return new String(HexEncoding.encode(bytes)); } private static String fromHex(String hexPassword) throws IllegalArgumentException { if (hexPassword == null) { return null; } final byte[] bytes = HexEncoding.decode(hexPassword.toCharArray(), false); return new String(bytes, StandardCharsets.UTF_8); } @Override @Override public int decryptStorage(String password) { public int decryptStorage(String password) { if (TextUtils.isEmpty(password)) { if (TextUtils.isEmpty(password)) { Loading @@ -2112,7 +2094,7 @@ class MountService extends IMountService.Stub final NativeDaemonEvent event; final NativeDaemonEvent event; try { try { event = mCryptConnector.execute("cryptfs", "checkpw", new SensitiveArg(toHex(password))); event = mCryptConnector.execute("cryptfs", "checkpw", new SensitiveArg(password)); final int code = Integer.parseInt(event.getMessage()); final int code = Integer.parseInt(event.getMessage()); if (code == 0) { if (code == 0) { Loading Loading @@ -2152,7 +2134,7 @@ class MountService extends IMountService.Stub try { try { mCryptConnector.execute("cryptfs", "enablecrypto", "inplace", CRYPTO_TYPES[type], mCryptConnector.execute("cryptfs", "enablecrypto", "inplace", CRYPTO_TYPES[type], new SensitiveArg(toHex(password))); new SensitiveArg(password)); } catch (NativeDaemonConnectorException e) { } catch (NativeDaemonConnectorException e) { // Encryption failed // Encryption failed return e.getCode(); return e.getCode(); Loading @@ -2177,7 +2159,7 @@ class MountService extends IMountService.Stub try { try { NativeDaemonEvent event = mCryptConnector.execute("cryptfs", "changepw", CRYPTO_TYPES[type], NativeDaemonEvent event = mCryptConnector.execute("cryptfs", "changepw", CRYPTO_TYPES[type], new SensitiveArg(toHex(password))); new SensitiveArg(password)); return Integer.parseInt(event.getMessage()); return Integer.parseInt(event.getMessage()); } catch (NativeDaemonConnectorException e) { } catch (NativeDaemonConnectorException e) { // Encryption failed // Encryption failed Loading Loading @@ -2210,7 +2192,7 @@ class MountService extends IMountService.Stub final NativeDaemonEvent event; final NativeDaemonEvent event; try { try { event = mCryptConnector.execute("cryptfs", "verifypw", new SensitiveArg(toHex(password))); event = mCryptConnector.execute("cryptfs", "verifypw", new SensitiveArg(password)); Slog.i(TAG, "cryptfs verifypw => " + event.getMessage()); Slog.i(TAG, "cryptfs verifypw => " + event.getMessage()); return Integer.parseInt(event.getMessage()); return Integer.parseInt(event.getMessage()); } catch (NativeDaemonConnectorException e) { } catch (NativeDaemonConnectorException e) { Loading Loading @@ -2300,7 +2282,7 @@ class MountService extends IMountService.Stub // -1 equals no password // -1 equals no password return null; return null; } } return fromHex(event.getMessage()); return event.getMessage(); } catch (NativeDaemonConnectorException e) { } catch (NativeDaemonConnectorException e) { throw e.rethrowAsParcelableException(); throw e.rethrowAsParcelableException(); } catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) { Loading Loading
services/core/java/com/android/server/MountService.java +5 −23 Original line number Original line Diff line number Diff line Loading @@ -76,7 +76,6 @@ import android.util.Xml; import libcore.io.IoUtils; import libcore.io.IoUtils; import libcore.util.EmptyArray; import libcore.util.EmptyArray; import libcore.util.HexEncoding; import com.android.internal.annotations.GuardedBy; import com.android.internal.annotations.GuardedBy; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.annotations.VisibleForTesting; Loading Loading @@ -2078,23 +2077,6 @@ class MountService extends IMountService.Stub } } } } private static String toHex(String password) { if (password == null) { return ""; } byte[] bytes = password.getBytes(StandardCharsets.UTF_8); return new String(HexEncoding.encode(bytes)); } private static String fromHex(String hexPassword) throws IllegalArgumentException { if (hexPassword == null) { return null; } final byte[] bytes = HexEncoding.decode(hexPassword.toCharArray(), false); return new String(bytes, StandardCharsets.UTF_8); } @Override @Override public int decryptStorage(String password) { public int decryptStorage(String password) { if (TextUtils.isEmpty(password)) { if (TextUtils.isEmpty(password)) { Loading @@ -2112,7 +2094,7 @@ class MountService extends IMountService.Stub final NativeDaemonEvent event; final NativeDaemonEvent event; try { try { event = mCryptConnector.execute("cryptfs", "checkpw", new SensitiveArg(toHex(password))); event = mCryptConnector.execute("cryptfs", "checkpw", new SensitiveArg(password)); final int code = Integer.parseInt(event.getMessage()); final int code = Integer.parseInt(event.getMessage()); if (code == 0) { if (code == 0) { Loading Loading @@ -2152,7 +2134,7 @@ class MountService extends IMountService.Stub try { try { mCryptConnector.execute("cryptfs", "enablecrypto", "inplace", CRYPTO_TYPES[type], mCryptConnector.execute("cryptfs", "enablecrypto", "inplace", CRYPTO_TYPES[type], new SensitiveArg(toHex(password))); new SensitiveArg(password)); } catch (NativeDaemonConnectorException e) { } catch (NativeDaemonConnectorException e) { // Encryption failed // Encryption failed return e.getCode(); return e.getCode(); Loading @@ -2177,7 +2159,7 @@ class MountService extends IMountService.Stub try { try { NativeDaemonEvent event = mCryptConnector.execute("cryptfs", "changepw", CRYPTO_TYPES[type], NativeDaemonEvent event = mCryptConnector.execute("cryptfs", "changepw", CRYPTO_TYPES[type], new SensitiveArg(toHex(password))); new SensitiveArg(password)); return Integer.parseInt(event.getMessage()); return Integer.parseInt(event.getMessage()); } catch (NativeDaemonConnectorException e) { } catch (NativeDaemonConnectorException e) { // Encryption failed // Encryption failed Loading Loading @@ -2210,7 +2192,7 @@ class MountService extends IMountService.Stub final NativeDaemonEvent event; final NativeDaemonEvent event; try { try { event = mCryptConnector.execute("cryptfs", "verifypw", new SensitiveArg(toHex(password))); event = mCryptConnector.execute("cryptfs", "verifypw", new SensitiveArg(password)); Slog.i(TAG, "cryptfs verifypw => " + event.getMessage()); Slog.i(TAG, "cryptfs verifypw => " + event.getMessage()); return Integer.parseInt(event.getMessage()); return Integer.parseInt(event.getMessage()); } catch (NativeDaemonConnectorException e) { } catch (NativeDaemonConnectorException e) { Loading Loading @@ -2300,7 +2282,7 @@ class MountService extends IMountService.Stub // -1 equals no password // -1 equals no password return null; return null; } } return fromHex(event.getMessage()); return event.getMessage(); } catch (NativeDaemonConnectorException e) { } catch (NativeDaemonConnectorException e) { throw e.rethrowAsParcelableException(); throw e.rethrowAsParcelableException(); } catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) { Loading