diff --git a/Cartfile b/Cartfile index 97f2c184..641cde94 100644 --- a/Cartfile +++ b/Cartfile @@ -1,3 +1,3 @@ github "sparkle-project/Sparkle" ~> 1.13.1 -github "mstarke/KeePassKit" "ea4d8cd82bc388787d66866e578645693971d453" +github "mstarke/KeePassKit" "f47b82b9404f606fcb0e989bb72df14839c0a35e" github "mstarke/HNHUi" ~> 1.1 diff --git a/Cartfile.resolved b/Cartfile.resolved index 9f1819fe..0962c715 100644 --- a/Cartfile.resolved +++ b/Cartfile.resolved @@ -1,3 +1,3 @@ github "mstarke/HNHUi" "1.1" -github "mstarke/KeePassKit" "ea4d8cd82bc388787d66866e578645693971d453" +github "mstarke/KeePassKit" "f47b82b9404f606fcb0e989bb72df14839c0a35e" github "sparkle-project/Sparkle" "1.14.0" diff --git a/MacPass/MPAutotypeContext.m b/MacPass/MPAutotypeContext.m index 3f1976fd..866ea06f 100644 --- a/MacPass/MPAutotypeContext.m +++ b/MacPass/MPAutotypeContext.m @@ -33,7 +33,7 @@ if(self) { _command = [sequence copy]; _entry = entry; - _normalizedCommand = sequence.normalizedAutotypeSequence; + _normalizedCommand = sequence.kpk_normalizedAutotypeSequence; } return self; } @@ -50,7 +50,7 @@ - (NSString *)evaluatedCommand { if(!_evaluatedCommand) { - _evaluatedCommand = [[self.normalizedCommand finalValueForEntry:self.entry] copy]; + _evaluatedCommand = [[self.normalizedCommand kpk_finalValueForEntry:self.entry] copy]; } return _evaluatedCommand; } diff --git a/MacPass/MPEntryViewController.m b/MacPass/MPEntryViewController.m index c626601b..b989c0a6 100644 --- a/MacPass/MPEntryViewController.m +++ b/MacPass/MPEntryViewController.m @@ -632,7 +632,7 @@ NSString *const _MPTableSecurCellView = @"PasswordCell"; NSArray *nodes = [self currentTargetNodes]; KPKEntry *selectedEntry = nodes.count == 1 ? [nodes.firstObject asEntry] : nil; if(selectedEntry) { - [self _copyToPasteboard:[selectedEntry.password finalValueForEntry:selectedEntry] overlayInfo:MPOverlayInfoPassword name:nil]; + [self _copyToPasteboard:[selectedEntry.password kpk_finalValueForEntry:selectedEntry] overlayInfo:MPOverlayInfoPassword name:nil]; } } @@ -640,7 +640,7 @@ NSString *const _MPTableSecurCellView = @"PasswordCell"; NSArray *nodes = [self currentTargetNodes]; KPKEntry *selectedEntry = nodes.count == 1 ? [nodes.firstObject asEntry] : nil; if(selectedEntry) { - [self _copyToPasteboard:[selectedEntry.username finalValueForEntry:selectedEntry] overlayInfo:MPOverlayInfoUsername name:nil]; + [self _copyToPasteboard:[selectedEntry.username kpk_finalValueForEntry:selectedEntry] overlayInfo:MPOverlayInfoUsername name:nil]; } } @@ -659,14 +659,14 @@ NSString *const _MPTableSecurCellView = @"PasswordCell"; NSArray *nodes = [self currentTargetNodes]; KPKEntry *selectedEntry = nodes.count == 1 ? [nodes.firstObject asEntry] : nil; if(selectedEntry) { - [self _copyToPasteboard:[selectedEntry.url finalValueForEntry:selectedEntry] overlayInfo:MPOverlayInfoURL name:nil]; + [self _copyToPasteboard:[selectedEntry.url kpk_finalValueForEntry:selectedEntry] overlayInfo:MPOverlayInfoURL name:nil]; } } - (void)openURL:(id)sender { NSArray *nodes = [self currentTargetNodes]; KPKEntry *selectedEntry = nodes.count == 1 ? [nodes.firstObject asEntry] : nil; - NSString *expandedURL = [selectedEntry.url finalValueForEntry:selectedEntry]; + NSString *expandedURL = [selectedEntry.url kpk_finalValueForEntry:selectedEntry]; if(expandedURL.length > 0) { NSURL *webURL = [NSURL URLWithString:[expandedURL stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]; NSString *scheme = [webURL scheme]; diff --git a/MacPass/MPOutlineViewController.m b/MacPass/MPOutlineViewController.m index 7c02242e..65d40402 100644 --- a/MacPass/MPOutlineViewController.m +++ b/MacPass/MPOutlineViewController.m @@ -277,7 +277,7 @@ NSString *const _MPOutlinveViewHeaderViewIdentifier = @"HeaderCell"; - (void)outlineViewSelectionDidChange:(NSNotification *)notification { MPDocument *document = self.windowController.document; NSArray *groups = [self currentTargetGroups]; - document.tree.metaData.lastSelectedGroup = (groups.count == 1 ? groups.firstObject.uuid : [NSUUID nullUUID]); + document.tree.metaData.lastSelectedGroup = (groups.count == 1 ? groups.firstObject.uuid : [NSUUID kpk_nullUUID]); document.selectedGroups = groups; } diff --git a/MacPass/MPPasswordEditWindowController.m b/MacPass/MPPasswordEditWindowController.m index 333f687d..8829254d 100644 --- a/MacPass/MPPasswordEditWindowController.m +++ b/MacPass/MPPasswordEditWindowController.m @@ -117,7 +117,7 @@ - (IBAction)generateKey:(id)sender { MPDocument *document = self.document; - NSData *data = [NSData generateKeyfiledataForFormat:document.tree.minimumVersion.format]; + NSData *data = [NSData kpk_generateKeyfiledataForFormat:document.tree.minimumVersion.format]; if(data) { NSSavePanel *savePanel = [NSSavePanel savePanel]; savePanel.allowedFileTypes = @[@"key", @"xml"]; @@ -149,9 +149,9 @@ if(hasKey) { keyOk = [self.keyURL checkResourceIsReachableAndReturnError:nil]; } - BOOL hasPassword = ![NSString isEmptyString:password]; + BOOL hasPassword = password.kpk_isNotEmpty; if(!self.showPassword) { - hasPassword |= ![NSString isEmptyString:repeat]; + hasPassword |= repeat.kpk_isNotEmpty; } BOOL passwordOk = YES; if(hasPassword ) { diff --git a/MacPass/NSString+MPPasswordCreation.m b/MacPass/NSString+MPPasswordCreation.m index ad09ebfc..38f1375a 100644 --- a/MacPass/NSString+MPPasswordCreation.m +++ b/MacPass/NSString+MPPasswordCreation.m @@ -98,7 +98,7 @@ static NSString *mergeWithoutDuplicates(NSString* baseCharacters, NSString* cust if([self length] == 0) { return nil; } - NSData *data = [NSData dataWithRandomBytes:sizeof(NSUInteger)]; + NSData *data = [NSData kpk_dataWithRandomBytes:sizeof(NSUInteger)]; NSUInteger randomIndex; [data getBytes:&randomIndex length:data.length]; return [self substringWithRange:NSMakeRange(randomIndex % self.length, 1)]; diff --git a/MacPassTests/MPDatabaseLoading.m b/MacPassTests/MPDatabaseLoading.m index f6cf0d9c..65d4c9ee 100644 --- a/MacPassTests/MPDatabaseLoading.m +++ b/MacPassTests/MPDatabaseLoading.m @@ -28,8 +28,8 @@ XCTAssertTrue(document.encrypted, @"Loaded but unencrypted should be not decrypted"); XCTAssertTrue([document unlockWithPassword:@"1234" keyFileURL:nil error:&error], @"Should decrypt with password"); XCTAssertNil(error, @"No Error should occur on unlocking with correct password"); - XCTAssertTrue((document.tree.minimumType = KPKDatabaseFormatKdb), @"Minimal Version should not increase with KDB File loaded"); - //STAssertTrue([document.fileType isEqualToString:[MPDocument fileTypeForVersion:KPKLegacyVersion]], @"File type needs to match opened file"); + KPKFileVersion kdb = { KPKDatabaseFormatKdb, kKPKKdbFileVersion }; + XCTAssertEqual(NSOrderedSame, KPKFileVersionCompare(kdb, document.tree.minimumVersion), @"Minimal Version should not increase with KDB File loaded"); } - (void)testVersion1WrongPassword { diff --git a/MacPassTests/MPTestDocument.m b/MacPassTests/MPTestDocument.m index dfe17265..3e7227c6 100644 --- a/MacPassTests/MPTestDocument.m +++ b/MacPassTests/MPTestDocument.m @@ -28,7 +28,8 @@ - (void)testCreateUntitledDocument { MPDocument *document = [[MPDocument alloc] initWithType:@"" error:nil]; XCTAssertNotNil(document, @"Document should be created"); - XCTAssertTrue(document.tree.minimumType == KPKDatabaseFormatKdb, @"Tree should be Legacy Version in default case"); + KPKFileVersion kdb = { KPKDatabaseFormatKdb, kKPKKdbFileVersion }; + XCTAssertEqual(NSOrderedSame, KPKFileVersionCompare(kdb, document.tree.minimumVersion), @"Tree should be Legacy Version in default case"); XCTAssertFalse(document.encrypted, @"Document cannot be encrypted at creation"); XCTAssertFalse(document.compositeKey.hasPasswordOrKeyFile, @"Document has no Password/Keyfile and thus is not secured");