Loading android/app/src/com/android/bluetooth/btservice/bluetoothKeystore/BluetoothKeystoreService.java +5 −19 Original line number Diff line number Diff line Loading @@ -31,7 +31,6 @@ import java.io.IOException; import java.io.InputStream; import java.nio.file.Files; import java.nio.file.Paths; import java.nio.file.StandardCopyOption; import java.security.InvalidAlgorithmParameterException; import java.security.InvalidKeyException; import java.security.KeyStore; Loading @@ -42,9 +41,9 @@ import java.security.NoSuchProviderException; import java.security.ProviderException; import java.security.UnrecoverableEntryException; import java.security.cert.CertificateException; import java.util.ArrayList; import java.util.Base64; import java.util.HashMap; import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Objects; Loading Loading @@ -92,10 +91,6 @@ public class BluetoothKeystoreService { private static final String CONFIG_FILE_PATH = "/data/misc/bluedroid/bt_config.conf"; private static final String CONFIG_BACKUP_PATH = "/data/misc/bluedroid/bt_config.bak"; private static final String CONFIG_FILE_CHECKSUM_PATH = "/data/misc/bluedroid/bt_config.conf.encrypted-checksum"; private static final String CONFIG_BACKUP_CHECKSUM_PATH = "/data/misc/bluedroid/bt_config.bak.encrypted-checksum"; private static final int BUFFER_SIZE = 400 * 10; Loading Loading @@ -449,8 +444,8 @@ public class BluetoothKeystoreService { @VisibleForTesting public void saveEncryptedKey() { stopThread(); List<String> configEncryptedLines = new LinkedList<>(); List<String> keyEncryptedLines = new LinkedList<>(); List<String> configEncryptedLines = new ArrayList<>(); List<String> keyEncryptedLines = new ArrayList<>(); for (String key : mNameEncryptKey.keySet()) { if (key.equals(CONFIG_FILE_PREFIX) || key.equals(CONFIG_BACKUP_PREFIX)) { configEncryptedLines.add(getEncryptedKeyData(key)); Loading Loading @@ -554,7 +549,7 @@ public class BluetoothKeystoreService { } byte[] messageDigestBytes = messageDigest.digest(); StringBuffer hashString = new StringBuffer(); StringBuilder hashString = new StringBuilder(); for (int index = 0; index < messageDigestBytes.length; index++) { hashString.append(Integer.toString(( messageDigestBytes[index] & 0xff) + 0x100, 16).substring(1)); Loading @@ -573,15 +568,6 @@ public class BluetoothKeystoreService { } } private void readChecksumFile(String filePathString, String prefixString) throws IOException { if (!Files.exists(Paths.get(filePathString))) { return; } byte[] allBytes = Files.readAllBytes(Paths.get(filePathString)); String checksumDataBase64 = mEncoder.encodeToString(allBytes); mNameEncryptKey.put(prefixString, checksumDataBase64); } /** * Parses a file to search for the key and put it into the pending compute queue */ Loading Loading @@ -729,7 +715,7 @@ public class BluetoothKeystoreService { /** * Decrypt the original data blob from the provided {@link EncryptedData}. * * @param data String as base64 to be decrypted. * @param encryptedDataBase64 String as base64 to be decrypted. * @return String. */ private @Nullable String decrypt(String encryptedDataBase64) { Loading Loading
android/app/src/com/android/bluetooth/btservice/bluetoothKeystore/BluetoothKeystoreService.java +5 −19 Original line number Diff line number Diff line Loading @@ -31,7 +31,6 @@ import java.io.IOException; import java.io.InputStream; import java.nio.file.Files; import java.nio.file.Paths; import java.nio.file.StandardCopyOption; import java.security.InvalidAlgorithmParameterException; import java.security.InvalidKeyException; import java.security.KeyStore; Loading @@ -42,9 +41,9 @@ import java.security.NoSuchProviderException; import java.security.ProviderException; import java.security.UnrecoverableEntryException; import java.security.cert.CertificateException; import java.util.ArrayList; import java.util.Base64; import java.util.HashMap; import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Objects; Loading Loading @@ -92,10 +91,6 @@ public class BluetoothKeystoreService { private static final String CONFIG_FILE_PATH = "/data/misc/bluedroid/bt_config.conf"; private static final String CONFIG_BACKUP_PATH = "/data/misc/bluedroid/bt_config.bak"; private static final String CONFIG_FILE_CHECKSUM_PATH = "/data/misc/bluedroid/bt_config.conf.encrypted-checksum"; private static final String CONFIG_BACKUP_CHECKSUM_PATH = "/data/misc/bluedroid/bt_config.bak.encrypted-checksum"; private static final int BUFFER_SIZE = 400 * 10; Loading Loading @@ -449,8 +444,8 @@ public class BluetoothKeystoreService { @VisibleForTesting public void saveEncryptedKey() { stopThread(); List<String> configEncryptedLines = new LinkedList<>(); List<String> keyEncryptedLines = new LinkedList<>(); List<String> configEncryptedLines = new ArrayList<>(); List<String> keyEncryptedLines = new ArrayList<>(); for (String key : mNameEncryptKey.keySet()) { if (key.equals(CONFIG_FILE_PREFIX) || key.equals(CONFIG_BACKUP_PREFIX)) { configEncryptedLines.add(getEncryptedKeyData(key)); Loading Loading @@ -554,7 +549,7 @@ public class BluetoothKeystoreService { } byte[] messageDigestBytes = messageDigest.digest(); StringBuffer hashString = new StringBuffer(); StringBuilder hashString = new StringBuilder(); for (int index = 0; index < messageDigestBytes.length; index++) { hashString.append(Integer.toString(( messageDigestBytes[index] & 0xff) + 0x100, 16).substring(1)); Loading @@ -573,15 +568,6 @@ public class BluetoothKeystoreService { } } private void readChecksumFile(String filePathString, String prefixString) throws IOException { if (!Files.exists(Paths.get(filePathString))) { return; } byte[] allBytes = Files.readAllBytes(Paths.get(filePathString)); String checksumDataBase64 = mEncoder.encodeToString(allBytes); mNameEncryptKey.put(prefixString, checksumDataBase64); } /** * Parses a file to search for the key and put it into the pending compute queue */ Loading Loading @@ -729,7 +715,7 @@ public class BluetoothKeystoreService { /** * Decrypt the original data blob from the provided {@link EncryptedData}. * * @param data String as base64 to be decrypted. * @param encryptedDataBase64 String as base64 to be decrypted. * @return String. */ private @Nullable String decrypt(String encryptedDataBase64) { Loading