mirror of
https://github.com/MacPass/MacPass.git
synced 2025-12-13 21:42:32 +00:00
Updated to KeePassKit 2.2 and adopted new API
This commit is contained in:
2
Cartfile
2
Cartfile
@@ -1,3 +1,3 @@
|
|||||||
github "sparkle-project/Sparkle" ~> 1.18.1
|
github "sparkle-project/Sparkle" ~> 1.18.1
|
||||||
github "MacPass/KeePassKit" ~> 1.13.10
|
github "MacPass/KeePassKit" ~> 2.2.0
|
||||||
github "mstarke/HNHUi" ~> 3.0
|
github "mstarke/HNHUi" ~> 3.0
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
github "MacPass/KeePassKit" "1.13.10"
|
github "MacPass/KeePassKit" "2.2.0"
|
||||||
github "mstarke/HNHUi" "3.0"
|
github "mstarke/HNHUi" "3.0"
|
||||||
github "robbiehanson/KissXML" "5.2.3"
|
github "robbiehanson/KissXML" "5.2.3"
|
||||||
github "sparkle-project/Sparkle" "1.20.0"
|
github "sparkle-project/Sparkle" "1.20.0"
|
||||||
|
|||||||
@@ -409,7 +409,8 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGrou
|
|||||||
completionHandler:^BOOL(NSString *password, NSURL *keyURL, BOOL didCancel, NSError *__autoreleasing *error) {
|
completionHandler:^BOOL(NSString *password, NSURL *keyURL, BOOL didCancel, NSError *__autoreleasing *error) {
|
||||||
[self.windowForSheet endSheet:sheet returnCode:(didCancel ? NSModalResponseCancel : NSModalResponseOK)];
|
[self.windowForSheet endSheet:sheet returnCode:(didCancel ? NSModalResponseCancel : NSModalResponseOK)];
|
||||||
if(!didCancel) {
|
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];
|
[self _mergeWithContentsFromURL:url key:compositeKey options:options];
|
||||||
}
|
}
|
||||||
// just return yes regardless since we will display the sheet again if needed!
|
// 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{
|
- (BOOL)unlockWithPassword:(NSString *)password keyFileURL:(NSURL *)keyFileURL error:(NSError *__autoreleasing*)error{
|
||||||
// TODO: Make this API asynchronous
|
// 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];
|
self.tree = [[KPKTree alloc] initWithData:self.encryptedData key:self.compositeKey error:error];
|
||||||
|
|
||||||
BOOL isUnlocked = (nil != self.tree);
|
BOOL isUnlocked = (nil != self.tree);
|
||||||
@@ -500,11 +502,12 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGrou
|
|||||||
if([password length] == 0 && keyFileURL == nil) {
|
if([password length] == 0 && keyFileURL == nil) {
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
NSData *keyFileData = keyFileURL ? [NSData dataWithContentsOfURL:keyFileURL] : nil;
|
||||||
if(!self.compositeKey) {
|
if(!self.compositeKey) {
|
||||||
self.compositeKey = [[KPKCompositeKey alloc] initWithPassword:password key:keyFileURL];
|
self.compositeKey = [[KPKCompositeKey alloc] initWithPassword:password keyFileData:keyFileData];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
[self.compositeKey setPassword:password andKeyfile:keyFileURL];
|
[self.compositeKey setPassword:password andKeyFileData:keyFileData];
|
||||||
}
|
}
|
||||||
self.tree.metaData.masterKeyChanged = [NSDate date];
|
self.tree.metaData.masterKeyChanged = [NSDate date];
|
||||||
/* Key change is not undoable so just recored the change as done */
|
/* Key change is not undoable so just recored the change as done */
|
||||||
|
|||||||
@@ -131,7 +131,7 @@
|
|||||||
|
|
||||||
- (IBAction)generateKey:(id)sender {
|
- (IBAction)generateKey:(id)sender {
|
||||||
MPDocument *document = self.document;
|
MPDocument *document = self.document;
|
||||||
NSData *data = [NSData kpk_generateKeyfiledataForFormat:document.tree.minimumVersion.format];
|
NSData *data = [NSData kpk_generateKeyfileDataForFormat:document.tree.minimumVersion.format];
|
||||||
if(data) {
|
if(data) {
|
||||||
NSSavePanel *savePanel = [NSSavePanel savePanel];
|
NSSavePanel *savePanel = [NSSavePanel savePanel];
|
||||||
savePanel.allowedFileTypes = @[@"key", @"xml"];
|
savePanel.allowedFileTypes = @[@"key", @"xml"];
|
||||||
|
|||||||
Reference in New Issue
Block a user