From 3b74543c51e99ad49e8a716f705b40b576bcc4d6 Mon Sep 17 00:00:00 2001 From: Maarten Billemont Date: Sat, 23 Apr 2016 23:56:16 -0400 Subject: [PATCH] Security answer generation for question keywords. --- MasterPassword/ObjC/MPEntities.h | 1 + MasterPassword/ObjC/MPEntities.m | 8 +++ .../ObjC/Mac/MPPasswordWindowController.m | 3 ++ .../ObjC/Mac/MPPasswordWindowController.xib | 53 +++++++++++-------- MasterPassword/ObjC/Mac/MPSiteModel.m | 5 +- 5 files changed, 46 insertions(+), 24 deletions(-) diff --git a/MasterPassword/ObjC/MPEntities.h b/MasterPassword/ObjC/MPEntities.h index c2368667..347fd811 100644 --- a/MasterPassword/ObjC/MPEntities.h +++ b/MasterPassword/ObjC/MPEntities.h @@ -49,6 +49,7 @@ - (void)resolveLoginUsingKey:(MPKey *)key result:(void ( ^ )(NSString *))result; - (void)resolvePasswordUsingKey:(MPKey *)key result:(void ( ^ )(NSString *))result; - (void)resolveSiteAnswerUsingKey:(MPKey *)key result:(void ( ^ )(NSString *))result; +- (void)resolveAnswerUsingKey:(MPKey *)key forQuestion:(NSString *)question result:(void ( ^ )(NSString *))result; @end diff --git a/MasterPassword/ObjC/MPEntities.m b/MasterPassword/ObjC/MPEntities.m index 5ae3259d..f78651d6 100644 --- a/MasterPassword/ObjC/MPEntities.m +++ b/MasterPassword/ObjC/MPEntities.m @@ -209,6 +209,14 @@ [self.algorithm resolveAnswerForSite:self usingKey:key result:result]; } +- (void)resolveAnswerUsingKey:(MPKey *)key forQuestion:(NSString *)question result:(void ( ^ )(NSString *))result { + + MPSiteQuestionEntity *questionEntity = [MPSiteQuestionEntity new]; + questionEntity.site = self; + questionEntity.keyword = question; + [questionEntity resolveQuestionAnswerUsingKey:key result:result]; +} + @end @implementation MPGeneratedSiteEntity(MP) diff --git a/MasterPassword/ObjC/Mac/MPPasswordWindowController.m b/MasterPassword/ObjC/Mac/MPPasswordWindowController.m index c8d9c26e..7376380c 100644 --- a/MasterPassword/ObjC/Mac/MPPasswordWindowController.m +++ b/MasterPassword/ObjC/Mac/MPPasswordWindowController.m @@ -433,6 +433,9 @@ break; } }]; + PearlMainQueueAfter(2, ^{ + [[[alert buttons] firstObject] becomeFirstResponder]; + }); } #pragma mark - Private diff --git a/MasterPassword/ObjC/Mac/MPPasswordWindowController.xib b/MasterPassword/ObjC/Mac/MPPasswordWindowController.xib index 77ec6fc4..7c2ac14f 100644 --- a/MasterPassword/ObjC/Mac/MPPasswordWindowController.xib +++ b/MasterPassword/ObjC/Mac/MPPasswordWindowController.xib @@ -16,7 +16,6 @@ - @@ -625,7 +624,7 @@ Use the arrows ⇅ to navigate the list or esc ⎋ to exit. - + @@ -734,7 +733,7 @@ Use the arrows ⇅ to navigate the list or esc ⎋ to exit. - + @@ -747,7 +746,7 @@ Use the arrows ⇅ to navigate the list or esc ⎋ to exit. - + @@ -880,7 +879,7 @@ Use the arrows ⇅ to navigate the list or esc ⎋ to exit. - + @@ -917,7 +916,7 @@ Use the arrows ⇅ to navigate the list or esc ⎋ to exit. - + @@ -954,7 +953,7 @@ Use the arrows ⇅ to navigate the list or esc ⎋ to exit. - + @@ -1233,6 +1232,7 @@ Use the arrows ⇅ to navigate the list or esc ⎋ to exit. + @@ -1242,19 +1242,29 @@ Use the arrows ⇅ to navigate the list or esc ⎋ to exit. - + - - + + + + + + - - + + + NSAllRomanInputSourcesLocaleIdentifier + + - - - + + + + + + - + @@ -1282,13 +1292,13 @@ Use the arrows ⇅ to navigate the list or esc ⎋ to exit. - - - - + + + + @@ -1298,6 +1308,7 @@ Use the arrows ⇅ to navigate the list or esc ⎋ to exit. + diff --git a/MasterPassword/ObjC/Mac/MPSiteModel.m b/MasterPassword/ObjC/Mac/MPSiteModel.m index 208fdec9..815b01f8 100644 --- a/MasterPassword/ObjC/Mac/MPSiteModel.m +++ b/MasterPassword/ObjC/Mac/MPSiteModel.m @@ -226,9 +226,8 @@ [entity resolveLoginUsingKey:[MPAppDelegate_Shared get].key result:^(NSString *result) { [self updateLoginNameWithResult:result]; }]; - [entity resolveSiteAnswerUsingKey:[MPAppDelegate_Shared get].key result:^(NSString *result) { - [self updateAnswerWithResult:result]; - }]; + [self updateAnswerWithResult:[self.algorithm generateAnswerForSiteNamed:self.name onQuestion:self.question + usingKey:[MPAppDelegate_Shared get].key]]; } - (void)updatePasswordWithResult:(NSString *)result {