Browse Source

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.
eho 7 years ago
parent
commit
5a49c5a464
1 changed files with 1 additions and 1 deletions
  1. 1 1
      src/main/java/com/owncloud/android/utils/EncryptionUtils.java

+ 1 - 1
src/main/java/com/owncloud/android/utils/EncryptionUtils.java

@@ -514,7 +514,7 @@ public class EncryptionUtils {
         byte[] bytes = encodeStringToBase64Bytes(privateKey);
         byte[] bytes = encodeStringToBase64Bytes(privateKey);
         byte[] encrypted = cipher.doFinal(bytes);
         byte[] encrypted = cipher.doFinal(bytes);
 
 
-        byte[] iv = cipher.getParameters().getParameterSpec(IvParameterSpec.class).getIV();
+        byte[] iv = cipher.getIV();
         String encodedIV = encodeBytesToBase64String(iv);
         String encodedIV = encodeBytesToBase64String(iv);
         String encodedSalt = encodeBytesToBase64String(salt);
         String encodedSalt = encodeBytesToBase64String(salt);
         String encodedEncryptedBytes = encodeBytesToBase64String(encrypted);
         String encodedEncryptedBytes = encodeBytesToBase64String(encrypted);