Browse Source

re-add: always use new key / iv on upload

Signed-off-by: tobiasKaminsky <tobias@kaminsky.me>
tobiasKaminsky 7 years ago
parent
commit
16080f8d05

+ 4 - 22
src/main/java/com/owncloud/android/operations/UploadFileOperation.java

@@ -88,8 +88,6 @@ import java.util.Set;
 import java.util.UUID;
 import java.util.concurrent.atomic.AtomicBoolean;
 
-import static com.owncloud.android.utils.EncryptionUtils.encodeStringToBase64Bytes;
-
 
 /**
  * Operation performing the update in the ownCloud server
@@ -496,27 +494,11 @@ public class UploadFileOperation extends SyncOperation {
 
             /***** E2E *****/
 
-            // Key
-            byte[] key = null;
-
-            if (metadata.files.get(mFile.getFileName()) != null) {
-                key = encodeStringToBase64Bytes(metadata.files.get(mFile.getFileName()).encrypted.key);
-            }
-
-            if (key == null || key.length == 0) {
-                key = EncryptionUtils.generateKey();
-            }
+            // Key, always generate new one
+            byte[] key = EncryptionUtils.generateKey();
 
-            // IV
-            byte[] iv = null;
-
-            if (metadata.files.get(mFile.getFileName()) != null) {
-                iv = encodeStringToBase64Bytes(metadata.files.get(mFile.getFileName()).initializationVector);
-            }
-
-            if (iv == null || iv.length == 0) {
-                iv = EncryptionUtils.randomBytes(EncryptionUtils.ivLength);
-            }
+            // IV, always generate new one
+            byte[] iv = EncryptionUtils.randomBytes(EncryptionUtils.ivLength);
 
             EncryptionUtils.EncryptedFile encryptedFile = EncryptionUtils.encryptFile(mFile, key, iv);