2017-04-05 20:56:22 +00:00
|
|
|
//==============================================================================
|
|
|
|
// This file is part of Master Password.
|
|
|
|
// Copyright (c) 2011-2017, Maarten Billemont.
|
2012-07-17 20:57:11 +00:00
|
|
|
//
|
2017-04-05 20:56:22 +00:00
|
|
|
// Master Password is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
2012-07-17 20:57:11 +00:00
|
|
|
//
|
2017-04-05 20:56:22 +00:00
|
|
|
// Master Password is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
2012-07-17 20:57:11 +00:00
|
|
|
//
|
2017-04-05 20:56:22 +00:00
|
|
|
// You can find a copy of the GNU General Public License in the
|
|
|
|
// LICENSE file. Alternatively, see <http://www.gnu.org/licenses/>.
|
|
|
|
//==============================================================================
|
2012-07-17 20:57:11 +00:00
|
|
|
|
|
|
|
#import "MPKey.h"
|
2017-05-01 22:32:52 +00:00
|
|
|
#import "MPStoredSiteEntity+CoreDataClass.h"
|
|
|
|
#import "MPGeneratedSiteEntity+CoreDataClass.h"
|
|
|
|
#import "MPSiteQuestionEntity+CoreDataClass.h"
|
2015-01-15 22:43:41 +00:00
|
|
|
#import "mpw-algorithm.h"
|
2012-07-17 20:57:11 +00:00
|
|
|
|
2015-01-15 22:43:41 +00:00
|
|
|
#define MPAlgorithmDefaultVersion MPAlgorithmVersionCurrent
|
2012-07-17 20:57:11 +00:00
|
|
|
#define MPAlgorithmDefault MPAlgorithmForVersion(MPAlgorithmDefaultVersion)
|
|
|
|
|
2015-09-23 04:31:33 +00:00
|
|
|
id<MPAlgorithm> MPAlgorithmForVersion(MPAlgorithmVersion version);
|
2014-07-26 05:26:33 +00:00
|
|
|
id<MPAlgorithm> MPAlgorithmDefaultForBundleVersion(NSString *bundleVersion);
|
|
|
|
|
|
|
|
PearlEnum( MPAttacker,
|
2014-07-28 22:53:50 +00:00
|
|
|
MPAttacker1, MPAttacker5K, MPAttacker20M, MPAttacker5B );
|
2014-07-26 05:26:33 +00: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 20:57:11 +00:00
|
|
|
@protocol MPAlgorithm<NSObject>
|
|
|
|
|
|
|
|
@required
|
2015-01-15 22:43:41 +00:00
|
|
|
- (MPAlgorithmVersion)version;
|
2014-09-24 11:58:23 +00:00
|
|
|
- (BOOL)tryMigrateUser:(MPUserEntity *)user inContext:(NSManagedObjectContext *)moc;
|
|
|
|
- (BOOL)tryMigrateSite:(MPSiteEntity *)site explicit:(BOOL)explicit;
|
2012-07-17 20:57:11 +00:00
|
|
|
|
2017-07-16 01:13:49 +00:00
|
|
|
- (NSData *)keyIDForKey:(MPMasterKey)masterKey;
|
2015-02-28 15:01:41 +00:00
|
|
|
- (NSData *)keyDataForFullName:(NSString *)fullName withMasterPassword:(NSString *)masterPassword;
|
2012-07-17 20:57:11 +00:00
|
|
|
|
2017-08-13 01:57:47 +00:00
|
|
|
- (NSString *)nameOfType:(MPResultType)type;
|
|
|
|
- (NSString *)shortNameOfType:(MPResultType)type;
|
|
|
|
- (NSString *)classNameOfType:(MPResultType)type;
|
|
|
|
- (Class)classOfType:(MPResultType)type;
|
2014-04-26 18:03:44 +00:00
|
|
|
- (NSArray *)allTypes;
|
2017-08-13 01:57:47 +00:00
|
|
|
- (NSArray *)allTypesStartingWith:(MPResultType)startingType;
|
|
|
|
- (MPResultType)defaultType;
|
|
|
|
- (MPResultType)nextType:(MPResultType)type;
|
|
|
|
- (MPResultType)previousType:(MPResultType)type;
|
|
|
|
|
|
|
|
- (NSString *)mpwLoginForSiteNamed:(NSString *)name usingKey:(MPKey *)key;
|
|
|
|
- (NSString *)mpwTemplateForSiteNamed:(NSString *)name ofType:(MPResultType)type
|
2017-08-13 02:26:48 +00:00
|
|
|
withCounter:(MPCounterValue)counter usingKey:(MPKey *)key;
|
2017-08-13 01:57:47 +00:00
|
|
|
- (NSString *)mpwAnswerForSiteNamed:(NSString *)name onQuestion:(NSString *)question usingKey:(MPKey *)key;
|
|
|
|
- (NSString *)mpwResultForSiteNamed:(NSString *)name ofType:(MPResultType)type parameter:(NSString *)parameter
|
2017-08-13 02:26:48 +00:00
|
|
|
withCounter:(MPCounterValue)counter variant:(MPKeyPurpose)purpose context:(NSString *)context usingKey:(MPKey *)key;
|
2017-08-13 01:57:47 +00:00
|
|
|
|
|
|
|
- (BOOL)savePassword:(NSString *)clearPassword toSite:(MPSiteEntity *)site usingKey:(MPKey *)key;
|
|
|
|
|
|
|
|
- (NSString *)resolveLoginForSite:(MPSiteEntity *)site usingKey:(MPKey *)key;
|
|
|
|
- (NSString *)resolvePasswordForSite:(MPSiteEntity *)site usingKey:(MPKey *)key;
|
|
|
|
- (NSString *)resolveAnswerForSite:(MPSiteEntity *)site usingKey:(MPKey *)key;
|
|
|
|
- (NSString *)resolveAnswerForQuestion:(MPSiteQuestionEntity *)question usingKey:(MPKey *)key;
|
|
|
|
|
|
|
|
- (void)resolveLoginForSite:(MPSiteEntity *)site usingKey:(MPKey *)key
|
2014-09-21 14:39:09 +00:00
|
|
|
result:(void ( ^ )(NSString *result))resultBlock;
|
2017-08-13 01:57:47 +00:00
|
|
|
- (void)resolvePasswordForSite:(MPSiteEntity *)site usingKey:(MPKey *)key
|
2014-09-15 05:00:23 +00:00
|
|
|
result:(void ( ^ )(NSString *result))resultBlock;
|
2017-08-13 01:57:47 +00:00
|
|
|
- (void)resolveAnswerForSite:(MPSiteEntity *)site usingKey:(MPKey *)key
|
2017-04-01 04:30:25 +00:00
|
|
|
result:(void ( ^ )(NSString *result))resultBlock;
|
2017-08-13 01:57:47 +00:00
|
|
|
- (void)resolveAnswerForQuestion:(MPSiteQuestionEntity *)question usingKey:(MPKey *)key
|
2014-09-27 20:30:17 +00:00
|
|
|
result:(void ( ^ )(NSString *result))resultBlock;
|
2014-09-15 05:00:23 +00:00
|
|
|
|
2017-08-13 01:57:47 +00:00
|
|
|
- (void)importPassword:(NSString *)protectedPassword protectedByKey:(MPKey *)importKey
|
|
|
|
intoSite:(MPSiteEntity *)site usingKey:(MPKey *)key;
|
|
|
|
- (NSString *)exportPasswordForSite:(MPSiteEntity *)site usingKey:(MPKey *)key;
|
2012-07-17 20:57:11 +00:00
|
|
|
|
2017-08-13 01:57:47 +00:00
|
|
|
- (BOOL)timeToCrack:(out TimeToCrack *)timeToCrack passwordOfType:(MPResultType)type byAttacker:(MPAttacker)attacker;
|
2014-07-26 05:26:33 +00:00
|
|
|
- (BOOL)timeToCrack:(out TimeToCrack *)timeToCrack passwordString:(NSString *)password byAttacker:(MPAttacker)attacker;
|
2012-07-17 20:57:11 +00:00
|
|
|
|
2014-07-26 05:26:33 +00:00
|
|
|
@end
|