no message

This commit is contained in:
giuseppenuc committed 2016-12-29 15:47:15 +01:00
1 parent 5bdac671f9
commit 0b0803f3f9
1292 files changed
+21890 -30219

No files matched your search

+7 -3
View File
@@ -13,7 +13,7 @@
#import "NSString+Helper.h"
#import "PNObject+Protected.h"
#import <FBSDKCoreKit/FBSDKCoreKit.h>
#import <NAChloride/NAChloride.h>
#import <AeroGear-Crypto/AeroGearCrypto.h>
#import <DDDKeychainWrapper/DDDKeychainWrapper.h>
#import "HTTPStatusCodes.h"
@@ -177,8 +177,12 @@ static bool isFirstAccess = YES;
if(![DDDKeychainWrapper dataForKey:PNObjectEncryptionKey]){
NSData *key = [NARandom randomData:NASecretBoxKeySize];
NSData *nonce = [NARandom randomData:NASecretBoxNonceSize];
AGPBKDF2 *pbkdf2 = [[AGPBKDF2 alloc] init];
NSData *key = [pbkdf2 deriveKey:[NSString getRandString:256]];
NSData *nonce = [AGRandomGenerator randomBytes:128];
[DDDKeychainWrapper setData:key forKey:PNObjectEncryptionKey];
+8 -12
View File
@@ -11,13 +11,13 @@
#import "PEARFileManager.h"
#import "PNObjectConstants.h"
#import <DDDKeychainWrapper/DDDKeychainWrapper.h>
#import <NAChloride/NAChloride.h>
#import <AeroGear-Crypto/AeroGearCrypto.h>
#import "HTTPStatusCodes.h"
@interface PNObjectModel()
@property (nonatomic, strong) PEARFileManager *fileManager;
@property (nonatomic, strong) NASecretBox *secretBox;
@property (nonatomic, strong) AGSecretBox *secretBox;
@end
@implementation PNObjectModel
@@ -122,7 +122,7 @@ static bool isFirstAccess = YES;
[_fileManager setRootDirectory:k_ROOT_DIR_DOCUMENTS];
NSLogDebug(@"%@",[_fileManager getRootDirectoryPath]);
_secretBox = [[NASecretBox alloc] init];
_secretBox = [[AGSecretBox alloc] initWithKey:[DDDKeychainWrapper dataForKey: PNObjectEncryptionKey]];
}
return self;
}
@@ -150,7 +150,7 @@ static bool isFirstAccess = YES;
NSError *error = nil;
NSData *data = [_secretBox decrypt:[_fileManager fetchFileDataWithPath:className] nonce:[DDDKeychainWrapper dataForKey:PNObjectEncryptionNonce] key:[DDDKeychainWrapper dataForKey: PNObjectEncryptionKey] error:&error]; // password:[[PNObjectConfig sharedInstance] encrypKey] error:&error];
NSData *data = [_secretBox decrypt:[_fileManager fetchFileDataWithPath:className] nonce:[DDDKeychainWrapper dataForKey: PNObjectEncryptionNonce] error:&error];
return [NSKeyedUnarchiver unarchiveObjectWithData:data];
}
@@ -168,14 +168,13 @@ static bool isFirstAccess = YES;
if(isPNObjectSubclass) {
if ([[object class] conformsToProtocol:@protocol(PNObjectSubclassing)]) {
if ([(PNObject*) object singleInstance]) {
NSDictionary *objectDict = [(PNObject*) object reverseMapping];
NSData *objectData = [_secretBox encrypt:[NSKeyedArchiver archivedDataWithRootObject:objectDict] nonce:[DDDKeychainWrapper dataForKey: PNObjectEncryptionNonce] key:[DDDKeychainWrapper dataForKey: PNObjectEncryptionKey] error:&error];//[RNCryptor encryptData:[NSKeyedArchiver archivedDataWithRootObject:objectDict] password:[[PNObjectConfig sharedInstance] encrypKey]];
NSData *objectData = [_secretBox encrypt:[NSKeyedArchiver archivedDataWithRootObject:objectDict] nonce:[DDDKeychainWrapper dataForKey: PNObjectEncryptionNonce] error:&error];
if ([self issetPNObjectModelForObject:object]) {
if ([_fileManager updateFileWithData:objectData filePath:[self objectName:object] permisson:@(0755)]) {
@@ -201,8 +200,7 @@ static bool isFirstAccess = YES;
NSData *data = [_secretBox decrypt:[_fileManager fetchFileDataWithPath:[self objectName:object]] nonce:[DDDKeychainWrapper dataForKey: PNObjectEncryptionNonce] key:[DDDKeychainWrapper dataForKey: PNObjectEncryptionKey] error:&error];
//[RNCryptor decryptData:[_fileManager fetchFileDataWithPath:[self objectName:object]] password:[[PNObjectConfig sharedInstance] encrypKey] error:&error];
NSData *data = [_secretBox decrypt:[_fileManager fetchFileDataWithPath:[self objectName:object]] nonce:[DDDKeychainWrapper dataForKey: PNObjectEncryptionNonce] error:&error];
NSMutableArray *objects = [[NSMutableArray alloc] initWithArray:[NSKeyedUnarchiver unarchiveObjectWithData:data]];
@@ -210,8 +208,7 @@ static bool isFirstAccess = YES;
[objects addObject:objectDict];
NSData *objectData = [_secretBox encrypt:[NSKeyedArchiver archivedDataWithRootObject:objects] nonce:[DDDKeychainWrapper dataForKey: PNObjectEncryptionNonce] key:[DDDKeychainWrapper dataForKey:PNObjectEncryptionKey] error:&error];
//[RNCryptor encryptData:[NSKeyedArchiver archivedDataWithRootObject:objects] password:[[PNObjectConfig sharedInstance] encrypKey]];
NSData *objectData = [_secretBox encrypt:[NSKeyedArchiver archivedDataWithRootObject:objects] nonce:[DDDKeychainWrapper dataForKey: PNObjectEncryptionNonce] error:&error];
if ([_fileManager updateFileWithData:objectData filePath:[self objectName:object] permisson:@(0755)]) {
@@ -229,8 +226,7 @@ static bool isFirstAccess = YES;
[objects addObject:objectDict];
NSData *objectData = [_secretBox encrypt:[NSKeyedArchiver archivedDataWithRootObject:objects] nonce:[DDDKeychainWrapper dataForKey:PNObjectEncryptionNonce] key:[DDDKeychainWrapper dataForKey:PNObjectEncryptionKey] error:&error];
//[RNCryptor encryptData:[NSKeyedArchiver archivedDataWithRootObject:objects] password:[[PNObjectConfig sharedInstance] encrypKey]];
NSData *objectData = [_secretBox encrypt:[NSKeyedArchiver archivedDataWithRootObject:objects] nonce:[DDDKeychainWrapper dataForKey: PNObjectEncryptionNonce] error:&error];
if ([_fileManager createFileWithData:objectData filePath:[self objectName:object] permisson:@(0755)]) {
return object;