Program: 163836
Project: 163836
Buggy source:
public static void importSaltAndEncryptedKeyMaterial(Context context,String[] saltAndEncryptedKeyMaterial) throws GeneralSecurityException, InvalidMacException, IOException {
  Log.d(TAG,"String_Node_Str");
  Optional<String> masterPassphrase=KeyStore.getMasterPassphrase(context);
  if (!masterPassphrase.isPresent())   throw new InvalidMacException("String_Node_Str");
  byte[] salt=Base64.decode(saltAndEncryptedKeyMaterial[0]);
  SecretKey[] masterKeys=KeyUtil.getCipherAndMacKeysForPassphrase(salt,masterPassphrase.get());
  SecretKey masterCipherKey=masterKeys[0];
  SecretKey masterMacKey=masterKeys[1];
  MasterCipher masterCipher=new MasterCipher(masterCipherKey,masterMacKey);
  byte[] plaintextKeyMaterial=masterCipher.decodeAndDecrypt(saltAndEncryptedKeyMaterial[1].getBytes());
  boolean saltLengthValid=salt.length == KeyUtil.SALT_LENGTH_BYTES;
  boolean keyMaterialLengthValid=plaintextKeyMaterial.length == (KeyUtil.CIPHER_KEY_LENGTH_BYTES + KeyUtil.MAC_KEY_LENGTH_BYTES);
  if (!saltLengthValid || !keyMaterialLengthValid)   throw new GeneralSecurityException("String_Node_Str" + saltLengthValid + "String_Node_Str"+ keyMaterialLengthValid);
  byte[] plaintextCipherKey=Arrays.copyOfRange(plaintextKeyMaterial,0,KeyUtil.CIPHER_KEY_LENGTH_BYTES);
  byte[] plaintextMacKey=Arrays.copyOfRange(plaintextKeyMaterial,KeyUtil.CIPHER_KEY_LENGTH_BYTES,plaintextCipherKey.length);
  KeyStore.saveEncryptedKeyMaterial(context,saltAndEncryptedKeyMaterial[1]);
  KeyStore.saveKeyMaterialSalt(context,salt);
  KeyStore.saveCipherKey(context,plaintextCipherKey);
  KeyStore.saveMacKey(context,plaintextMacKey);
}

Fixed version (ground truth):
public static void importSaltAndEncryptedKeyMaterial(Context context,String[] saltAndEncryptedKeyMaterial) throws GeneralSecurityException, InvalidMacException, IOException {
  Log.d(TAG,"String_Node_Str");
  Optional<String> masterPassphrase=KeyStore.getMasterPassphrase(context);
  if (!masterPassphrase.isPresent())   throw new InvalidMacException("String_Node_Str");
  byte[] salt=Base64.decode(saltAndEncryptedKeyMaterial[0]);
  SecretKey[] masterKeys=KeyUtil.getCipherAndMacKeysForPassphrase(salt,masterPassphrase.get());
  SecretKey masterCipherKey=masterKeys[0];
  SecretKey masterMacKey=masterKeys[1];
  MasterCipher masterCipher=new MasterCipher(masterCipherKey,masterMacKey);
  byte[] plaintextKeyMaterial=masterCipher.decodeAndDecrypt(saltAndEncryptedKeyMaterial[1].getBytes());
  boolean saltLengthValid=salt.length == KeyUtil.SALT_LENGTH_BYTES;
  boolean keyMaterialLengthValid=plaintextKeyMaterial.length == (KeyUtil.CIPHER_KEY_LENGTH_BYTES + KeyUtil.MAC_KEY_LENGTH_BYTES);
  if (!saltLengthValid || !keyMaterialLengthValid)   throw new GeneralSecurityException("String_Node_Str" + saltLengthValid + "String_Node_Str"+ keyMaterialLengthValid);
  byte[] plaintextCipherKey=Arrays.copyOfRange(plaintextKeyMaterial,0,KeyUtil.CIPHER_KEY_LENGTH_BYTES);
  byte[] plaintextMacKey=Arrays.copyOfRange(plaintextKeyMaterial,KeyUtil.CIPHER_KEY_LENGTH_BYTES,KeyUtil.CIPHER_KEY_LENGTH_BYTES + KeyUtil.MAC_KEY_LENGTH_BYTES);
  KeyStore.saveEncryptedKeyMaterial(context,saltAndEncryptedKeyMaterial[1]);
  KeyStore.saveKeyMaterialSalt(context,salt);
  KeyStore.saveCipherKey(context,plaintextCipherKey);
  KeyStore.saveMacKey(context,plaintextMacKey);
}