Skip to content

Commit

Permalink
Test v1 backward compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
rnapier committed Jan 17, 2013
1 parent b4f8de2 commit 5729974
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 5 deletions.
3 changes: 3 additions & 0 deletions RNCryptor OS X/RNCryptor OS X-Prefix.pch
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
14 changes: 10 additions & 4 deletions RNCryptor.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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 */; };
Expand All @@ -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 */

Expand Down Expand Up @@ -104,6 +106,7 @@
FB7565241512D9BE007B808E /* RNOpenSSLDecryptor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RNOpenSSLDecryptor.h; sourceTree = "<group>"; };
FB7565241512D9BE007B8090 /* RNOpenSSLDecryptor.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RNOpenSSLDecryptor.m; sourceTree = "<group>"; };
FB7565241512D9BE007B8092 /* README.md */ = {isa = PBXFileReference; lastKnownFileType = file.md; path = README.md; sourceTree = "<group>"; };
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 = "<group>"; };
FBF7D593167E5032004B6F0F /* RNCryptorVectors-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "RNCryptorVectors-Prefix.pch"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -270,6 +273,7 @@
isa = PBXGroup;
children = (
FBF7D590167E5032004B6F0F /* main.m */,
FBE1F73A16A899D800C90463 /* RNCryptorV1.enc */,
FBF7D592167E5032004B6F0F /* Supporting Files */,
);
path = RNCryptorVectors;
Expand Down Expand Up @@ -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;
Expand All @@ -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)";
Expand Down
2 changes: 1 addition & 1 deletion RNCryptor/RNDecryptor.m
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 2 additions & 0 deletions RNCryptorV1.enc
Original file line number Diff line number Diff line change
@@ -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=�%
8 changes: 8 additions & 0 deletions RNCryptorVectors/main.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#import <Foundation/Foundation.h>
#import "RNEncryptor.h"
#import "RNDecryptor.h"
#import "RNCryptorEngine.h"

void Encrypt(NSString *string, NSString *password, NSData *encryptionSalt, NSData *HMACSalt, NSData *IV)
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 5729974

Please sign in to comment.