diff --git a/Cartfile b/Cartfile index eaaaee28..d400f66e 100644 --- a/Cartfile +++ b/Cartfile @@ -1,3 +1,3 @@ github "sparkle-project/Sparkle" ~> 1.18.1 -github "MacPass/KeePassKit" ~> 1.13.10 +github "MacPass/KeePassKit" ~> 2.2.0 github "mstarke/HNHUi" ~> 3.0 diff --git a/Cartfile.resolved b/Cartfile.resolved index 46a0eef5..f00178ab 100644 --- a/Cartfile.resolved +++ b/Cartfile.resolved @@ -1,4 +1,4 @@ -github "MacPass/KeePassKit" "1.13.10" +github "MacPass/KeePassKit" "2.2.0" github "mstarke/HNHUi" "3.0" github "robbiehanson/KissXML" "5.2.3" github "sparkle-project/Sparkle" "1.20.0" diff --git a/MacPass/MPDocument.m b/MacPass/MPDocument.m index 64632dd1..8f57636f 100644 --- a/MacPass/MPDocument.m +++ b/MacPass/MPDocument.m @@ -409,7 +409,8 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGrou completionHandler:^BOOL(NSString *password, NSURL *keyURL, BOOL didCancel, NSError *__autoreleasing *error) { [self.windowForSheet endSheet:sheet returnCode:(didCancel ? NSModalResponseCancel : NSModalResponseOK)]; if(!didCancel) { - KPKCompositeKey *compositeKey = [[KPKCompositeKey alloc] initWithPassword:password key:keyURL]; + NSData *keyFileData = keyURL ? [NSData dataWithContentsOfURL:keyURL] : nil; + KPKCompositeKey *compositeKey = [[KPKCompositeKey alloc] initWithPassword:password keyFileData:keyFileData]; [self _mergeWithContentsFromURL:url key:compositeKey options:options]; } // just return yes regardless since we will display the sheet again if needed! @@ -477,7 +478,8 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGrou - (BOOL)unlockWithPassword:(NSString *)password keyFileURL:(NSURL *)keyFileURL error:(NSError *__autoreleasing*)error{ // TODO: Make this API asynchronous - self.compositeKey = [[KPKCompositeKey alloc] initWithPassword:password key:keyFileURL]; + NSData *keyFileData = keyFileURL ? [NSData dataWithContentsOfURL:keyFileURL] : nil; + self.compositeKey = [[KPKCompositeKey alloc] initWithPassword:password keyFileData:keyFileData]; self.tree = [[KPKTree alloc] initWithData:self.encryptedData key:self.compositeKey error:error]; BOOL isUnlocked = (nil != self.tree); @@ -500,11 +502,12 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGrou if([password length] == 0 && keyFileURL == nil) { return NO; } + NSData *keyFileData = keyFileURL ? [NSData dataWithContentsOfURL:keyFileURL] : nil; if(!self.compositeKey) { - self.compositeKey = [[KPKCompositeKey alloc] initWithPassword:password key:keyFileURL]; + self.compositeKey = [[KPKCompositeKey alloc] initWithPassword:password keyFileData:keyFileData]; } else { - [self.compositeKey setPassword:password andKeyfile:keyFileURL]; + [self.compositeKey setPassword:password andKeyFileData:keyFileData]; } self.tree.metaData.masterKeyChanged = [NSDate date]; /* Key change is not undoable so just recored the change as done */ diff --git a/MacPass/MPPasswordEditWindowController.m b/MacPass/MPPasswordEditWindowController.m index f2971c75..56cfb2bd 100644 --- a/MacPass/MPPasswordEditWindowController.m +++ b/MacPass/MPPasswordEditWindowController.m @@ -131,7 +131,7 @@ - (IBAction)generateKey:(id)sender { MPDocument *document = self.document; - NSData *data = [NSData kpk_generateKeyfiledataForFormat:document.tree.minimumVersion.format]; + NSData *data = [NSData kpk_generateKeyfileDataForFormat:document.tree.minimumVersion.format]; if(data) { NSSavePanel *savePanel = [NSSavePanel savePanel]; savePanel.allowedFileTypes = @[@"key", @"xml"];