Marino Faggiana 7 年之前
父節點
當前提交
12697977cf

+ 0 - 3
iOSClient/AppDelegate.h

@@ -124,9 +124,6 @@
 @property (nonatomic, strong) NSMutableDictionary *listMainVC;
 @property (nonatomic, strong) NSMutableDictionary *listProgressMetadata;
 
-// E2E Encryption passphrase
-@property (nonatomic, strong) NSString *e2ePassphrase;
-
 // Maintenance Mode
 @property BOOL maintenanceMode;
 

+ 0 - 1
iOSClient/AppDelegate.m

@@ -222,7 +222,6 @@
     [application registerUserNotificationSettings:notificationSettings];
     
     // E2E Encryption
-    self.e2ePassphrase = nil;
     self.endToEndInterface = [NCEntoToEndInterface new];
     
     // Fabric

+ 1 - 0
iOSClient/Nextcloud-Bridging-Header.h

@@ -11,6 +11,7 @@
 #import "NCAutoUpload.h"
 #import "NCUchardet.h"
 #import "NCEndToEndEncryption.h"
+#import "NYMnemonic.h"
 
 #import "OCActivity.h"
 #import "OCUserProfile.h"

+ 6 - 5
iOSClient/Security/NCEntoToEndInterface.swift

@@ -167,7 +167,7 @@ class NCEntoToEndInterface : NSObject, OCNetworkingDelegate  {
         let ok = UIAlertAction(title: "OK", style: .default, handler: { (action) -> Void in
             
             let passphrase = passphraseTextField?.text
-
+            
             guard let privateKey = NCEndToEndEncryption.sharedManager().decryptPrivateKeyCipher(metadataNet.key, passphrase: passphrase) else {
                 
                 self.appDelegate.messageNotification("E2E decrypt private key", description: "E2E Error to decrypt Private Key", visible: true, delay: TimeInterval(k_dismissAfterSecond), type: TWMessageBarMessageType.error, errorCode: 0)
@@ -216,13 +216,14 @@ class NCEntoToEndInterface : NSObject, OCNetworkingDelegate  {
             CCUtility.setEndToEndPassphrase(appDelegate.activeAccount, passphrase: nil)
             
             // message
-            let message = NSLocalizedString("_e2e_settings_start_request_", comment: "") + "\n\n" + NSLocalizedString("_e2e_settings_view_passphrase_", comment: "") + "\n\n"
+            let e2ePassphrase = NYMnemonic.generateString(128, language: "english")
+            let message = "\n" + NSLocalizedString("_e2e_settings_view_passphrase_", comment: "") + "\n\n" + e2ePassphrase!
             
-            let alertController = UIAlertController(title: NSLocalizedString("_start_", comment: ""), message: NSLocalizedString(message, comment: ""), preferredStyle: .alert)
+            let alertController = UIAlertController(title: NSLocalizedString("_e2e_settings_title_", comment: ""), message: NSLocalizedString(message, comment: ""), preferredStyle: .alert)
             
             let OKAction = UIAlertAction(title: NSLocalizedString("_ok_", comment: ""), style: .default) { action in
 
-                guard let privateKeyChiper = NCEndToEndEncryption.sharedManager().createEnd(toEndPrivateKey: self.appDelegate.activeUserID, directoryUser: self.appDelegate.directoryUser, passphrase: self.appDelegate.e2ePassphrase) else {
+                guard let privateKeyChiper = NCEndToEndEncryption.sharedManager().createEnd(toEndPrivateKey: self.appDelegate.activeUserID, directoryUser: self.appDelegate.directoryUser, passphrase: e2ePassphrase) else {
                     
                     self.appDelegate.messageNotification("E2E private keys", description: "E2E Error to create PublicKey chiper", visible: true, delay: TimeInterval(k_dismissAfterSecond), type: TWMessageBarMessageType.error, errorCode: errorCode)
                     
@@ -235,7 +236,7 @@ class NCEntoToEndInterface : NSObject, OCNetworkingDelegate  {
                 
                 metadataNet.action = actionStoreEndToEndPrivateKeyCipher
                 metadataNet.key = privateKeyChiper
-                metadataNet.password = self.appDelegate.e2ePassphrase
+                metadataNet.password = e2ePassphrase
                 
                 self.appDelegate.addNetworkingOperationQueue(self.appDelegate.netQueue, delegate: self, metadataNet: metadataNet)
             }

+ 16 - 18
iOSClient/Settings/NCManageEndToEndEncryption.m

@@ -24,7 +24,6 @@
 #import "NCManageEndToEndEncryption.h"
 #import "AppDelegate.h"
 #import "CCNetworking.h"
-#import "NYMnemonic.h"
 
 #import "NCBridgeSwift.h"
 
@@ -57,24 +56,14 @@
     
     if ([CCUtility isEndToEndEnabled:app.activeAccount]) {
    
-        // Section START E2E -------------------------------------------------
-
-        section = [XLFormSectionDescriptor formSectionWithTitle:NSLocalizedString(@"_e2e_settings_start_", nil)];
+        section = [XLFormSectionDescriptor formSectionWithTitle:NSLocalizedString(@"_e2e_settings_activated_", nil)];
         [form addFormSection:section];
-    
-        // Start e2e
-        row = [XLFormRowDescriptor formRowDescriptorWithTag:@"startE2E" rowType:XLFormRowDescriptorTypeButton title:NSLocalizedString(@"_e2e_settings_start_", nil)];
-        [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"textLabel.font"];
-        [row.cellConfig setObject:[UIColor blackColor] forKey:@"textLabel.textColor"];
-        [row.cellConfig setObject:@(NSTextAlignmentLeft) forKey:@"textLabel.textAlignment"];
-        row.action.formSelector = @selector(startE2E:);
-        [section addFormRow:row];
-   
+        
         // Section PASSPHRASE -------------------------------------------------
-    
+        
         section = [XLFormSectionDescriptor formSectionWithTitle:NSLocalizedString(@"_e2e_settings_read_passphrase_", nil)];
         [form addFormSection:section];
-    
+        
         // Read Passphrase
         row = [XLFormRowDescriptor formRowDescriptorWithTag:@"readPassphrase" rowType:XLFormRowDescriptorTypeButton title:NSLocalizedString(@"_e2e_settings_read_passphrase_", nil)];
         [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"textLabel.font"];
@@ -84,9 +73,18 @@
         [section addFormRow:row];
         
     } else {
-        
-        section = [XLFormSectionDescriptor formSectionWithTitle:NSLocalizedString(@"_e2e_settings_started_", nil)];
+        // Section START E2E -------------------------------------------------
+
+        section = [XLFormSectionDescriptor formSectionWithTitle:NSLocalizedString(@"_e2e_settings_start_", nil)];
         [form addFormSection:section];
+    
+        // Start e2e
+        row = [XLFormRowDescriptor formRowDescriptorWithTag:@"startE2E" rowType:XLFormRowDescriptorTypeButton title:NSLocalizedString(@"_e2e_settings_start_", nil)];
+        [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"textLabel.font"];
+        [row.cellConfig setObject:[UIColor blackColor] forKey:@"textLabel.textColor"];
+        [row.cellConfig setObject:@(NSTextAlignmentLeft) forKey:@"textLabel.textAlignment"];
+        row.action.formSelector = @selector(startE2E:);
+        [section addFormRow:row];   
     }
     
 #ifdef DEBUG
@@ -232,7 +230,7 @@
 {
     [aViewController dismissViewControllerAnimated:YES completion:nil];
     
-    NSString *message = [NSString stringWithFormat:@"%@\n%@", NSLocalizedString(@"_e2e_settings_the_passphrase_is_", nil), [CCUtility getEndToEndPassphrase:app.activeAccount]];
+    NSString *message = [NSString stringWithFormat:@"\n%@\n\n\n%@", NSLocalizedString(@"_e2e_settings_the_passphrase_is_", nil), [CCUtility getEndToEndPassphrase:app.activeAccount]];
     
     UIAlertController *alertController = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"_info_", nil) message:message preferredStyle:UIAlertControllerStyleAlert];
     UIAlertAction *okAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"OK", @"OK action") style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {

+ 1 - 2
iOSClient/Supporting Files/en.lproj/Localizable.strings

@@ -583,10 +583,9 @@
 "_e2e_settings_"                    = "End To End Encryption";
 "_e2e_settings_start_"              = "Start End To End Encryption";
 "_e2e_settings_not_available_"      = "End To End Encryption not available";
-"_e2e_settings_start_request_"      = "Do you want to start the End To End Encryption?";
 "_e2e_settings_activated_"          = "End To End Encryption activated";
 "_e2e_settings_view_passphrase_"    = "This 12 word phrase is like a very strong password: it provides full access to view and use your encrypted files. Please write it down and keep it somewhere safe.";
 "_e2e_settings_read_passphrase_"    = "Read passphrase";
 "_e2e_settings_lock_not_active_"    = "Lock not active, go back to \"Settings\" and activate it";
-"_e2e_settings_the_passphrase_is_"  = "The passphrase is: \n\n";
+"_e2e_settings_the_passphrase_is_"  = "The passphrase is:";