Browse Source

Update NCEndToEndMetadataV20.swift

Marino Faggiana 1 year ago
parent
commit
4e7df94f99
1 changed files with 5 additions and 1 deletions
  1. 5 1
      iOSClient/Networking/E2EE/NCEndToEndMetadataV20.swift

+ 5 - 1
iOSClient/Networking/E2EE/NCEndToEndMetadataV20.swift

@@ -50,6 +50,7 @@ extension NCEndToEndMetadata {
 
         if let user = NCManageDatabase.shared.getE2EUsersV2(account: account, serverUrl: serverUrl, userId: userId) {
             encryptedMetadataKey = user.encryptedMetadataKey
+            metadataKey = user.metadataKey
         } else {
             guard let keyGenerated = NCEndToEndEncryption.sharedManager()?.generateKey() as? Data else { return (nil, nil) }
             decryptedMetadataKey = keyGenerated
@@ -107,10 +108,13 @@ extension NCEndToEndMetadata {
             let jsonZip = try json.gzipped()
             let ciphertext = NCEndToEndEncryption.sharedManager().encryptPayloadFile(jsonZip, key: metadataKey, initializationVector: &initializationVector, authenticationTag: &authenticationTag)
 
-            guard let ciphertext, let initializationVector = initializationVector as? String, let authenticationTag = authenticationTag as? String else {
+            guard var ciphertext, let initializationVector = initializationVector as? String, let authenticationTag = authenticationTag as? String else {
                 return (nil, nil)
             }
 
+            // Add initializationVector [ANDROID]
+            ciphertext = ciphertext + "|" + initializationVector
+
             let metadataCodable = E2eeV20.Metadata(ciphertext: ciphertext, nonce: initializationVector, authenticationTag: authenticationTag)
 
             let e2eeCodable = E2eeV20(metadata: metadataCodable, users: usersCodable, filedrop: filedropCodable, version: "2.0")