瀏覽代碼

Update NCEndToEndEncryption.m

Marino Faggiana 1 年之前
父節點
當前提交
fd54c35517
共有 1 個文件被更改,包括 10 次插入0 次删除
  1. 10 0
      iOSClient/Networking/E2EE/NCEndToEndEncryption.m

+ 10 - 0
iOSClient/Networking/E2EE/NCEndToEndEncryption.m

@@ -848,7 +848,10 @@
         return NO;
 
     NSInputStream *inStream = [NSInputStream inputStreamWithFileAtPath:fileName];
+    NSOutputStream *outStream = [NSOutputStream outputStreamToFileAtPath:fileNameCipher append:false];
     [inStream open];
+    [outStream open];
+
     Byte buffer[1024];
     while ([inStream hasBytesAvailable])
     {
@@ -860,8 +863,15 @@
         int cCipherLen = 0;
 
         status = EVP_EncryptUpdate(ctx, cCipher, &cCipherLen, [inData bytes], bytesRead);
+        [outStream write:cCipher maxLength:cCipherLen];
     }
+
+    // Finalise the encryption
+    //status = EVP_EncryptFinal_ex(ctx, cCipher+cCipherLen, &len);
+
+
     [inStream close];
+    [outStream close];
 
     /*
     // Provide the message to be encrypted, and obtain the encrypted output