mirror of
https://github.com/MacPass/MacPass.git
synced 2025-12-13 21:42:32 +00:00
key file to database file mapping now hash the database url to obscure the mapping
This commit is contained in:
@@ -119,6 +119,7 @@
|
||||
4C569D9E17652B0600595B62 /* MPConstants.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C569D9D17652B0600595B62 /* MPConstants.m */; };
|
||||
4C569DA117652BFE00595B62 /* MPEntryTableDataSource.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C569DA017652BFE00595B62 /* MPEntryTableDataSource.m */; };
|
||||
4C57AE1417BA422B00CA4F34 /* MPSegmentedContextCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C57AE1317BA422B00CA4F34 /* MPSegmentedContextCell.m */; };
|
||||
4C5807781C64F67000E7171F /* NSString+MPHash.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C5807771C64F67000E7171F /* NSString+MPHash.m */; };
|
||||
4C586F9E16D07ABD00E7DB57 /* 00_PasswordTemplate.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 4C586F9D16D07ABD00E7DB57 /* 00_PasswordTemplate.pdf */; };
|
||||
4C586FA016D07D7200E7DB57 /* 01_PackageNetworkTemplate.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 4C586F9F16D07D7200E7DB57 /* 01_PackageNetworkTemplate.pdf */; };
|
||||
4C586FA216D07F6A00E7DB57 /* 02_MessageBoxWarningTemplate.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 4C586FA116D07F6A00E7DB57 /* 02_MessageBoxWarningTemplate.pdf */; };
|
||||
@@ -440,6 +441,8 @@
|
||||
4C569DA017652BFE00595B62 /* MPEntryTableDataSource.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPEntryTableDataSource.m; sourceTree = "<group>"; };
|
||||
4C57AE1217BA422B00CA4F34 /* MPSegmentedContextCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPSegmentedContextCell.h; sourceTree = "<group>"; };
|
||||
4C57AE1317BA422B00CA4F34 /* MPSegmentedContextCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPSegmentedContextCell.m; sourceTree = "<group>"; };
|
||||
4C5807761C64F67000E7171F /* NSString+MPHash.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSString+MPHash.h"; sourceTree = "<group>"; };
|
||||
4C5807771C64F67000E7171F /* NSString+MPHash.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSString+MPHash.m"; sourceTree = "<group>"; };
|
||||
4C586F9D16D07ABD00E7DB57 /* 00_PasswordTemplate.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = 00_PasswordTemplate.pdf; sourceTree = "<group>"; };
|
||||
4C586F9F16D07D7200E7DB57 /* 01_PackageNetworkTemplate.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = 01_PackageNetworkTemplate.pdf; sourceTree = "<group>"; };
|
||||
4C586FA116D07F6A00E7DB57 /* 02_MessageBoxWarningTemplate.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = 02_MessageBoxWarningTemplate.pdf; sourceTree = "<group>"; };
|
||||
@@ -856,6 +859,8 @@
|
||||
4C77C84018E240E000D1C42B /* DDHotKey+MacPassAdditions.m */,
|
||||
4C32B0E51A1D4436007E12F1 /* KPKFormat+MPUTIDetection.h */,
|
||||
4C32B0E61A1D4436007E12F1 /* KPKFormat+MPUTIDetection.m */,
|
||||
4C5807761C64F67000E7171F /* NSString+MPHash.h */,
|
||||
4C5807771C64F67000E7171F /* NSString+MPHash.m */,
|
||||
);
|
||||
name = Categories;
|
||||
sourceTree = "<group>";
|
||||
@@ -1759,6 +1764,7 @@
|
||||
4C57AE1417BA422B00CA4F34 /* MPSegmentedContextCell.m in Sources */,
|
||||
4CE2961518429AA5005F01CE /* MPAutotypeKeyPress.m in Sources */,
|
||||
4C32B0E71A1D4436007E12F1 /* KPKFormat+MPUTIDetection.m in Sources */,
|
||||
4C5807781C64F67000E7171F /* NSString+MPHash.m in Sources */,
|
||||
4CE501341BBC47F500FB819D /* MPTagsTokenFieldDelegate.m in Sources */,
|
||||
4CC6DB7A17D23719002C6091 /* KPKNode+IconImage.m in Sources */,
|
||||
4C15B74618BCA3B1003F8008 /* MPDocument+Search.m in Sources */,
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
|
||||
#import "NSError+Messages.h"
|
||||
#import "NSString+MPPasswordCreation.h"
|
||||
#import "NSString+MPHash.h"
|
||||
|
||||
NSString *const MPDocumentDidAddGroupNotification = @"com.hicknhack.macpass.MPDocumentDidAddGroupNotification";
|
||||
NSString *const MPDocumentDidAddEntryNotification = @"com.hicknhack.macpass.MPDocumentDidAddEntryNotification";
|
||||
@@ -331,7 +332,7 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGroupKey
|
||||
return nil;
|
||||
}
|
||||
NSDictionary *keysForFiles = [[NSUserDefaults standardUserDefaults] dictionaryForKey:kMPSettingsKeyRememeberdKeysForDatabases];
|
||||
NSString *keyPath = keysForFiles[[[self fileURL] path]];
|
||||
NSString *keyPath = keysForFiles[self.fileURL.path.sha1HexDigest];
|
||||
if(!keyPath) {
|
||||
return nil;
|
||||
}
|
||||
@@ -689,7 +690,7 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGroupKey
|
||||
if(nil == keysForFiles) {
|
||||
keysForFiles = [[NSMutableDictionary alloc] initWithCapacity:1];
|
||||
}
|
||||
keysForFiles[[[self fileURL] path]] = [keyURL path];
|
||||
keysForFiles[self.fileURL.path.sha1HexDigest] = keyURL.path;
|
||||
[[NSUserDefaults standardUserDefaults] setObject:keysForFiles forKey:kMPSettingsKeyRememeberdKeysForDatabases];
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
|
||||
#import "MPSettingsHelper.h"
|
||||
#import "NSString+MPPasswordCreation.h"
|
||||
#import "NSString+MPHash.h"
|
||||
#import "MPEntryViewController.h" // Sort descriptors
|
||||
#import "DDHotKey+MacPassAdditions.h" // Default hotkey;
|
||||
|
||||
@@ -80,6 +81,7 @@ NSString *const kMPDeprecatedSettingsKeyShowMenuItem = @"Sh
|
||||
[self _fixEntryTableSortDescriptors];
|
||||
[self _migrateURLDoubleClickPreferences];
|
||||
[self _migrateEntrySearchFlags];
|
||||
[self _migrateRememberedKeyFiles];
|
||||
[self _removeDeprecatedValues];
|
||||
}
|
||||
|
||||
@@ -182,6 +184,7 @@ NSString *const kMPDeprecatedSettingsKeyShowMenuItem = @"Sh
|
||||
}
|
||||
|
||||
+ (void)_migrateEntrySearchFlags {
|
||||
/* Entry filters are now stored as archivd search context not just flags */
|
||||
NSInteger flags = [[NSUserDefaults standardUserDefaults] integerForKey:kMPDeprecatedSettingsKeyEntrySearchFilterMode];
|
||||
if(flags != 0) {
|
||||
MPEntrySearchContext *context = [[MPEntrySearchContext alloc] initWithString:nil flags:flags];
|
||||
@@ -190,4 +193,23 @@ NSString *const kMPDeprecatedSettingsKeyShowMenuItem = @"Sh
|
||||
}
|
||||
}
|
||||
|
||||
+ (void)_migrateRememberedKeyFiles {
|
||||
/*
|
||||
Database file paths was stored as plain text in keyfile mapping.
|
||||
We only need to store the key file ulr in plain text, thus hashing the path is sufficent
|
||||
*/
|
||||
NSDictionary<NSString *, NSString *> *plainTextDict = [[NSUserDefaults standardUserDefaults] dictionaryForKey:kMPSettingsKeyRememeberdKeysForDatabases];
|
||||
if(!plainTextDict) {
|
||||
return;
|
||||
}
|
||||
NSMutableDictionary *hashedDict = [[NSMutableDictionary alloc] initWithCapacity:plainTextDict.count];
|
||||
for(NSString *key in plainTextDict) {
|
||||
NSString *digest = key.sha1HexDigest;
|
||||
if(digest) {
|
||||
hashedDict[key.sha1HexDigest] = plainTextDict[key];
|
||||
}
|
||||
}
|
||||
[[NSUserDefaults standardUserDefaults] setObject:hashedDict forKey:kMPSettingsKeyRememeberdKeysForDatabases];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
17
MacPass/NSString+MPHash.h
Normal file
17
MacPass/NSString+MPHash.h
Normal file
@@ -0,0 +1,17 @@
|
||||
//
|
||||
// NSString+MPHash.h
|
||||
// MacPass
|
||||
//
|
||||
// Created by Michael Starke on 05/02/16.
|
||||
// Copyright © 2016 HicknHack Software GmbH. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@interface NSString (MPHash)
|
||||
|
||||
@property (copy, readonly, nonatomic) NSString *sha1HexDigest;
|
||||
|
||||
+ (NSString *)sha1HexDigest:(NSString*)input;
|
||||
|
||||
@end
|
||||
34
MacPass/NSString+MPHash.m
Normal file
34
MacPass/NSString+MPHash.m
Normal file
@@ -0,0 +1,34 @@
|
||||
//
|
||||
// NSString+MPHash.m
|
||||
// MacPass
|
||||
//
|
||||
// Created by Michael Starke on 05/02/16.
|
||||
// Copyright © 2016 HicknHack Software GmbH. All rights reserved.
|
||||
//
|
||||
|
||||
#import "NSString+MPHash.h"
|
||||
|
||||
#import <CommonCrypto/CommonCrypto.h>
|
||||
|
||||
@implementation NSString (MPHash)
|
||||
|
||||
+ (NSString*)sha1HexDigest:(NSString*)input {
|
||||
if(input.length == 0) {
|
||||
return nil;
|
||||
}
|
||||
const char* str = input.UTF8String;
|
||||
unsigned char result[CC_SHA1_DIGEST_LENGTH];
|
||||
CC_SHA1(str, (CC_LONG)strlen(str), result);
|
||||
|
||||
NSMutableString *hexDigest = [NSMutableString stringWithCapacity:CC_SHA1_DIGEST_LENGTH*2];
|
||||
for(int i = 0; i<CC_SHA1_DIGEST_LENGTH; i++) {
|
||||
[hexDigest appendFormat:@"%02x",result[i]];
|
||||
}
|
||||
return hexDigest;
|
||||
}
|
||||
|
||||
- (NSString *)sha1HexDigest {
|
||||
return [NSString sha1HexDigest:self];
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in New Issue
Block a user