- Remove AeroGear-Crypto

- Add NSData-AES
This commit is contained in:
giuseppenuc committed 2016-12-29 16:18:35 +01:00
1 parent 0b0803f3f9
commit 87b4f742e3
580 files changed
+3753 -24516

No files matched your search

+3 -9
View File
@@ -13,7 +13,7 @@
#import "NSString+Helper.h"
#import "PNObject+Protected.h"
#import <FBSDKCoreKit/FBSDKCoreKit.h>
#import <AeroGear-Crypto/AeroGearCrypto.h>
#import <NSDataAES/NSData+AES.h>
#import <DDDKeychainWrapper/DDDKeychainWrapper.h>
#import "HTTPStatusCodes.h"
@@ -37,7 +37,6 @@ NSString * const PNObjectLocalNotificationPNInstallationUserDelete = @"PNObjectL
NSInteger const minPassLenght = 4;
NSString * const PNObjectEncryptionKey = @"PNObjectConfigEncryptionKey";
NSString * const PNObjectEncryptionNonce = @"PNObjectConfigEncryptionNonce";
NSString * const PNObjectServiceClientCredentialIdentifier = @"PNObjectServiceClientCredentialIdentifier";
NSString * const PNObjectServiceUserCredentialIdentifier = @"PNObjectServiceUserCredentialIdentifier";
@@ -178,15 +177,10 @@ static bool isFirstAccess = YES;
if(![DDDKeychainWrapper dataForKey:PNObjectEncryptionKey]){
AGPBKDF2 *pbkdf2 = [[AGPBKDF2 alloc] init];
NSData *key = [pbkdf2 deriveKey:[NSString getRandString:256]];
NSData *nonce = [AGRandomGenerator randomBytes:128];
NSData *key = [[NSString getRandString:256] dataUsingEncoding:NSUTF8StringEncoding];
[DDDKeychainWrapper setData:key forKey:PNObjectEncryptionKey];
[DDDKeychainWrapper setData:nonce forKey:PNObjectEncryptionNonce];
}
+6 -12
View File
@@ -11,13 +11,12 @@
#import "PEARFileManager.h"
#import "PNObjectConstants.h"
#import <DDDKeychainWrapper/DDDKeychainWrapper.h>
#import <AeroGear-Crypto/AeroGearCrypto.h>
#import <NSDataAES/NSData+AES.h>
#import "HTTPStatusCodes.h"
@interface PNObjectModel()
@property (nonatomic, strong) PEARFileManager *fileManager;
@property (nonatomic, strong) AGSecretBox *secretBox;
@end
@implementation PNObjectModel
@@ -122,7 +121,6 @@ static bool isFirstAccess = YES;
[_fileManager setRootDirectory:k_ROOT_DIR_DOCUMENTS];
NSLogDebug(@"%@",[_fileManager getRootDirectoryPath]);
_secretBox = [[AGSecretBox alloc] initWithKey:[DDDKeychainWrapper dataForKey: PNObjectEncryptionKey]];
}
return self;
}
@@ -150,7 +148,7 @@ static bool isFirstAccess = YES;
NSError *error = nil;
NSData *data = [_secretBox decrypt:[_fileManager fetchFileDataWithPath:className] nonce:[DDDKeychainWrapper dataForKey: PNObjectEncryptionNonce] error:&error];
NSData *data = [[_fileManager fetchFileDataWithPath:className] aes_decrypt:[DDDKeychainWrapper dataForKey: PNObjectEncryptionKey]];
return [NSKeyedUnarchiver unarchiveObjectWithData:data];
}
@@ -174,7 +172,7 @@ static bool isFirstAccess = YES;
NSDictionary *objectDict = [(PNObject*) object reverseMapping];
NSData *objectData = [_secretBox encrypt:[NSKeyedArchiver archivedDataWithRootObject:objectDict] nonce:[DDDKeychainWrapper dataForKey: PNObjectEncryptionNonce] error:&error];
NSData *objectData = [[NSKeyedArchiver archivedDataWithRootObject:objectDict] aes_encrypt:[DDDKeychainWrapper dataForKey: PNObjectEncryptionKey]];
if ([self issetPNObjectModelForObject:object]) {
if ([_fileManager updateFileWithData:objectData filePath:[self objectName:object] permisson:@(0755)]) {
@@ -196,11 +194,7 @@ static bool isFirstAccess = YES;
else {
if ([self issetPNObjectModelForObject:object]) {
//NSData * data = [_fileManager fetchFileDataWithPath:[self objectName:object]];
NSData *data = [_secretBox decrypt:[_fileManager fetchFileDataWithPath:[self objectName:object]] nonce:[DDDKeychainWrapper dataForKey: PNObjectEncryptionNonce] error:&error];
NSData *data = [[_fileManager fetchFileDataWithPath:[self objectName:object]] aes_decrypt:[DDDKeychainWrapper dataForKey: PNObjectEncryptionKey]];
NSMutableArray *objects = [[NSMutableArray alloc] initWithArray:[NSKeyedUnarchiver unarchiveObjectWithData:data]];
@@ -208,7 +202,7 @@ static bool isFirstAccess = YES;
[objects addObject:objectDict];
NSData *objectData = [_secretBox encrypt:[NSKeyedArchiver archivedDataWithRootObject:objects] nonce:[DDDKeychainWrapper dataForKey: PNObjectEncryptionNonce] error:&error];
NSData *objectData = [[NSKeyedArchiver archivedDataWithRootObject:objects] aes_encrypt:[DDDKeychainWrapper dataForKey: PNObjectEncryptionKey]];
if ([_fileManager updateFileWithData:objectData filePath:[self objectName:object] permisson:@(0755)]) {
@@ -226,7 +220,7 @@ static bool isFirstAccess = YES;
[objects addObject:objectDict];
NSData *objectData = [_secretBox encrypt:[NSKeyedArchiver archivedDataWithRootObject:objects] nonce:[DDDKeychainWrapper dataForKey: PNObjectEncryptionNonce] error:&error];
NSData *objectData = [[NSKeyedArchiver archivedDataWithRootObject:objects] aes_encrypt:[DDDKeychainWrapper dataForKey: PNObjectEncryptionKey]];
if ([_fileManager createFileWithData:objectData filePath:[self objectName:object] permisson:@(0755)]) {
return object;