2012-07-17 22:57:11 +02:00
|
|
|
/**
|
2014-09-15 01:00:23 -04:00
|
|
|
* Copyright Maarten Billemont (http://www.lhunath.com, lhunath@lyndir.com)
|
|
|
|
*
|
|
|
|
* See the enclosed file LICENSE for license information (LGPLv3). If you did
|
|
|
|
* not receive this file, see http://www.gnu.org/licenses/lgpl-3.0.txt
|
|
|
|
*
|
|
|
|
* @author Maarten Billemont <lhunath@lyndir.com>
|
|
|
|
* @license http://www.gnu.org/licenses/lgpl-3.0.txt
|
|
|
|
*/
|
2012-07-17 22:57:11 +02:00
|
|
|
|
|
|
|
//
|
|
|
|
// MPAlgorithm
|
|
|
|
//
|
|
|
|
// Created by Maarten Billemont on 16/07/12.
|
|
|
|
// Copyright 2012 lhunath (Maarten Billemont). All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
#import "MPKey.h"
|
2014-09-21 11:47:53 -04:00
|
|
|
#import "MPStoredSiteEntity.h"
|
|
|
|
#import "MPGeneratedSiteEntity.h"
|
2014-09-27 16:30:17 -04:00
|
|
|
#import "MPSiteQuestionEntity.h"
|
2015-01-15 17:43:41 -05:00
|
|
|
#import "mpw-algorithm.h"
|
2012-07-17 22:57:11 +02:00
|
|
|
|
2015-01-15 17:43:41 -05:00
|
|
|
#define MPAlgorithmDefaultVersion MPAlgorithmVersionCurrent
|
2012-07-17 22:57:11 +02:00
|
|
|
#define MPAlgorithmDefault MPAlgorithmForVersion(MPAlgorithmDefaultVersion)
|
|
|
|
|
2015-09-23 00:31:33 -04:00
|
|
|
id<MPAlgorithm> MPAlgorithmForVersion(MPAlgorithmVersion version);
|
2014-07-26 01:26:33 -04:00
|
|
|
id<MPAlgorithm> MPAlgorithmDefaultForBundleVersion(NSString *bundleVersion);
|
|
|
|
|
|
|
|
PearlEnum( MPAttacker,
|
2014-07-28 18:53:50 -04:00
|
|
|
MPAttacker1, MPAttacker5K, MPAttacker20M, MPAttacker5B );
|
2014-07-26 01:26:33 -04:00
|
|
|
|
|
|
|
typedef struct TimeToCrack {
|
|
|
|
unsigned long long hours;
|
|
|
|
unsigned long long days;
|
|
|
|
unsigned long long weeks;
|
|
|
|
unsigned long long months;
|
|
|
|
unsigned long long years;
|
|
|
|
unsigned long long universes;
|
|
|
|
} TimeToCrack;
|
|
|
|
|
|
|
|
NSString *NSStringFromTimeToCrack(TimeToCrack timeToCrack);
|
|
|
|
|
2012-07-17 22:57:11 +02:00
|
|
|
@protocol MPAlgorithm<NSObject>
|
|
|
|
|
|
|
|
@required
|
2015-01-15 17:43:41 -05:00
|
|
|
- (MPAlgorithmVersion)version;
|
2014-09-24 07:58:23 -04:00
|
|
|
- (BOOL)tryMigrateUser:(MPUserEntity *)user inContext:(NSManagedObjectContext *)moc;
|
|
|
|
- (BOOL)tryMigrateSite:(MPSiteEntity *)site explicit:(BOOL)explicit;
|
2012-07-17 22:57:11 +02:00
|
|
|
|
|
|
|
- (NSData *)keyIDForKeyData:(NSData *)keyData;
|
2015-02-28 10:01:41 -05:00
|
|
|
- (NSData *)keyDataForFullName:(NSString *)fullName withMasterPassword:(NSString *)masterPassword;
|
2012-07-17 22:57:11 +02:00
|
|
|
|
2014-09-21 10:39:09 -04:00
|
|
|
- (NSString *)nameOfType:(MPSiteType)type;
|
|
|
|
- (NSString *)shortNameOfType:(MPSiteType)type;
|
|
|
|
- (NSString *)classNameOfType:(MPSiteType)type;
|
|
|
|
- (Class)classOfType:(MPSiteType)type;
|
2014-04-26 14:03:44 -04:00
|
|
|
- (NSArray *)allTypes;
|
2014-09-21 10:39:09 -04:00
|
|
|
- (NSArray *)allTypesStartingWith:(MPSiteType)startingType;
|
|
|
|
- (MPSiteType)nextType:(MPSiteType)type;
|
|
|
|
- (MPSiteType)previousType:(MPSiteType)type;
|
2012-07-17 22:57:11 +02:00
|
|
|
|
2014-09-15 01:00:23 -04:00
|
|
|
- (NSString *)generateLoginForSiteNamed:(NSString *)name usingKey:(MPKey *)key;
|
2014-09-21 10:39:09 -04:00
|
|
|
- (NSString *)generatePasswordForSiteNamed:(NSString *)name ofType:(MPSiteType)type withCounter:(NSUInteger)counter
|
2014-09-15 01:00:23 -04:00
|
|
|
usingKey:(MPKey *)key;
|
2014-09-21 22:45:21 -04:00
|
|
|
- (NSString *)generateAnswerForSiteNamed:(NSString *)name onQuestion:(NSString *)question usingKey:(MPKey *)key;
|
2014-09-21 10:39:09 -04:00
|
|
|
- (NSString *)generateContentForSiteNamed:(NSString *)name ofType:(MPSiteType)type withCounter:(NSUInteger)counter
|
2014-09-21 22:45:21 -04:00
|
|
|
variant:(MPSiteVariant)variant context:(NSString *)context usingKey:(MPKey *)key;
|
2013-09-13 08:14:58 -04:00
|
|
|
|
2014-09-21 11:47:53 -04:00
|
|
|
- (NSString *)storedLoginForSite:(MPStoredSiteEntity *)site usingKey:(MPKey *)key;
|
|
|
|
- (NSString *)storedPasswordForSite:(MPStoredSiteEntity *)site usingKey:(MPKey *)key;
|
2013-09-13 08:14:58 -04:00
|
|
|
|
2014-09-21 10:39:09 -04:00
|
|
|
- (BOOL)savePassword:(NSString *)clearPassword toSite:(MPSiteEntity *)site usingKey:(MPKey *)siteKey;
|
2014-09-15 01:00:23 -04:00
|
|
|
|
2014-09-21 10:39:09 -04:00
|
|
|
- (NSString *)resolveLoginForSite:(MPSiteEntity *)site usingKey:(MPKey *)siteKey;
|
|
|
|
- (NSString *)resolvePasswordForSite:(MPSiteEntity *)site usingKey:(MPKey *)siteKey;
|
2014-09-21 22:45:21 -04:00
|
|
|
- (NSString *)resolveAnswerForSite:(MPSiteEntity *)site usingKey:(MPKey *)siteKey;
|
2014-09-27 16:30:17 -04:00
|
|
|
- (NSString *)resolveAnswerForQuestion:(MPSiteQuestionEntity *)question usingKey:(MPKey *)siteKey;
|
2014-09-15 01:00:23 -04:00
|
|
|
|
2014-09-21 10:39:09 -04:00
|
|
|
- (void)resolveLoginForSite:(MPSiteEntity *)site usingKey:(MPKey *)siteKey
|
|
|
|
result:(void ( ^ )(NSString *result))resultBlock;
|
|
|
|
- (void)resolvePasswordForSite:(MPSiteEntity *)site usingKey:(MPKey *)siteKey
|
2014-09-15 01:00:23 -04:00
|
|
|
result:(void ( ^ )(NSString *result))resultBlock;
|
2014-09-21 22:45:21 -04:00
|
|
|
- (void)resolveAnswerForSite:(MPSiteEntity *)site usingKey:(MPKey *)siteKey
|
|
|
|
result:(void ( ^ )(NSString *result))resultBlock;
|
2014-09-27 16:30:17 -04:00
|
|
|
- (void)resolveAnswerForQuestion:(MPSiteQuestionEntity *)question usingKey:(MPKey *)siteKey
|
|
|
|
result:(void ( ^ )(NSString *result))resultBlock;
|
2014-09-15 01:00:23 -04:00
|
|
|
|
|
|
|
- (void)importProtectedPassword:(NSString *)protectedPassword protectedByKey:(MPKey *)importKey
|
2014-09-21 10:39:09 -04:00
|
|
|
intoSite:(MPSiteEntity *)site usingKey:(MPKey *)siteKey;
|
|
|
|
- (void)importClearTextPassword:(NSString *)clearPassword intoSite:(MPSiteEntity *)site
|
|
|
|
usingKey:(MPKey *)siteKey;
|
|
|
|
- (NSString *)exportPasswordForSite:(MPSiteEntity *)site usingKey:(MPKey *)siteKey;
|
2012-07-17 22:57:11 +02:00
|
|
|
|
2014-09-21 10:39:09 -04:00
|
|
|
- (BOOL)timeToCrack:(out TimeToCrack *)timeToCrack passwordOfType:(MPSiteType)type byAttacker:(MPAttacker)attacker;
|
2014-07-26 01:26:33 -04:00
|
|
|
- (BOOL)timeToCrack:(out TimeToCrack *)timeToCrack passwordString:(NSString *)password byAttacker:(MPAttacker)attacker;
|
2012-07-17 22:57:11 +02:00
|
|
|
|
2014-07-26 01:26:33 -04:00
|
|
|
@end
|