From 5a49c5a4649085a7c8ac9e3c3e9b9c3a03615cfd Mon Sep 17 00:00:00 2001 From: eho Date: Mon, 12 Feb 2018 21:06:53 +0100 Subject: [PATCH] Encryption: Get IV directly from the cipher object when encrypting the private key. In Android O and newer (at least) javax.crypto.spec.IvParameterSpec is unsupported. Get the IV directly from the cipher object instead. --- src/main/java/com/owncloud/android/utils/EncryptionUtils.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/owncloud/android/utils/EncryptionUtils.java b/src/main/java/com/owncloud/android/utils/EncryptionUtils.java index fbe36dd13e11..2cfdfcf34ff5 100644 --- a/src/main/java/com/owncloud/android/utils/EncryptionUtils.java +++ b/src/main/java/com/owncloud/android/utils/EncryptionUtils.java @@ -514,7 +514,7 @@ public static String encryptPrivateKey(String privateKey, String keyPhrase) thro byte[] bytes = encodeStringToBase64Bytes(privateKey); byte[] encrypted = cipher.doFinal(bytes); - byte[] iv = cipher.getParameters().getParameterSpec(IvParameterSpec.class).getIV(); + byte[] iv = cipher.getIV(); String encodedIV = encodeBytesToBase64String(iv); String encodedSalt = encodeBytesToBase64String(salt); String encodedEncryptedBytes = encodeBytesToBase64String(encrypted);