diff --git a/Cartfile b/Cartfile index a54864ad..88dafb24 100644 --- a/Cartfile +++ b/Cartfile @@ -1,4 +1,4 @@ github "sparkle-project/Sparkle" ~> 1.22 github "MacPass/TransformerKit" "b28de3a7de9249dd886979cae4985092523b6dd1" -github "MacPass/KeePassKit" ~> 2.4 +github "MacPass/KeePassKit" "86266c8211b19f50a55bfdfd293adc783fb0a7b1" github "mstarke/HNHUi" ~> 3.0 diff --git a/Cartfile.resolved b/Cartfile.resolved index 93d35001..9d0ca7a4 100644 --- a/Cartfile.resolved +++ b/Cartfile.resolved @@ -1,5 +1,5 @@ -github "MacPass/KeePassKit" "2.4.7" +github "MacPass/KeePassKit" "86266c8211b19f50a55bfdfd293adc783fb0a7b1" github "MacPass/TransformerKit" "b28de3a7de9249dd886979cae4985092523b6dd1" github "mstarke/HNHUi" "3.0" github "robbiehanson/KissXML" "5.3.1" -github "sparkle-project/Sparkle" "1.22.0" +github "sparkle-project/Sparkle" "v1.23.0" diff --git a/MacPass/MPAppDelegate.m b/MacPass/MPAppDelegate.m index a0304753..cfb655e0 100644 --- a/MacPass/MPAppDelegate.m +++ b/MacPass/MPAppDelegate.m @@ -227,7 +227,7 @@ typedef NS_OPTIONS(NSInteger, MPAppStartupState) { - (void)menuNeedsUpdate:(NSMenu *)menu { if(menu == self.saveMenuItem.menu) { MPDocument *document = NSDocumentController.sharedDocumentController.currentDocument; - BOOL displayDots = (document.fileURL == nil || !document.compositeKey.hasPasswordOrKeyFile); + BOOL displayDots = (document.fileURL == nil || !document.compositeKey.hasKeys); NSString *saveTitle = displayDots ? NSLocalizedString(@"SAVE_WITH_DOTS", "Save file menu item title when save will prompt for a location to save or ask for a password/key") : NSLocalizedString(@"SAVE", "Save file menu item title when save will just save the file"); self.saveMenuItem.title = saveTitle; } diff --git a/MacPass/MPDocument.m b/MacPass/MPDocument.m index 523c2736..1d278774 100644 --- a/MacPass/MPDocument.m +++ b/MacPass/MPDocument.m @@ -155,7 +155,7 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGrou if(self.encryptedData) { return YES; } - if(self.compositeKey.hasPasswordOrKeyFile) { + if(self.compositeKey.hasKeys) { return YES; // key is set, so autosave should be save } @@ -186,7 +186,7 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGrou NSLog(@"%@ should not be called on locked databases!", NSStringFromSelector(_cmd)); return self.encryptedData; } - if(!self.compositeKey.hasPasswordOrKeyFile) { + if(!self.compositeKey.hasKeys) { if(outError != NULL) { NSDictionary *userInfo = @{ NSLocalizedDescriptionKey: NSLocalizedString(@"WARNING_ON_SAVE_NO_PASSWORD_OR_KEY_SET", "") }; *outError = [NSError errorWithDomain:MPDefaultErrorDomain code:0 userInfo:userInfo]; @@ -421,7 +421,9 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGrou [self.windowForSheet endSheet:sheet returnCode:(didCancel ? NSModalResponseCancel : NSModalResponseOK)]; if(!didCancel) { NSData *keyFileData = keyURL ? [NSData dataWithContentsOfURL:keyURL] : nil; - KPKCompositeKey *compositeKey = [[KPKCompositeKey alloc] initWithPassword:password keyFileData:keyFileData]; + KPKCompositeKey *compositeKey = [[KPKCompositeKey alloc] init]; + [compositeKey addKey:[KPKKey keyWithPassword:password]]; + [compositeKey addKey:[KPKKey keyWithKeyFileData:keyFileData]]; [self _mergeWithContentsFromURL:url key:compositeKey options:options]; } // just return yes regardless since we will display the sheet again if needed! @@ -490,7 +492,10 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGrou - (BOOL)unlockWithPassword:(NSString *)password keyFileURL:(NSURL *)keyFileURL error:(NSError *__autoreleasing*)error{ // TODO: Make this API asynchronous NSData *keyFileData = keyFileURL ? [NSData dataWithContentsOfURL:keyFileURL] : nil; - self.compositeKey = [[KPKCompositeKey alloc] initWithPassword:password keyFileData:keyFileData]; + + self.compositeKey = [[KPKCompositeKey alloc] init]; + [self.compositeKey addKey:[KPKKey keyWithPassword:password]]; + [self.compositeKey addKey:[KPKKey keyWithKeyFileData:keyFileData]]; self.tree = [[KPKTree alloc] initWithData:self.encryptedData key:self.compositeKey error:error]; BOOL isUnlocked = (nil != self.tree); @@ -514,13 +519,11 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGrou return NO; } NSData *keyFileData = keyFileURL ? [NSData dataWithContentsOfURL:keyFileURL] : nil; - if(!self.compositeKey) { - self.compositeKey = [[KPKCompositeKey alloc] initWithPassword:password keyFileData:keyFileData]; - } - else { - [self.compositeKey setPassword:password andKeyFileData:keyFileData]; - } - self.tree.metaData.masterKeyChanged = [NSDate date]; + self.compositeKey = [[KPKCompositeKey alloc] init]; + [self.compositeKey addKey:[KPKKey keyWithPassword:password]]; + [self.compositeKey addKey:[KPKKey keyWithKeyFileData:keyFileData]]; + + self.tree.metaData.masterKeyChanged = NSDate.date; /* Key change is not undoable so just recored the change as done */ [self updateChangeCount:NSChangeDone]; /*