diff --git a/RNCryptor OS X/RNCryptor OS X-Prefix.pch b/RNCryptor OS X/RNCryptor OS X-Prefix.pch index cf0d2a5e..ae1c34d1 100644 --- a/RNCryptor OS X/RNCryptor OS X-Prefix.pch +++ b/RNCryptor OS X/RNCryptor OS X-Prefix.pch @@ -2,6 +2,9 @@ // Prefix header for all source files of the 'RNCryptor OS X' target in the 'RNCryptor OS X' project // +// For testing +// #define RNCRYPTOR_ALLOW_V1_BAD_HMAC + #ifdef __OBJC__ #endif diff --git a/RNCryptor.xcodeproj/project.pbxproj b/RNCryptor.xcodeproj/project.pbxproj index 453b5021..890f3a7c 100644 --- a/RNCryptor.xcodeproj/project.pbxproj +++ b/RNCryptor.xcodeproj/project.pbxproj @@ -40,6 +40,7 @@ FB7565241512D9BE007B808D /* RNOpenSSLEncryptor.h in Headers */ = {isa = PBXBuildFile; fileRef = FB7565241512D9BE007B808C /* RNOpenSSLEncryptor.h */; }; FB7565241512D9BE007B808F /* RNOpenSSLDecryptor.h in Headers */ = {isa = PBXBuildFile; fileRef = FB7565241512D9BE007B808E /* RNOpenSSLDecryptor.h */; }; FB7565241512D9BE007B8091 /* RNOpenSSLDecryptor.m in Sources */ = {isa = PBXBuildFile; fileRef = FB7565241512D9BE007B8090 /* RNOpenSSLDecryptor.m */; }; + FBE1F73B16A899E400C90463 /* RNCryptorV1.enc in CopyFiles */ = {isa = PBXBuildFile; fileRef = FBE1F73A16A899D800C90463 /* RNCryptorV1.enc */; }; FBF7D58E167E5031004B6F0F /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FB7564F31512D3C4007B806B /* Foundation.framework */; }; FBF7D591167E5032004B6F0F /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = FBF7D590167E5032004B6F0F /* main.m */; }; FBF7D5A9167E515D004B6F0F /* RNCryptor.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AB13427A15E0FC2300456914 /* RNCryptor.framework */; }; @@ -58,12 +59,13 @@ /* Begin PBXCopyFilesBuildPhase section */ FBF7D58A167E5031004B6F0F /* CopyFiles */ = { isa = PBXCopyFilesBuildPhase; - buildActionMask = 2147483647; - dstPath = /usr/share/man/man1/; - dstSubfolderSpec = 0; + buildActionMask = 12; + dstPath = ""; + dstSubfolderSpec = 16; files = ( + FBE1F73B16A899E400C90463 /* RNCryptorV1.enc in CopyFiles */, ); - runOnlyForDeploymentPostprocessing = 1; + runOnlyForDeploymentPostprocessing = 0; }; /* End PBXCopyFilesBuildPhase section */ @@ -104,6 +106,7 @@ FB7565241512D9BE007B808E /* RNOpenSSLDecryptor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RNOpenSSLDecryptor.h; sourceTree = ""; }; FB7565241512D9BE007B8090 /* RNOpenSSLDecryptor.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RNOpenSSLDecryptor.m; sourceTree = ""; }; FB7565241512D9BE007B8092 /* README.md */ = {isa = PBXFileReference; lastKnownFileType = file.md; path = README.md; sourceTree = ""; }; + FBE1F73A16A899D800C90463 /* RNCryptorV1.enc */ = {isa = PBXFileReference; lastKnownFileType = file; path = RNCryptorV1.enc; sourceTree = SOURCE_ROOT; }; FBF7D58C167E5031004B6F0F /* RNCryptorVectors */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = RNCryptorVectors; sourceTree = BUILT_PRODUCTS_DIR; }; FBF7D590167E5032004B6F0F /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; FBF7D593167E5032004B6F0F /* RNCryptorVectors-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "RNCryptorVectors-Prefix.pch"; sourceTree = ""; }; @@ -270,6 +273,7 @@ isa = PBXGroup; children = ( FBF7D590167E5032004B6F0F /* main.m */, + FBE1F73A16A899D800C90463 /* RNCryptorV1.enc */, FBF7D592167E5032004B6F0F /* Supporting Files */, ); path = RNCryptorVectors; @@ -690,6 +694,7 @@ GCC_ENABLE_OBJC_EXCEPTIONS = YES; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "RNCryptorVectors/RNCryptorVectors-Prefix.pch"; + GCC_PREPROCESSOR_DEFINITIONS = "$(inherited)"; GCC_WARN_64_TO_32_BIT_CONVERSION = YES; MACOSX_DEPLOYMENT_TARGET = 10.8; ONLY_ACTIVE_ARCH = YES; @@ -710,6 +715,7 @@ GCC_ENABLE_OBJC_EXCEPTIONS = YES; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "RNCryptorVectors/RNCryptorVectors-Prefix.pch"; + GCC_PREPROCESSOR_DEFINITIONS = ""; GCC_WARN_64_TO_32_BIT_CONVERSION = YES; MACOSX_DEPLOYMENT_TARGET = 10.8; PRODUCT_NAME = "$(TARGET_NAME)"; diff --git a/RNCryptor/RNDecryptor.m b/RNCryptor/RNDecryptor.m index fffdab5c..ebd79dfa 100644 --- a/RNCryptor/RNDecryptor.m +++ b/RNCryptor/RNDecryptor.m @@ -36,7 +36,7 @@ @interface RNDecryptor () @property (nonatomic, readwrite, copy) NSData *encryptionKey; @property (nonatomic, readwrite, copy) NSData *HMACKey; @property (nonatomic, readwrite, copy) NSString *password; -@property (nonatomic, readwrite, assign) BOOL *hasV1HMAC; +@property (nonatomic, readwrite, assign) BOOL hasV1HMAC; @end diff --git a/RNCryptorV1.enc b/RNCryptorV1.enc new file mode 100644 index 00000000..f8fa3344 --- /dev/null +++ b/RNCryptorV1.enc @@ -0,0 +1,2 @@ +Õé°îï£3muxÁùº¾K]éìùYŒJáà€ìqàʺÒ"ØÐÜ[÷rú~FF] lÔ¡”ªß+U“Õù*¡;'ÜzúÊ|¡TŽj’)Žè„Àµ´¥U¾(…+¡¢uý_A|¹iÙ b;s¦WÞMŸõnžçb^…%±5ÛÌï ”`5 +Ín=é% \ No newline at end of file diff --git a/RNCryptorVectors/main.m b/RNCryptorVectors/main.m index 9615baf2..8e037770 100644 --- a/RNCryptorVectors/main.m +++ b/RNCryptorVectors/main.m @@ -8,6 +8,7 @@ #import #import "RNEncryptor.h" +#import "RNDecryptor.h" #import "RNCryptorEngine.h" void Encrypt(NSString *string, NSString *password, NSData *encryptionSalt, NSData *HMACSalt, NSData *IV) @@ -71,6 +72,13 @@ int main(int argc, const char * argv[]) error:&error]; [encryptedData writeToFile:@"/tmp/RNCryptor.enc" atomically:NO]; + + NSData *v1Data = [NSData dataWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"RNCryptorV1.enc" ofType:nil]]; + + NSData *decryptedData = [RNDecryptor decryptData:v1Data withPassword:password error:&error]; + NSLog(@"decryptedData:%@", [[NSString alloc] initWithData:decryptedData encoding:NSUTF8StringEncoding]); + NSLog(@"error:%@", error); + } return 0; }