diff --git a/Cartfile b/Cartfile index 091cffa4..fdc6d66c 100644 --- a/Cartfile +++ b/Cartfile @@ -1,4 +1,4 @@ github "sparkle-project/Sparkle" ~> 1.22 github "mattt/TransformerKit" ~> 1.1.1 -github "MacPass/KeePassKit" "53fb31cd39eb56b75a27867aa4594f73e380863c" +github "MacPass/KeePassKit" "76e6ecda942f9e328efde7883ad75aed7290b632" github "mstarke/HNHUi" ~> 4.0 diff --git a/Cartfile.resolved b/Cartfile.resolved index 6a86b77f..c86226d2 100644 --- a/Cartfile.resolved +++ b/Cartfile.resolved @@ -1,4 +1,4 @@ -github "MacPass/KeePassKit" "53fb31cd39eb56b75a27867aa4594f73e380863c" +github "MacPass/KeePassKit" "76e6ecda942f9e328efde7883ad75aed7290b632" github "mattt/TransformerKit" "1.1.1" github "mstarke/HNHUi" "4.0.3" github "robbiehanson/KissXML" "5.3.3" diff --git a/MacPass/Base.lproj/DatabaseSettingsWindow.xib b/MacPass/Base.lproj/DatabaseSettingsWindow.xib index 969e6b5c..6a8cb127 100644 --- a/MacPass/Base.lproj/DatabaseSettingsWindow.xib +++ b/MacPass/Base.lproj/DatabaseSettingsWindow.xib @@ -1,8 +1,8 @@ - + - + @@ -52,12 +52,12 @@ - - + + - + - + - + @@ -103,7 +103,7 @@ Gw - + @@ -111,7 +111,7 @@ Gw - + @@ -119,7 +119,7 @@ Gw - + @@ -132,7 +132,7 @@ Gw - + @@ -140,7 +140,7 @@ Gw - + @@ -148,7 +148,7 @@ Gw - + @@ -156,10 +156,10 @@ Gw - + - + @@ -186,7 +186,7 @@ Gw - + @@ -194,7 +194,7 @@ Gw - + @@ -236,11 +236,11 @@ Gw - + - + @@ -251,7 +251,7 @@ Gw - + @@ -259,29 +259,29 @@ Gw - + - + - + - + - + @@ -289,7 +289,7 @@ Gw - + @@ -314,13 +314,13 @@ Gw - + - + - + @@ -328,7 +328,7 @@ Gw - + @@ -336,7 +336,7 @@ Gw - + @@ -351,7 +351,7 @@ Gw - + @@ -363,7 +363,7 @@ Gw - + @@ -372,7 +372,7 @@ Gw - + @@ -380,7 +380,7 @@ Gw - + @@ -411,10 +411,16 @@ Gw + + + + + + - + @@ -425,7 +431,7 @@ Gw - + diff --git a/MacPass/MPDatabaseSettingsWindowController.m b/MacPass/MPDatabaseSettingsWindowController.m index a40efaf7..86351d48 100644 --- a/MacPass/MPDatabaseSettingsWindowController.m +++ b/MacPass/MPDatabaseSettingsWindowController.m @@ -92,7 +92,8 @@ } self.cipherPopupButton.menu = cipherMenu; self.keyDerivationSettingsTabView.tabViewItems[0].identifier = [KPKAESKeyDerivation uuid]; - self.keyDerivationSettingsTabView.tabViewItems[1].identifier = [KPKArgon2KeyDerivation uuid]; + self.keyDerivationSettingsTabView.tabViewItems[1].identifier = [KPKArgon2DKeyDerivation uuid]; + self.keyDerivationSettingsTabView.tabViewItems[2].identifier = [KPKArgon2IDKeyDerivation uuid]; } #pragma mark Actions @@ -164,7 +165,8 @@ metaData.cipherUUID = self.cipherPopupButton.selectedItem.representedObject; KPKAESKeyDerivation *aesKdf = [[KPKAESKeyDerivation alloc] initWithParameters:[KPKAESKeyDerivation defaultParameters]]; - KPKArgon2KeyDerivation *argon2Kdf = [[KPKArgon2KeyDerivation alloc] initWithParameters:[KPKArgon2KeyDerivation defaultParameters]]; + KPKArgon2DKeyDerivation *argon2Kdf = [[KPKArgon2DKeyDerivation alloc] initWithParameters:[KPKArgon2DKeyDerivation defaultParameters]]; + // FIXME: add Argon2id support! NSUUID *selectedKdfUUID = self.keyDerivationSettingsTabView.selectedTabViewItem.identifier; @@ -273,19 +275,21 @@ [self.keyDerivationPopupButton selectItemAtIndex:kdfIndex]; [self.keyDerivationSettingsTabView selectTabViewItemWithIdentifier:keyDerivation.uuid]; - if([keyDerivation isMemberOfClass:[KPKAESKeyDerivation class]]) { + if([keyDerivation isMemberOfClass:KPKAESKeyDerivation.class]) { + /* set to database values */ KPKAESKeyDerivation *aesKdf = (KPKAESKeyDerivation *)keyDerivation; self.aesEncryptionRoundsTextField.integerValue = aesKdf.rounds; self.createKeyDerivationParametersButton.enabled = YES; /* fill defaults for Argon2 */ - KPKArgon2KeyDerivation *argon2Kdf = [[KPKArgon2KeyDerivation alloc] initWithParameters:[KPKArgon2KeyDerivation defaultParameters]]; + KPKArgon2DKeyDerivation *argon2Kdf = [[KPKArgon2DKeyDerivation alloc] initWithParameters:[KPKArgon2DKeyDerivation defaultParameters]]; self.argon2IterationsTextField.integerValue = argon2Kdf.iterations; self.argon2Memory = argon2Kdf.memory; self.argon2ThreadsTextField.integerValue = argon2Kdf.threads; } - else if([keyDerivation isMemberOfClass:[KPKArgon2KeyDerivation class]]) { - KPKArgon2KeyDerivation *argon2Kdf = (KPKArgon2KeyDerivation *)keyDerivation; + else if([keyDerivation isMemberOfClass:KPKArgon2DKeyDerivation.class]) { + /* set to database value */ + KPKArgon2DKeyDerivation *argon2Kdf = (KPKArgon2DKeyDerivation *)keyDerivation; self.argon2Memory = argon2Kdf.memory; self.argon2ThreadsTextField.integerValue = argon2Kdf.threads; self.argon2IterationsTextField.integerValue = argon2Kdf.iterations; @@ -294,6 +298,9 @@ KPKAESKeyDerivation *aesKdf = [[KPKAESKeyDerivation alloc] initWithParameters:[KPKAESKeyDerivation defaultParameters]]; self.aesEncryptionRoundsTextField.integerValue = aesKdf.rounds; } + else if([keyDerivation isMemberOfClass:KPKArgon2IDKeyDerivation.class]) { + // TODO: implement setup! + } else { NSAssert(NO, @"Unkown key derivation"); } diff --git a/MacPass/MPDocument.m b/MacPass/MPDocument.m index 5366b278..1c3bbbf6 100644 --- a/MacPass/MPDocument.m +++ b/MacPass/MPDocument.m @@ -147,11 +147,9 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGrou [self addWindowController:windowController]; } -/* - (BOOL)canAsynchronouslyWriteToURL:(NSURL *)url ofType:(NSString *)typeName forSaveOperation:(NSSaveOperationType)saveOperation { return YES; } - */ - (BOOL)checkAutosavingSafetyAndReturnError:(NSError **)outError { if(![super checkAutosavingSafetyAndReturnError:outError]) { @@ -208,10 +206,15 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGrou } return nil; // We do not know what version to save! } - - // FIXME: add [self unblockUserInteraction] to enable async save in background! - // this requires a "snapshot" of the tree to be made and stored! - return [self.tree encryptWithKey:self.compositeKey format:format error:outError]; + // create a copy to allow for unblocking user interaction + NSLog(@"Copying tree to save…"); + KPKTree *copy = [self.tree copy]; + NSLog(@"Created copy…"); + [self unblockUserInteraction]; + NSLog(@"Starting encryption…"); + NSData *data = [copy encryptWithKey:self.compositeKey format:format error:outError]; + NSLog(@"Finished encryption…"); + return data; } - (BOOL)readFromURL:(NSURL *)url ofType:(NSString *)typeName error:(NSError **)outError { diff --git a/MacPass/MPTOTPSetupViewController.m b/MacPass/MPTOTPSetupViewController.m index 2316068a..1b483ffd 100644 --- a/MacPass/MPTOTPSetupViewController.m +++ b/MacPass/MPTOTPSetupViewController.m @@ -101,7 +101,7 @@ typedef NS_ENUM(NSUInteger, MPOTPType) { } - (void)_updateView:(MPOTPUpdateSource)source { - self.generator = [[KPKTimeOTPGenerator alloc] initWithEntry:((KPKEntry *)self.representedObject)]; + self.generator = [[KPKTimeOTPGenerator alloc] initWithAttributes:((KPKEntry *)self.representedObject).attributes]; if(source == MPOTPUpdateSourceQRImage) { NSString *qrCodeString = self.qrCodeImageView.image.QRCodeString; diff --git a/MacPass/MPTOTPViewController.m b/MacPass/MPTOTPViewController.m index 8e76c6cb..f0160958 100644 --- a/MacPass/MPTOTPViewController.m +++ b/MacPass/MPTOTPViewController.m @@ -54,7 +54,7 @@ BOOL showTOTP = entry.hasTimeOTP; self.view.hidden = !showTOTP; if(showTOTP) { - self.generator = [[KPKTimeOTPGenerator alloc] initWithEntry:entry]; + self.generator = [[KPKTimeOTPGenerator alloc] initWithAttributes:entry.attributes]; self.generator.time = NSDate.date.timeIntervalSince1970; NSString *stringValue = self.generator.string; self.toptValueTextField.stringValue = stringValue ? stringValue : @"";