diff --git a/Cartfile b/Cartfile
index 2e749ae4..0da8ceef 100644
--- a/Cartfile
+++ b/Cartfile
@@ -1,3 +1,3 @@
github "sparkle-project/Sparkle" ~> 1.13.1
-github "mstarke/KeePassKit" "f4f7c56c2c081ae129f88e6004411ecc8ef9ae0c"
+github "mstarke/KeePassKit" "32d3bdeb224b5718424b46a5b80c3a66114f6a9b"
github "mstarke/HNHUi" ~> 1.1
diff --git a/Cartfile.resolved b/Cartfile.resolved
index 7b2a37f6..4d18d2d5 100644
--- a/Cartfile.resolved
+++ b/Cartfile.resolved
@@ -1,3 +1,3 @@
github "mstarke/HNHUi" "1.1"
-github "mstarke/KeePassKit" "f4f7c56c2c081ae129f88e6004411ecc8ef9ae0c"
+github "mstarke/KeePassKit" "32d3bdeb224b5718424b46a5b80c3a66114f6a9b"
github "sparkle-project/Sparkle" "1.14.0"
diff --git a/MacPass/Base.lproj/DatabaseSettingsWindow.xib b/MacPass/Base.lproj/DatabaseSettingsWindow.xib
index a21239b8..45b6344d 100644
--- a/MacPass/Base.lproj/DatabaseSettingsWindow.xib
+++ b/MacPass/Base.lproj/DatabaseSettingsWindow.xib
@@ -9,6 +9,10 @@
+
+
+
+
@@ -24,6 +28,7 @@
+
@@ -37,14 +42,14 @@
-
+
-
+
-
+
-
+
-
+
@@ -90,7 +95,7 @@ Gw
-
+
@@ -98,7 +103,7 @@ Gw
-
+
@@ -106,7 +111,7 @@ Gw
-
+
@@ -119,7 +124,7 @@ Gw
-
+
@@ -127,7 +132,7 @@ Gw
-
+
@@ -135,7 +140,7 @@ Gw
-
+
@@ -143,7 +148,7 @@ Gw
-
+
@@ -200,11 +205,11 @@ Gw
-
+
-
+
@@ -212,7 +217,7 @@ Gw
-
+
@@ -220,13 +225,13 @@ Gw
-
+
-
+
-
+
@@ -234,7 +239,7 @@ Gw
-
+
@@ -242,32 +247,114 @@ Gw
-
-
+
+
-
+
+
+
+
+
+
+
+
+
-
+
+
+
+
+
+
+
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -275,60 +362,27 @@ Gw
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -336,9 +390,10 @@ Gw
+
-
-
+
+
@@ -363,7 +418,7 @@ Gw
-
+
-
+
diff --git a/MacPass/DocumentWindow.xib b/MacPass/DocumentWindow.xib
index 6beb332f..a5000851 100644
--- a/MacPass/DocumentWindow.xib
+++ b/MacPass/DocumentWindow.xib
@@ -1,8 +1,9 @@
-
-
+
+
-
+
+
@@ -17,11 +18,12 @@
-
+
+
diff --git a/MacPass/MPDatabaseSettingsWindowController.h b/MacPass/MPDatabaseSettingsWindowController.h
index dfc8c826..c35a1679 100644
--- a/MacPass/MPDatabaseSettingsWindowController.h
+++ b/MacPass/MPDatabaseSettingsWindowController.h
@@ -29,11 +29,17 @@ typedef NS_ENUM(NSUInteger, MPDatabaseSettingsTab) {
@property (weak) IBOutlet NSColorWell *databaseColorColorWell;
/* Security Tab */
-@property (weak) IBOutlet NSTextField *AESEncryptionRoundsTextField;
@property (weak) IBOutlet NSButton *createKeyDerivationParametersButton;
@property (weak) IBOutlet NSPopUpButton *encryptionPopupButton;
@property (weak) IBOutlet NSPopUpButton *keyDerivationPopupButton;
+@property (weak) IBOutlet NSTabView *keyDerivationSettingsTabView;
+/* AES */
+@property (weak) IBOutlet NSTextField *AESEncryptionRoundsTextField;
+/* Argon2 */
+@property (weak) IBOutlet NSTextField *Argon2ThreadsTextField;
+@property (weak) IBOutlet NSTextField *Argon2IterationsTextField;
+@property (weak) IBOutlet NSTextField *Argon2MemoryTextField;
/* Advanced Tab*/
@property (weak) IBOutlet NSButton *enableHistoryCheckButton;
diff --git a/MacPass/MPDatabaseSettingsWindowController.m b/MacPass/MPDatabaseSettingsWindowController.m
index c60ba84f..7cab942c 100644
--- a/MacPass/MPDatabaseSettingsWindowController.m
+++ b/MacPass/MPDatabaseSettingsWindowController.m
@@ -23,7 +23,6 @@
@interface MPDatabaseSettingsWindowController () {
NSString *_missingFeature;
}
-
@end
@implementation MPDatabaseSettingsWindowController
@@ -48,7 +47,6 @@
self.sectionTabView.delegate = self;
self.AESEncryptionRoundsTextField.formatter = [[MPNumericalInputFormatter alloc] init];
-
NSMenu *kdfMenu = [[NSMenu alloc] init];
NSArray *keyderivations = [KPKKeyDerivation availableKeyDerivations];
for(KPKKeyDerivation *kd in keyderivations) {
@@ -56,6 +54,9 @@
kdfMenu.itemArray.lastObject.representedObject = kd.uuid;
}
self.keyDerivationPopupButton.menu = kdfMenu;
+ self.keyDerivationPopupButton.target = self;
+ self.keyDerivationPopupButton.action = @selector(selectKeyDerivation:);
+
NSMenu *cipherMenu = [[NSMenu alloc] init];
NSArray *ciphers = [KPKCipher availableCiphers];
for(KPKCipher *cipher in ciphers) {
@@ -63,10 +64,17 @@
cipherMenu.itemArray.lastObject.representedObject = cipher.uuid;
}
self.encryptionPopupButton.menu = cipherMenu;
+ self.keyDerivationSettingsTabView.tabViewItems[0].identifier = [KPKAESKeyDerivation uuid];
+ self.keyDerivationSettingsTabView.tabViewItems[1].identifier = [KPKArgon2KeyDerivation uuid];
}
#pragma mark Actions
+- (IBAction)selectKeyDerivation:(id)sender {
+ NSUUID *uuid = self.keyDerivationPopupButton.selectedItem.representedObject;
+ [self.keyDerivationSettingsTabView selectTabViewItemWithIdentifier:uuid];
+}
+
- (IBAction)save:(id)sender {
/* General */
KPKMetaData *metaData = ((MPDocument *)self.document).tree.metaData;
@@ -112,6 +120,7 @@
metaData.defaultUserName = self.defaultUsernameTextField.stringValue;
+ /* fixme! */
metaData.keyDerivationParameters = @{ KPKAESRoundsOption : [[KPKNumber alloc] initWithUnsignedInteger64: MAX(0,self.AESEncryptionRoundsTextField.integerValue)]};
/* Register an action to enable promts when user cloeses without saving */
@@ -181,12 +190,44 @@
}
- (void)_setupSecurityTab:(KPKMetaData *)metaData {
- [self.AESEncryptionRoundsTextField setIntegerValue:[metaData.keyDerivationParameters[KPKAESRoundsOption] unsignedInteger64Value]];
+ /* Tab 0 AES Tab 1 Argon2 */
+ KPKKeyDerivation *keyDerivation = [KPKKeyDerivation keyDerivationWithParameters:metaData.keyDerivationParameters];
- self.createKeyDerivationParametersButton.enabled = YES;
+ NSUInteger kdfIndex = [self.keyDerivationPopupButton.menu indexOfItemWithRepresentedObject:keyDerivation.uuid];
+ [self.keyDerivationPopupButton selectItemAtIndex:kdfIndex];
+
+ if([keyDerivation isKindOfClass:[KPKAESKeyDerivation class]]) {
+ [self.keyDerivationSettingsTabView selectTabViewItemAtIndex:0];
+ KPKAESKeyDerivation *aesKDF = (KPKAESKeyDerivation *)keyDerivation;
+ self.AESEncryptionRoundsTextField.integerValue = aesKDF.rounds;
+ self.createKeyDerivationParametersButton.enabled = YES;
+
+ /* fill defautls for Argon2 */
+ KPKArgon2KeyDerivation *argon2Kdf = [[KPKArgon2KeyDerivation alloc] initWithParameters:[KPKArgon2KeyDerivation defaultParameters]];
+ self.Argon2IterationsTextField.integerValue = argon2Kdf.iterations;
+ self.Argon2MemoryTextField.integerValue = argon2Kdf.memory;
+ self.Argon2ThreadsTextField.integerValue = argon2Kdf.threads;
+ }
+ else if([keyDerivation isKindOfClass:[KPKArgon2KeyDerivation class]]) {
+ [self.keyDerivationSettingsTabView selectTabViewItemAtIndex:1];
+ KPKArgon2KeyDerivation *argon2KDF = (KPKArgon2KeyDerivation *)keyDerivation;
+ self.Argon2MemoryTextField.integerValue = argon2KDF.memory;
+ self.Argon2ThreadsTextField.integerValue = argon2KDF.threads;
+ self.Argon2IterationsTextField.integerValue = argon2KDF.iterations;
+
+ /* fill defaults for AES */
+ KPKAESKeyDerivation *aesKdf = [[KPKAESKeyDerivation alloc] initWithParameters:[KPKAESKeyDerivation defaultParameters]];
+ self.AESEncryptionRoundsTextField.integerValue = aesKdf.rounds;
+ }
+ else {
+
+ }
+
+ NSUInteger cipherIndex = [self.encryptionPopupButton.menu indexOfItemWithRepresentedObject:metaData.cipherUUID];
+ [self.encryptionPopupButton selectItemAtIndex:cipherIndex];
}
-- (void)_setupAdvancedTab:(KPKTree *)tree {
+- (void)_setupAdvancedTab:(KPKTree *)tree {
HNHUISetStateFromBool(self.enableTrashCheckButton, tree.metaData.useTrash);
self.selectTrashGoupPopUpButton.enabled = tree.metaData.useTrash;
[self.enableTrashCheckButton bind:NSValueBinding toObject:self.selectTrashGoupPopUpButton withKeyPath:NSEnabledBinding options:nil];