├── .gitignore
├── README.md
├── crypted-resource-ios
├── CryptedResources.xcodeproj
│ └── project.pbxproj
└── CryptedResources
│ ├── CryptedResourceLib
│ ├── CryptedConstants.h
│ ├── CryptedDataUtil.cpp
│ ├── CryptedDataUtil.h
│ ├── CryptedResources.h
│ ├── NSData+CryptedData.h
│ ├── NSData+CryptedData.mm
│ ├── NSString+CryptedString.h
│ ├── NSString+CryptedString.mm
│ ├── UIImage+CryptedImage.h
│ └── UIImage+CryptedImage.mm
│ ├── CryptedResources-Info.plist
│ ├── CryptedResources-Prefix.pch
│ ├── IMTAppDelegate.h
│ ├── IMTAppDelegate.m
│ ├── IMTViewController.h
│ ├── IMTViewController.m
│ ├── Resources
│ ├── Default-568h@2x.png
│ ├── Default.png
│ ├── Default@2x.png
│ ├── Icon.png
│ ├── Icon@2x.png
│ ├── inmite.cri
│ └── text.crs
│ ├── en.lproj
│ ├── InfoPlist.strings
│ └── MainStoryboard.storyboard
│ └── main.m
├── crypted-resource-java-tool
├── build.xml
├── lib
│ └── nblibraries.properties
├── manifest.mf
├── nbproject
│ ├── build-impl.xml
│ ├── genfiles.properties
│ ├── project.properties
│ └── project.xml
└── src
│ └── eu
│ └── inmite
│ └── application
│ ├── CryptedResource.java
│ └── resources
│ └── help.txt
└── pngcrypt
├── pngcrypt.xcodeproj
└── project.pbxproj
└── pngcrypt
└── main.m
/.gitignore:
--------------------------------------------------------------------------------
1 | # Xcode
2 | .DS_Store
3 | build/
4 | *.pbxuser
5 | !default.pbxuser
6 | *.mode1v3
7 | !default.mode1v3
8 | *.mode2v3
9 | !default.mode2v3
10 | *.perspectivev3
11 | !default.perspectivev3
12 | *.xcworkspace
13 | !default.xcworkspace
14 | xcuserdata
15 | profile
16 | *.moved-aside
17 | DerivedData
18 | .idea/
19 |
20 | # NetBeans specific #
21 | nbproject/private/
22 | build/
23 | nbbuild/
24 | dist/
25 | nbdist/
26 | nbactions.xml
27 | nb-configuration.xml
28 |
29 | # Mac Specific #
30 | .DS_Store
31 |
32 | # Class Files #
33 | *.class
34 |
35 | # Package Files #
36 | *.jar
37 | *.war
38 | *.ear
39 | /nbproject/private/
40 | /crypted-resource-java/nbproject/private/
41 | /crypted-resource-java-tool/nbproject/private/
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | Mobile library and tool for encrypted resources
2 | ===============================================
3 |
4 | This is a project for utility library and tools for resource and data encryption on iOS. It
5 | basically obfuscates resources using a XOR or AES256 function with a key provided in the binary,
6 | drawing resources unreadable for a regular users or modarate attackers.
7 |
8 | How to use
9 | ----------
10 |
11 | The project contains a simple tool written in Java that can be used to encrypt or decrypt
12 | files using XOR algorithm, as such:
13 |
14 | $ java -jar crypted-resource-java-tool.jar gen 16
15 | ffa17e84f481201844724a4e1c1b981e
16 |
17 | $ java -jar crypted-resource-java-tool.jar xor input.png output.cri ffa17e84f481201844724a4e1c1b981e
18 |
19 | The command above stores the crypted version of input.png
to the file
20 | output.cri
, using ffa17e84f481201844724a4e1c1b981e
as the key
21 | for encryption.
22 |
23 | Also, there is a sample iOS project that demonstrates the use of the client side library.
24 | All library files are under Lib/CryptedResources
group in the project. To
25 | use the library, just drag and drop the Lib/CryptedResources
group to your
26 | project.
27 |
28 | Then, you need to visit CryptedConstants.h
file and put the generated
29 | key there:
30 |
31 | #define DEFAULT_KEY @"ffa17e84f481201844724a4e1c1b981e"
32 |
33 | From this moment on, you are able to call the specific methods on UIImage
,
34 | NSString
and NSData
, for example:
35 |
36 | #import "CryptedResources.h"
37 |
38 | // ...
39 |
40 | self.image = [UIImage cryptedImageNamed:@"output.cri"];
41 | self.text = [NSString stringWithContentsOfCryptedFile:@"crypted_text.crs"
42 | encoding:NSUTF8StringEncoding];
43 | self.data = [NSData cryptedDataWithData:originalData];
44 |
45 | Alternatively, you can provide an individual key (in hexadecimal string format, or as a
46 | raw NSData object) for each of the resources, for example as such:
47 |
48 | self.data = [NSData cryptedDataWithData:originalData hexKey:@"1234567890abcdef"];
49 |
50 | This may come handy in case you need to obfuscate the key itself in the binary.
51 |
52 | See the header files for more detailed information on what methods are available.
53 |
54 | Licence
55 | -------
56 |
57 | This software is shared under the IHL ("Inmite Happiness License"), which is derived from
58 | [MIT license](http://en.wikipedia.org/wiki/MIT_License "MIT License at Wikipedia")
59 | completely, except for you have to follow [@inmite](http://twitter.com/inmite) if you are
60 | [happy](http://en.wikipedia.org/wiki/Happiness) using the software of matter.
61 |
62 | Planned features
63 | ----------------
64 |
65 | - AES256 data encryption
66 | - random key obfuscation generator
67 |
68 | F.A.Q
69 | -----
70 |
71 | **Why do I need to encrypt bundle resources in the mobile app?**
72 |
73 | There might be several reasons for resource encryption. The first one is preventing
74 | someone with moderate skills from stealing them from your application. Designing icons and
75 | app graphics is hard - stealing them is unfair.
76 |
77 | There are also more advanced reasons for resource encryption. If you write an application
78 | which uses an image wizard as an introduction, replacing image might instruct a user to
79 | perform an incorrect task (such as call a malicious number). These types of attacks play
80 | role in application with high security concerns, such as mobile banking or insurance apps.
81 |
82 | **Is this really secure? Is there no way attacker steals the data?**
83 |
84 | Well first, security is a subject of threads and their impacts. Basically, since all
85 | the cryptography happens on the device, hacker will winn, in the end. Unless you store
86 | the key in some smarter manner on the device (or even on the server), of course.
87 |
88 | The mechanism in it's basic form will prevent someone who is able to Jailbreak the device
89 | and use tools such as iExplorer to steal or modify your resources. And it can buy you some
90 | time...
--------------------------------------------------------------------------------
/crypted-resource-ios/CryptedResources.xcodeproj/project.pbxproj:
--------------------------------------------------------------------------------
1 | // !$*UTF8*$!
2 | {
3 | archiveVersion = 1;
4 | classes = {
5 | };
6 | objectVersion = 46;
7 | objects = {
8 |
9 | /* Begin PBXBuildFile section */
10 | 1B30990016EB7603004BC14D /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1B3098FF16EB7602004BC14D /* UIKit.framework */; };
11 | 1B30990216EB7603004BC14D /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1B30990116EB7603004BC14D /* Foundation.framework */; };
12 | 1B30990416EB7603004BC14D /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1B30990316EB7603004BC14D /* CoreGraphics.framework */; };
13 | 1B30990A16EB7603004BC14D /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 1B30990816EB7603004BC14D /* InfoPlist.strings */; };
14 | 1B30990C16EB7603004BC14D /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 1B30990B16EB7603004BC14D /* main.m */; };
15 | 1B30991016EB7603004BC14D /* IMTAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 1B30990F16EB7603004BC14D /* IMTAppDelegate.m */; };
16 | 1B30991216EB7603004BC14D /* Default.png in Resources */ = {isa = PBXBuildFile; fileRef = 1B30991116EB7603004BC14D /* Default.png */; };
17 | 1B30991416EB7603004BC14D /* Default@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 1B30991316EB7603004BC14D /* Default@2x.png */; };
18 | 1B30991616EB7603004BC14D /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 1B30991516EB7603004BC14D /* Default-568h@2x.png */; };
19 | 1B30991916EB7603004BC14D /* MainStoryboard.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 1B30991716EB7603004BC14D /* MainStoryboard.storyboard */; };
20 | 1B30991C16EB7603004BC14D /* IMTViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 1B30991B16EB7603004BC14D /* IMTViewController.m */; };
21 | 1B30993D16EB7652004BC14D /* CryptedDataUtil.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1B30993B16EB7652004BC14D /* CryptedDataUtil.cpp */; };
22 | 1B30994016EB7DF7004BC14D /* UIImage+CryptedImage.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1B30993F16EB7DF7004BC14D /* UIImage+CryptedImage.mm */; };
23 | 1B42AD7416ED65D500FB1164 /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1B42AD7316ED65D500FB1164 /* Security.framework */; };
24 | 1BDE0DAC16EBE189006B5960 /* NSString+CryptedString.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1BDE0DAB16EBE189006B5960 /* NSString+CryptedString.mm */; };
25 | 1BDE0DB416EBE7D8006B5960 /* Icon.png in Resources */ = {isa = PBXBuildFile; fileRef = 1BDE0DB216EBE7D8006B5960 /* Icon.png */; };
26 | 1BDE0DB516EBE7D8006B5960 /* Icon@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 1BDE0DB316EBE7D8006B5960 /* Icon@2x.png */; };
27 | 1BDE0DBC16EBFD1B006B5960 /* inmite.cri in Resources */ = {isa = PBXBuildFile; fileRef = 1BDE0DBB16EBFD1B006B5960 /* inmite.cri */; };
28 | 1BDE0DBF16EC0163006B5960 /* NSData+CryptedData.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1BDE0DBE16EC0162006B5960 /* NSData+CryptedData.mm */; };
29 | 1BDE0DC316EC07B2006B5960 /* text.crs in Resources */ = {isa = PBXBuildFile; fileRef = 1BDE0DC216EC07B2006B5960 /* text.crs */; };
30 | /* End PBXBuildFile section */
31 |
32 | /* Begin PBXFileReference section */
33 | 1B3098FC16EB7602004BC14D /* CryptedResources.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = CryptedResources.app; sourceTree = BUILT_PRODUCTS_DIR; };
34 | 1B3098FF16EB7602004BC14D /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
35 | 1B30990116EB7603004BC14D /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
36 | 1B30990316EB7603004BC14D /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; };
37 | 1B30990716EB7603004BC14D /* CryptedResources-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "CryptedResources-Info.plist"; sourceTree = ""; };
38 | 1B30990916EB7603004BC14D /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; };
39 | 1B30990B16EB7603004BC14D /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; };
40 | 1B30990D16EB7603004BC14D /* CryptedResources-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "CryptedResources-Prefix.pch"; sourceTree = ""; };
41 | 1B30990E16EB7603004BC14D /* IMTAppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = IMTAppDelegate.h; sourceTree = ""; };
42 | 1B30990F16EB7603004BC14D /* IMTAppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = IMTAppDelegate.m; sourceTree = ""; };
43 | 1B30991116EB7603004BC14D /* Default.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = Default.png; path = Resources/Default.png; sourceTree = ""; };
44 | 1B30991316EB7603004BC14D /* Default@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Default@2x.png"; path = "Resources/Default@2x.png"; sourceTree = ""; };
45 | 1B30991516EB7603004BC14D /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Default-568h@2x.png"; path = "Resources/Default-568h@2x.png"; sourceTree = ""; };
46 | 1B30991816EB7603004BC14D /* en */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = en; path = en.lproj/MainStoryboard.storyboard; sourceTree = ""; };
47 | 1B30991A16EB7603004BC14D /* IMTViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = IMTViewController.h; sourceTree = ""; };
48 | 1B30991B16EB7603004BC14D /* IMTViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = IMTViewController.m; sourceTree = ""; };
49 | 1B30992316EB7603004BC14D /* SenTestingKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SenTestingKit.framework; path = Library/Frameworks/SenTestingKit.framework; sourceTree = DEVELOPER_DIR; };
50 | 1B30993B16EB7652004BC14D /* CryptedDataUtil.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CryptedDataUtil.cpp; sourceTree = ""; };
51 | 1B30993C16EB7652004BC14D /* CryptedDataUtil.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CryptedDataUtil.h; sourceTree = ""; };
52 | 1B30993E16EB7DF7004BC14D /* UIImage+CryptedImage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIImage+CryptedImage.h"; sourceTree = ""; };
53 | 1B30993F16EB7DF7004BC14D /* UIImage+CryptedImage.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = "UIImage+CryptedImage.mm"; sourceTree = ""; };
54 | 1B42AD7316ED65D500FB1164 /* Security.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Security.framework; path = System/Library/Frameworks/Security.framework; sourceTree = SDKROOT; };
55 | 1BDE0DAA16EBE189006B5960 /* NSString+CryptedString.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSString+CryptedString.h"; sourceTree = ""; };
56 | 1BDE0DAB16EBE189006B5960 /* NSString+CryptedString.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = "NSString+CryptedString.mm"; sourceTree = ""; };
57 | 1BDE0DAD16EBE1C6006B5960 /* CryptedResources.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CryptedResources.h; sourceTree = ""; };
58 | 1BDE0DAE16EBE2BB006B5960 /* CryptedConstants.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CryptedConstants.h; sourceTree = ""; };
59 | 1BDE0DB216EBE7D8006B5960 /* Icon.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = Icon.png; path = Resources/Icon.png; sourceTree = ""; };
60 | 1BDE0DB316EBE7D8006B5960 /* Icon@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Icon@2x.png"; path = "Resources/Icon@2x.png"; sourceTree = ""; };
61 | 1BDE0DBB16EBFD1B006B5960 /* inmite.cri */ = {isa = PBXFileReference; lastKnownFileType = file; name = inmite.cri; path = Resources/inmite.cri; sourceTree = ""; };
62 | 1BDE0DBD16EC0162006B5960 /* NSData+CryptedData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSData+CryptedData.h"; sourceTree = ""; };
63 | 1BDE0DBE16EC0162006B5960 /* NSData+CryptedData.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = "NSData+CryptedData.mm"; sourceTree = ""; };
64 | 1BDE0DC216EC07B2006B5960 /* text.crs */ = {isa = PBXFileReference; lastKnownFileType = file; name = text.crs; path = Resources/text.crs; sourceTree = ""; };
65 | /* End PBXFileReference section */
66 |
67 | /* Begin PBXFrameworksBuildPhase section */
68 | 1B3098F916EB7602004BC14D /* Frameworks */ = {
69 | isa = PBXFrameworksBuildPhase;
70 | buildActionMask = 2147483647;
71 | files = (
72 | 1B30990016EB7603004BC14D /* UIKit.framework in Frameworks */,
73 | 1B30990216EB7603004BC14D /* Foundation.framework in Frameworks */,
74 | 1B30990416EB7603004BC14D /* CoreGraphics.framework in Frameworks */,
75 | 1B42AD7416ED65D500FB1164 /* Security.framework in Frameworks */,
76 | );
77 | runOnlyForDeploymentPostprocessing = 0;
78 | };
79 | /* End PBXFrameworksBuildPhase section */
80 |
81 | /* Begin PBXGroup section */
82 | 1B3098F316EB7602004BC14D = {
83 | isa = PBXGroup;
84 | children = (
85 | 1B30990516EB7603004BC14D /* CryptedResources */,
86 | 1B3098FE16EB7602004BC14D /* Frameworks */,
87 | 1B3098FD16EB7602004BC14D /* Products */,
88 | );
89 | sourceTree = "";
90 | };
91 | 1B3098FD16EB7602004BC14D /* Products */ = {
92 | isa = PBXGroup;
93 | children = (
94 | 1B3098FC16EB7602004BC14D /* CryptedResources.app */,
95 | );
96 | name = Products;
97 | sourceTree = "";
98 | };
99 | 1B3098FE16EB7602004BC14D /* Frameworks */ = {
100 | isa = PBXGroup;
101 | children = (
102 | 1B42AD7316ED65D500FB1164 /* Security.framework */,
103 | 1B3098FF16EB7602004BC14D /* UIKit.framework */,
104 | 1B30990116EB7603004BC14D /* Foundation.framework */,
105 | 1B30990316EB7603004BC14D /* CoreGraphics.framework */,
106 | 1B30992316EB7603004BC14D /* SenTestingKit.framework */,
107 | );
108 | name = Frameworks;
109 | sourceTree = "";
110 | };
111 | 1B30990516EB7603004BC14D /* CryptedResources */ = {
112 | isa = PBXGroup;
113 | children = (
114 | 1BDE0DB016EBE50D006B5960 /* Controller */,
115 | 1BDE0DAF16EBE4F8006B5960 /* Resources */,
116 | 1B30993A16EB7635004BC14D /* Lib */,
117 | 1B30990616EB7603004BC14D /* Supporting Files */,
118 | 1B30990E16EB7603004BC14D /* IMTAppDelegate.h */,
119 | 1B30990F16EB7603004BC14D /* IMTAppDelegate.m */,
120 | 1B30991716EB7603004BC14D /* MainStoryboard.storyboard */,
121 | );
122 | path = CryptedResources;
123 | sourceTree = "";
124 | };
125 | 1B30990616EB7603004BC14D /* Supporting Files */ = {
126 | isa = PBXGroup;
127 | children = (
128 | 1B30990716EB7603004BC14D /* CryptedResources-Info.plist */,
129 | 1B30990816EB7603004BC14D /* InfoPlist.strings */,
130 | 1B30990B16EB7603004BC14D /* main.m */,
131 | 1B30990D16EB7603004BC14D /* CryptedResources-Prefix.pch */,
132 | 1B30991116EB7603004BC14D /* Default.png */,
133 | 1B30991316EB7603004BC14D /* Default@2x.png */,
134 | 1B30991516EB7603004BC14D /* Default-568h@2x.png */,
135 | 1BDE0DB216EBE7D8006B5960 /* Icon.png */,
136 | 1BDE0DB316EBE7D8006B5960 /* Icon@2x.png */,
137 | );
138 | name = "Supporting Files";
139 | sourceTree = "";
140 | };
141 | 1B30993A16EB7635004BC14D /* Lib */ = {
142 | isa = PBXGroup;
143 | children = (
144 | 1BDE0DB916EBE89A006B5960 /* CryptedResources */,
145 | );
146 | name = Lib;
147 | sourceTree = "";
148 | };
149 | 1BDE0DAF16EBE4F8006B5960 /* Resources */ = {
150 | isa = PBXGroup;
151 | children = (
152 | 1BDE0DC216EC07B2006B5960 /* text.crs */,
153 | 1BDE0DBB16EBFD1B006B5960 /* inmite.cri */,
154 | );
155 | name = Resources;
156 | sourceTree = "";
157 | };
158 | 1BDE0DB016EBE50D006B5960 /* Controller */ = {
159 | isa = PBXGroup;
160 | children = (
161 | 1B30991A16EB7603004BC14D /* IMTViewController.h */,
162 | 1B30991B16EB7603004BC14D /* IMTViewController.m */,
163 | );
164 | name = Controller;
165 | sourceTree = "";
166 | };
167 | 1BDE0DB916EBE89A006B5960 /* CryptedResources */ = {
168 | isa = PBXGroup;
169 | children = (
170 | 1BDE0DAD16EBE1C6006B5960 /* CryptedResources.h */,
171 | 1BDE0DAE16EBE2BB006B5960 /* CryptedConstants.h */,
172 | 1B30993C16EB7652004BC14D /* CryptedDataUtil.h */,
173 | 1B30993B16EB7652004BC14D /* CryptedDataUtil.cpp */,
174 | 1B30993E16EB7DF7004BC14D /* UIImage+CryptedImage.h */,
175 | 1B30993F16EB7DF7004BC14D /* UIImage+CryptedImage.mm */,
176 | 1BDE0DAA16EBE189006B5960 /* NSString+CryptedString.h */,
177 | 1BDE0DAB16EBE189006B5960 /* NSString+CryptedString.mm */,
178 | 1BDE0DBD16EC0162006B5960 /* NSData+CryptedData.h */,
179 | 1BDE0DBE16EC0162006B5960 /* NSData+CryptedData.mm */,
180 | );
181 | name = CryptedResources;
182 | path = CryptedResourceLib;
183 | sourceTree = "";
184 | };
185 | /* End PBXGroup section */
186 |
187 | /* Begin PBXNativeTarget section */
188 | 1B3098FB16EB7602004BC14D /* CryptedResources */ = {
189 | isa = PBXNativeTarget;
190 | buildConfigurationList = 1B30993416EB7603004BC14D /* Build configuration list for PBXNativeTarget "CryptedResources" */;
191 | buildPhases = (
192 | 1B3098F816EB7602004BC14D /* Sources */,
193 | 1B3098F916EB7602004BC14D /* Frameworks */,
194 | 1B3098FA16EB7602004BC14D /* Resources */,
195 | );
196 | buildRules = (
197 | );
198 | dependencies = (
199 | );
200 | name = CryptedResources;
201 | productName = CryptedResources;
202 | productReference = 1B3098FC16EB7602004BC14D /* CryptedResources.app */;
203 | productType = "com.apple.product-type.application";
204 | };
205 | /* End PBXNativeTarget section */
206 |
207 | /* Begin PBXProject section */
208 | 1B3098F416EB7602004BC14D /* Project object */ = {
209 | isa = PBXProject;
210 | attributes = {
211 | CLASSPREFIX = IMT;
212 | LastUpgradeCheck = 0460;
213 | ORGANIZATIONNAME = "Inmite s.r.o";
214 | };
215 | buildConfigurationList = 1B3098F716EB7602004BC14D /* Build configuration list for PBXProject "CryptedResources" */;
216 | compatibilityVersion = "Xcode 3.2";
217 | developmentRegion = English;
218 | hasScannedForEncodings = 0;
219 | knownRegions = (
220 | en,
221 | );
222 | mainGroup = 1B3098F316EB7602004BC14D;
223 | productRefGroup = 1B3098FD16EB7602004BC14D /* Products */;
224 | projectDirPath = "";
225 | projectRoot = "";
226 | targets = (
227 | 1B3098FB16EB7602004BC14D /* CryptedResources */,
228 | );
229 | };
230 | /* End PBXProject section */
231 |
232 | /* Begin PBXResourcesBuildPhase section */
233 | 1B3098FA16EB7602004BC14D /* Resources */ = {
234 | isa = PBXResourcesBuildPhase;
235 | buildActionMask = 2147483647;
236 | files = (
237 | 1B30990A16EB7603004BC14D /* InfoPlist.strings in Resources */,
238 | 1B30991216EB7603004BC14D /* Default.png in Resources */,
239 | 1B30991416EB7603004BC14D /* Default@2x.png in Resources */,
240 | 1B30991616EB7603004BC14D /* Default-568h@2x.png in Resources */,
241 | 1B30991916EB7603004BC14D /* MainStoryboard.storyboard in Resources */,
242 | 1BDE0DB416EBE7D8006B5960 /* Icon.png in Resources */,
243 | 1BDE0DB516EBE7D8006B5960 /* Icon@2x.png in Resources */,
244 | 1BDE0DBC16EBFD1B006B5960 /* inmite.cri in Resources */,
245 | 1BDE0DC316EC07B2006B5960 /* text.crs in Resources */,
246 | );
247 | runOnlyForDeploymentPostprocessing = 0;
248 | };
249 | /* End PBXResourcesBuildPhase section */
250 |
251 | /* Begin PBXSourcesBuildPhase section */
252 | 1B3098F816EB7602004BC14D /* Sources */ = {
253 | isa = PBXSourcesBuildPhase;
254 | buildActionMask = 2147483647;
255 | files = (
256 | 1B30990C16EB7603004BC14D /* main.m in Sources */,
257 | 1B30991016EB7603004BC14D /* IMTAppDelegate.m in Sources */,
258 | 1B30991C16EB7603004BC14D /* IMTViewController.m in Sources */,
259 | 1B30993D16EB7652004BC14D /* CryptedDataUtil.cpp in Sources */,
260 | 1B30994016EB7DF7004BC14D /* UIImage+CryptedImage.mm in Sources */,
261 | 1BDE0DAC16EBE189006B5960 /* NSString+CryptedString.mm in Sources */,
262 | 1BDE0DBF16EC0163006B5960 /* NSData+CryptedData.mm in Sources */,
263 | );
264 | runOnlyForDeploymentPostprocessing = 0;
265 | };
266 | /* End PBXSourcesBuildPhase section */
267 |
268 | /* Begin PBXVariantGroup section */
269 | 1B30990816EB7603004BC14D /* InfoPlist.strings */ = {
270 | isa = PBXVariantGroup;
271 | children = (
272 | 1B30990916EB7603004BC14D /* en */,
273 | );
274 | name = InfoPlist.strings;
275 | sourceTree = "";
276 | };
277 | 1B30991716EB7603004BC14D /* MainStoryboard.storyboard */ = {
278 | isa = PBXVariantGroup;
279 | children = (
280 | 1B30991816EB7603004BC14D /* en */,
281 | );
282 | name = MainStoryboard.storyboard;
283 | sourceTree = "";
284 | };
285 | /* End PBXVariantGroup section */
286 |
287 | /* Begin XCBuildConfiguration section */
288 | 1B30993216EB7603004BC14D /* Debug */ = {
289 | isa = XCBuildConfiguration;
290 | buildSettings = {
291 | ALWAYS_SEARCH_USER_PATHS = NO;
292 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
293 | CLANG_CXX_LIBRARY = "libc++";
294 | CLANG_ENABLE_OBJC_ARC = YES;
295 | CLANG_WARN_CONSTANT_CONVERSION = YES;
296 | CLANG_WARN_EMPTY_BODY = YES;
297 | CLANG_WARN_ENUM_CONVERSION = YES;
298 | CLANG_WARN_INT_CONVERSION = YES;
299 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
300 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
301 | COPY_PHASE_STRIP = NO;
302 | GCC_C_LANGUAGE_STANDARD = gnu99;
303 | GCC_DYNAMIC_NO_PIC = NO;
304 | GCC_OPTIMIZATION_LEVEL = 0;
305 | GCC_PREPROCESSOR_DEFINITIONS = (
306 | "DEBUG=1",
307 | "$(inherited)",
308 | );
309 | GCC_SYMBOLS_PRIVATE_EXTERN = NO;
310 | GCC_WARN_ABOUT_RETURN_TYPE = YES;
311 | GCC_WARN_UNINITIALIZED_AUTOS = YES;
312 | GCC_WARN_UNUSED_VARIABLE = YES;
313 | IPHONEOS_DEPLOYMENT_TARGET = 5.0;
314 | ONLY_ACTIVE_ARCH = YES;
315 | SDKROOT = iphoneos;
316 | };
317 | name = Debug;
318 | };
319 | 1B30993316EB7603004BC14D /* Release */ = {
320 | isa = XCBuildConfiguration;
321 | buildSettings = {
322 | ALWAYS_SEARCH_USER_PATHS = NO;
323 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
324 | CLANG_CXX_LIBRARY = "libc++";
325 | CLANG_ENABLE_OBJC_ARC = YES;
326 | CLANG_WARN_CONSTANT_CONVERSION = YES;
327 | CLANG_WARN_EMPTY_BODY = YES;
328 | CLANG_WARN_ENUM_CONVERSION = YES;
329 | CLANG_WARN_INT_CONVERSION = YES;
330 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
331 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
332 | COPY_PHASE_STRIP = YES;
333 | GCC_C_LANGUAGE_STANDARD = gnu99;
334 | GCC_WARN_ABOUT_RETURN_TYPE = YES;
335 | GCC_WARN_UNINITIALIZED_AUTOS = YES;
336 | GCC_WARN_UNUSED_VARIABLE = YES;
337 | IPHONEOS_DEPLOYMENT_TARGET = 5.0;
338 | OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1";
339 | SDKROOT = iphoneos;
340 | VALIDATE_PRODUCT = YES;
341 | };
342 | name = Release;
343 | };
344 | 1B30993516EB7603004BC14D /* Debug */ = {
345 | isa = XCBuildConfiguration;
346 | buildSettings = {
347 | GCC_PRECOMPILE_PREFIX_HEADER = YES;
348 | GCC_PREFIX_HEADER = "CryptedResources/CryptedResources-Prefix.pch";
349 | INFOPLIST_FILE = "CryptedResources/CryptedResources-Info.plist";
350 | IPHONEOS_DEPLOYMENT_TARGET = 5.0;
351 | PRODUCT_NAME = CryptedResources;
352 | WRAPPER_EXTENSION = app;
353 | };
354 | name = Debug;
355 | };
356 | 1B30993616EB7603004BC14D /* Release */ = {
357 | isa = XCBuildConfiguration;
358 | buildSettings = {
359 | GCC_PRECOMPILE_PREFIX_HEADER = YES;
360 | GCC_PREFIX_HEADER = "CryptedResources/CryptedResources-Prefix.pch";
361 | INFOPLIST_FILE = "CryptedResources/CryptedResources-Info.plist";
362 | IPHONEOS_DEPLOYMENT_TARGET = 5.0;
363 | PRODUCT_NAME = CryptedResources;
364 | WRAPPER_EXTENSION = app;
365 | };
366 | name = Release;
367 | };
368 | /* End XCBuildConfiguration section */
369 |
370 | /* Begin XCConfigurationList section */
371 | 1B3098F716EB7602004BC14D /* Build configuration list for PBXProject "CryptedResources" */ = {
372 | isa = XCConfigurationList;
373 | buildConfigurations = (
374 | 1B30993216EB7603004BC14D /* Debug */,
375 | 1B30993316EB7603004BC14D /* Release */,
376 | );
377 | defaultConfigurationIsVisible = 0;
378 | defaultConfigurationName = Release;
379 | };
380 | 1B30993416EB7603004BC14D /* Build configuration list for PBXNativeTarget "CryptedResources" */ = {
381 | isa = XCConfigurationList;
382 | buildConfigurations = (
383 | 1B30993516EB7603004BC14D /* Debug */,
384 | 1B30993616EB7603004BC14D /* Release */,
385 | );
386 | defaultConfigurationIsVisible = 0;
387 | defaultConfigurationName = Release;
388 | };
389 | /* End XCConfigurationList section */
390 | };
391 | rootObject = 1B3098F416EB7602004BC14D /* Project object */;
392 | }
393 |
--------------------------------------------------------------------------------
/crypted-resource-ios/CryptedResources/CryptedResourceLib/CryptedConstants.h:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2013, Inmite s.r.o. (www.inmite.eu).
3 | *
4 | * All rights reserved. This source code can be used only for purposes specified
5 | * by the given license contract signed by the rightful deputy of Inmite s.r.o.
6 | * This source code can be used only by the owner of the license.
7 | *
8 | * Any disputes arising in respect of this agreement (license) shall be brought
9 | * before the Municipal Court of Prague.
10 | *
11 | */
12 |
13 | #ifndef CryptedConstants_h
14 | #define CryptedConstants_h
15 |
16 | /**
17 | * Edit this key to contain a hexadecimal string, you can generate the key using the
18 | * java utility available at: https://github.com/inmite/imt-crypted-resources
19 | */
20 | #define DEFAULT_KEY @"5189bb939f3476f1d4b76d435305e8f21a09d1134f0a115317a312236bc947d72e3218ac0c785547f3b7c79db9d9f985d861e14f4beaa6fde060cff8e9d3f588531312804485400b06087febc64971c465543f9201511f7964e92ef904998c7cb4d2385e96e041b463ec2bf43ff05a8f59dca08472029363b27f736e18c56f43a238c37b54bcae7140719ef4ce12add695f60f4aef5ec01a13f9a6901613557aae9ba23f204315c7307d4e2f2d7f033e203c49fc2a9b88f7909db83a3c748f9be7118cd942aedb103c35447e9ba0db025bf8f47f7ea8c350d8e259498e1b8f4cc7c37a3c34059c6a61a1882ad13060cbfb4500c830a262c4a9547370015f0847"
21 |
22 | #endif
23 |
--------------------------------------------------------------------------------
/crypted-resource-ios/CryptedResources/CryptedResourceLib/CryptedDataUtil.cpp:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2013, Inmite s.r.o. (www.inmite.eu).
3 | *
4 | * All rights reserved. This source code can be used only for purposes specified
5 | * by the given license contract signed by the rightful deputy of Inmite s.r.o.
6 | * This source code can be used only by the owner of the license.
7 | *
8 | * Any disputes arising in respect of this agreement (license) shall be brought
9 | * before the Municipal Court of Prague.
10 | *
11 | */
12 |
13 | #include "CryptedDataUtil.h"
14 | #include
15 | #include
16 | #include
17 |
18 | #define hex(c) ((c >= '0' && c <= '9')?c - '0':((c >= 'a' && c <= 'f')?10 + c - 'a':((c >= 'A' && c <= 'F')?10 + c - 'A':-1)))
19 |
20 | char *CryptedDataUtil::hex2bytes(char *hex, size_t len) {
21 | if (len % 2 != 0) {
22 | return NULL;
23 | }
24 | char *result = (char*)malloc(len / 2);
25 | for (int i = 0; i < len / 2; i++) {
26 | char upper = hex(hex[i * 2]);
27 | char lower = hex(hex[i * 2 + 1]);
28 | result[i] = upper * 16 + lower;
29 | }
30 | return result;
31 | }
32 |
33 | char* CryptedDataUtil::dataFromCryptedData(char* encryptedData, size_t dataLength, char *symKey, size_t symKeyLength, size_t * outputLength) {
34 | char *originalBytes = (char*) malloc(dataLength * sizeof(char));
35 |
36 | for (size_t i = 0; i < dataLength; i++) {
37 | originalBytes[i] = encryptedData[i] ^ symKey[i % symKeyLength];
38 | }
39 |
40 | // return the length of the resulting data
41 | *outputLength = dataLength;
42 |
43 | return originalBytes;
44 | }
45 |
46 | char* CryptedDataUtil::cryptedDataFromData(char* originalData, size_t dataLength, char *symKey, size_t symKeyLength, size_t * outputLength) {
47 | char *originalBytes = (char*) malloc(dataLength * sizeof(char));
48 |
49 | for (size_t i = 0; i < dataLength; i++) {
50 | originalBytes[i] = originalData[i] ^ symKey[i % symKeyLength];
51 | }
52 |
53 | // return the length of the resulting data
54 | *outputLength = dataLength;
55 |
56 | return originalBytes;
57 | }
58 |
59 | char* CryptedDataUtil::dataFromCryptedFile(const char* fileName, char *symKey, size_t symKeyLength, size_t * outputLength) {
60 | FILE* pFile;
61 | long lSize;
62 | char* encryptedData;
63 | size_t result;
64 |
65 | pFile = fopen(fileName, "rb" );
66 | if (pFile == NULL) {
67 | return NULL;
68 | }
69 |
70 | // obtain file size:
71 | fseek(pFile , 0 , SEEK_END);
72 | lSize = ftell(pFile);
73 | rewind(pFile);
74 |
75 | // allocate memory to contain the whole file:
76 | encryptedData = (char*) malloc(sizeof(char) * lSize);
77 | if (encryptedData == NULL) {
78 | return NULL;
79 | }
80 |
81 | // copy the file into the buffer:
82 | result = fread(encryptedData, 1, lSize, pFile);
83 | if (result != lSize) {
84 | return NULL;
85 | }
86 |
87 | fclose (pFile);
88 |
89 | char *originalBytes = dataFromCryptedData(encryptedData, lSize, symKey, symKeyLength, outputLength);
90 |
91 | free (encryptedData);
92 |
93 | return originalBytes;
94 |
95 | }
96 |
97 | char* CryptedDataUtil::aes256CryptedDataFromData(char *data, size_t data_length, char *key, size_t keyLength, size_t *outputLength) {
98 | char keyPtr[kCCKeySizeAES256 + 1];
99 | bzero(keyPtr, sizeof(keyPtr)); // fill with zeroes
100 |
101 | // copy and nullpad the key
102 | for (int i = 0; i < keyLength && i < kCCKeySizeAES256+1; i++) {
103 | keyPtr[i] = key[i];
104 | }
105 |
106 | size_t bufferSize = data_length + kCCBlockSizeAES128;
107 | char *buffer = (char*)malloc(bufferSize);
108 |
109 | *outputLength = 0;
110 | CCCryptorStatus cryptStatus = CCCrypt(kCCEncrypt, kCCAlgorithmAES128, kCCOptionPKCS7Padding,
111 | keyPtr, kCCKeySizeAES256,
112 | NULL,
113 | data, data_length, /* input */
114 | buffer, bufferSize, /* output */
115 | outputLength);
116 | if (cryptStatus == kCCSuccess) {
117 | return buffer;
118 | }
119 |
120 | free(buffer); //free the buffer;
121 | return NULL;
122 | }
123 |
124 | char *CryptedDataUtil::aes256DataFromCryptedData(char *data, size_t data_length, char *key, size_t keyLength, size_t *outputLength) {
125 | char keyPtr[kCCKeySizeAES256 + 1];
126 | bzero(keyPtr, sizeof(keyPtr)); // fill with zeroes (for padding)
127 |
128 | // copy and nullpad the key
129 | for (int i = 0; i < keyLength && i < kCCKeySizeAES256+1; i++) {
130 | keyPtr[i] = key[i];
131 | }
132 |
133 | size_t bufferSize = data_length + kCCBlockSizeAES128;
134 | char *buffer = (char*)malloc(bufferSize);
135 |
136 | *outputLength = 0;
137 | CCCryptorStatus cryptStatus = CCCrypt(kCCDecrypt, kCCAlgorithmAES128, kCCOptionPKCS7Padding,
138 | keyPtr, kCCKeySizeAES256,
139 | NULL /* initialization vector (optional) */,
140 | data, data_length, /* input */
141 | buffer, bufferSize, /* output */
142 | outputLength);
143 |
144 | if (cryptStatus == kCCSuccess) {
145 | //the returned NSData takes ownership of the buffer and will free it on deallocation
146 | return buffer;
147 | }
148 |
149 | free(buffer); //free the buffer;
150 | return NULL;
151 | }
152 |
153 | char* CryptedDataUtil::aes256DataFromCryptedFile(const char* fileName, char *symKey, size_t symKeyLength, size_t * outputLength) {
154 | FILE* pFile;
155 | long lSize;
156 | char* encryptedData;
157 | size_t result;
158 |
159 | pFile = fopen(fileName, "rb" );
160 | if (pFile == NULL) {
161 | return NULL;
162 | }
163 |
164 | // obtain file size:
165 | fseek(pFile , 0 , SEEK_END);
166 | lSize = ftell(pFile);
167 | rewind(pFile);
168 |
169 | // allocate memory to contain the whole file:
170 | encryptedData = (char*) malloc(sizeof(char) * lSize);
171 | if (encryptedData == NULL) {
172 | return NULL;
173 | }
174 |
175 | // copy the file into the buffer:
176 | result = fread(encryptedData, 1, lSize, pFile);
177 | if (result != lSize) {
178 | return NULL;
179 | }
180 |
181 | fclose (pFile);
182 |
183 | char *originalBytes = aes256DataFromCryptedData(encryptedData, lSize, symKey, symKeyLength, outputLength);
184 |
185 | free (encryptedData);
186 |
187 | return originalBytes;
188 |
189 | }
190 |
--------------------------------------------------------------------------------
/crypted-resource-ios/CryptedResources/CryptedResourceLib/CryptedDataUtil.h:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2013, Inmite s.r.o. (www.inmite.eu).
3 | *
4 | * All rights reserved. This source code can be used only for purposes specified
5 | * by the given license contract signed by the rightful deputy of Inmite s.r.o.
6 | * This source code can be used only by the owner of the license.
7 | *
8 | * Any disputes arising in respect of this agreement (license) shall be brought
9 | * before the Municipal Court of Prague.
10 | *
11 | */
12 |
13 | #ifndef __CryptedDataUtil__
14 | #define __CryptedDataUtil__
15 |
16 | #include
17 |
18 | using namespace std;
19 |
20 | class CryptedDataUtil {
21 | public:
22 | static char* hex2bytes(char *hex, size_t len);
23 | static char* dataFromCryptedData(char* encryptedData, size_t dataLength, char *symKey, size_t symKeyLength, size_t * outputLength);
24 | static char* cryptedDataFromData(char* originalData, size_t dataLength, char *symKey, size_t symKeyLength, size_t * outputLength);
25 | static char* dataFromCryptedFile(const char* fileName, char *symKey, size_t symKeyLength, size_t * outputLength);
26 | static char* aes256CryptedDataFromData(char *data, size_t data_length, char *key, size_t keyLength, size_t *outputLength);
27 | static char* aes256DataFromCryptedData(char *data, size_t data_length, char *key, size_t keyLength, size_t *outputLength);
28 | static char* aes256DataFromCryptedFile(const char* fileName, char *symKey, size_t symKeyLength, size_t * outputLength);
29 |
30 | };
31 |
32 | #endif /* defined(__CryptedDataUtil__) */
33 |
--------------------------------------------------------------------------------
/crypted-resource-ios/CryptedResources/CryptedResourceLib/CryptedResources.h:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2013, Inmite s.r.o. (www.inmite.eu).
3 | *
4 | * All rights reserved. This source code can be used only for purposes specified
5 | * by the given license contract signed by the rightful deputy of Inmite s.r.o.
6 | * This source code can be used only by the owner of the license.
7 | *
8 | * Any disputes arising in respect of this agreement (license) shall be brought
9 | * before the Municipal Court of Prague.
10 | *
11 | */
12 |
13 | #ifndef CryptedResources_h
14 | #define CryptedResources_h
15 |
16 | #import "CryptedConstants.h"
17 | #import "NSData+CryptedData.h"
18 | #import "NSString+CryptedString.h"
19 | #import "UIImage+CryptedImage.h"
20 |
21 | #endif
22 |
--------------------------------------------------------------------------------
/crypted-resource-ios/CryptedResources/CryptedResourceLib/NSData+CryptedData.h:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2013, Inmite s.r.o. (www.inmite.eu).
3 | *
4 | * All rights reserved. This source code can be used only for purposes specified
5 | * by the given license contract signed by the rightful deputy of Inmite s.r.o.
6 | * This source code can be used only by the owner of the license.
7 | *
8 | * Any disputes arising in respect of this agreement (license) shall be brought
9 | * before the Municipal Court of Prague.
10 | *
11 | */
12 |
13 | #import
14 |
15 | @interface NSData (CryptedData)
16 |
17 | + (NSData*) cryptedDataWithData:(NSData*)originalData rawKey:(NSData*)rawKey;
18 | + (NSData*) cryptedDataWithData:(NSData*)originalData hexKey:(NSString*)hexKey;
19 | + (NSData*) cryptedDataWithData:(NSData*)originalData;
20 | + (NSData*) aes256cryptedDataWithData:(NSData*)originalData rawKey:(NSData*)rawKey;
21 | + (NSData*) aes256cryptedDataWithData:(NSData*)originalData hexKey:(NSString*)hexKey;
22 | + (NSData*) aes256cryptedDataWithData:(NSData*)originalData;
23 |
24 | + (NSData*) dataWithCryptedData:(NSData*)encryptedData rawKey:(NSData*)rawKey;
25 | + (NSData*) dataWithCryptedData:(NSData*)encryptedData hexKey:(NSString*)hexKey;
26 | + (NSData*) dataWithCryptedData:(NSData*)encryptedData;
27 | + (NSData*) dataWithAes256CryptedData:(NSData*)encryptedData rawKey:(NSData*)rawKey;
28 | + (NSData*) dataWithAes256CryptedData:(NSData*)encryptedData hexKey:(NSString*)hexKey;
29 | + (NSData*) dataWithAes256CryptedData:(NSData*)encryptedData;
30 |
31 | + (NSData*) dataWithContentsOfCryptedFile:(NSString *)fullPath rawKey:(NSData*)rawKey;
32 | + (NSData*) dataWithContentsOfCryptedFile:(NSString *)fullPath hexKey:(NSString*)hexKey;
33 | + (NSData*) dataWithContentsOfCryptedFile:(NSString *)fullPath;
34 |
35 | + (NSData*) dataWithContentsOfAes256CryptedFile:(NSString *)fullPath rawKey:(NSData*)rawKey;
36 | + (NSData*) dataWithContentsOfAes256CryptedFile:(NSString *)fullPath hexKey:(NSString*)hexKey;
37 | + (NSData*) dataWithContentsOfAes256CryptedFile:(NSString *)fullPath;
38 |
39 |
40 | @end
41 |
--------------------------------------------------------------------------------
/crypted-resource-ios/CryptedResources/CryptedResourceLib/NSData+CryptedData.mm:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2013, Inmite s.r.o. (www.inmite.eu).
3 | *
4 | * All rights reserved. This source code can be used only for purposes specified
5 | * by the given license contract signed by the rightful deputy of Inmite s.r.o.
6 | * This source code can be used only by the owner of the license.
7 | *
8 | * Any disputes arising in respect of this agreement (license) shall be brought
9 | * before the Municipal Court of Prague.
10 | *
11 | */
12 |
13 | #import "NSData+CryptedData.h"
14 | #import "CryptedDataUtil.h"
15 | #import "CryptedConstants.h"
16 |
17 | @implementation NSData (CryptedData)
18 |
19 | #pragma mark - XOR encryption support
20 |
21 | /**
22 | * Returns data obtained after decrypting crypted data using the client provided raw key.
23 | * @param encryptedData A chunk of crypted data to be decrypted.
24 | * @param rawKey A key used to decrypt the crypted data, raw bytes.
25 | * @return An instance of NSData obrained by decrypting the crypted data. The decrypted data
26 | * does not have to be valid when using the incorrect key.
27 | */
28 | + (NSData*) dataWithCryptedData:(NSData*)encryptedData rawKey:(NSData*)rawKey {
29 | size_t size;
30 | char *originalBytes = CryptedDataUtil::dataFromCryptedData((char*)[encryptedData bytes], [encryptedData length], (char*)[rawKey bytes], [rawKey length], &size);
31 | return [NSData dataWithBytesNoCopy:originalBytes length:size freeWhenDone:YES];
32 | }
33 |
34 | /**
35 | * Returns data obtained after decrypting crypted data stored in a specified file using
36 | * the client provided raw key.
37 | * @param fullPath A full path to the binary file with the crypted data.
38 | * @param rawKey A key used to decrypt the crypted data, raw bytes.
39 | * @return An instance of NSData obrained by decrypting the crypted data. The decrypted data
40 | * does not have to be valid when using the incorrect key.
41 | */
42 | + (NSData*) dataWithContentsOfCryptedFile:(NSString *)fullPath rawKey:(NSData*)rawKey {
43 | size_t size;
44 | if (![[NSFileManager defaultManager] fileExistsAtPath:fullPath]) {
45 | return nil;
46 | }
47 | char *originalBytes = CryptedDataUtil::dataFromCryptedFile([fullPath UTF8String], (char*)[rawKey bytes], [rawKey length], &size);
48 | return [NSData dataWithBytesNoCopy:originalBytes length:size freeWhenDone:YES];
49 | }
50 |
51 | /**
52 | * Returns data obtained after decrypting crypted data using the client provided key.
53 | * @param encryptedData A chunk of crypted data to be decrypted.
54 | * @param hexKey A key used to decrypt the crypted data, hexadecimal string.
55 | * @return An instance of NSData obrained by decrypting the crypted data. The decrypted data
56 | * does not have to be valid when using the incorrect key.
57 | */
58 | + (NSData*) dataWithCryptedData:(NSData*)encryptedData hexKey:(NSString*)hexKey {
59 | size_t size;
60 | char *rawKey = CryptedDataUtil::hex2bytes((char*)[hexKey cStringUsingEncoding:NSASCIIStringEncoding], [hexKey length]);
61 | char *originalBytes = CryptedDataUtil::dataFromCryptedData((char*)[encryptedData bytes], [encryptedData length], (char*)rawKey, [hexKey length] / 2, &size);
62 | return [NSData dataWithBytesNoCopy:originalBytes length:size freeWhenDone:YES];
63 | }
64 |
65 | /**
66 | * Returns data obtained after decrypting crypted data stored in a specified file using
67 | * the client provided key.
68 | * @param fullPath A full path to the binary file with the crypted data.
69 | * @param hexKey A key used to decrypt the crypted data, hexadecimal string.
70 | * @return An instance of NSData obrained by decrypting the crypted data. The decrypted data
71 | * does not have to be valid when using the incorrect key.
72 | */
73 | + (NSData*) dataWithContentsOfCryptedFile:(NSString *)fullPath hexKey:(NSString*)hexKey {
74 | size_t size;
75 | if (![[NSFileManager defaultManager] fileExistsAtPath:fullPath]) {
76 | return nil;
77 | }
78 | char *rawKey = CryptedDataUtil::hex2bytes((char*)[hexKey cStringUsingEncoding:NSASCIIStringEncoding], [hexKey length]);
79 | char *originalBytes = CryptedDataUtil::dataFromCryptedFile([fullPath UTF8String], (char*)rawKey, [hexKey length] / 2, &size);
80 | return [NSData dataWithBytesNoCopy:originalBytes length:size freeWhenDone:YES];
81 | }
82 |
83 | /**
84 | * Returns data obtained after decrypting crypted data using the shared default key.
85 | * @param encryptedData A chunk of crypted data to be decrypted.
86 | * @return An instance of NSData obrained by decrypting the crypted data. The decrypted data
87 | * does not have to be valid when using the incorrect default key.
88 | */
89 | + (NSData*) dataWithCryptedData:(NSData*)encryptedData {
90 | return [NSData cryptedDataWithData:encryptedData hexKey:DEFAULT_KEY];
91 | }
92 |
93 | /**
94 | * Returns data obtained after decrypting crypted data stored in a specified file using
95 | * the shared default key.
96 | * @param fullPath A full path to the binary file with the crypted data.
97 | * @return An instance of NSData obrained by decrypting the crypted data. The decrypted data
98 | * does not have to be valid when using the incorrect default key.
99 | */
100 | + (NSData*) dataWithContentsOfCryptedFile:(NSString *)fullPath {
101 | return [NSData dataWithContentsOfCryptedFile:fullPath hexKey:DEFAULT_KEY];
102 | }
103 |
104 | /**
105 | * Return an encrypted data by crypting the original data with a default key.
106 | * @param originalData A original data to be encrypted.
107 | * @return Encrypted original data using the default key.
108 | */
109 | + (NSData *)cryptedDataWithData:(NSData *)originalData {
110 | return [NSData cryptedDataWithData:originalData hexKey:DEFAULT_KEY];
111 | }
112 |
113 | /**
114 | * Return an encrypted data by crypting the original data with a provided hexadecimal key.
115 | * @param originalData A original data to be encrypted.
116 | * @param hexKey A hexadecimal string to be used as a key for encryption.
117 | * @return Encrypted original data using the provided hexadecimal key.
118 | */
119 | + (NSData *)cryptedDataWithData:(NSData *)originalData hexKey:(NSString *)hexKey {
120 | size_t size;
121 | char *rawKey = CryptedDataUtil::hex2bytes((char*)[hexKey cStringUsingEncoding:NSASCIIStringEncoding], [hexKey length]);
122 | char *cryptedBytes = CryptedDataUtil::cryptedDataFromData((char*)[originalData bytes], originalData.length, rawKey, [hexKey length] / 2, &size);
123 | return [NSData dataWithBytesNoCopy:cryptedBytes length:size freeWhenDone:YES];
124 | }
125 |
126 | /**
127 | * Return an encrypted data by crypting the original data with a provided raw key.
128 | * @param originalData A original data to be encrypted.
129 | * @param hexKey A raw data to be used as a key for encryption.
130 | * @return Encrypted original data using the provided raw key.
131 | */
132 | + (NSData *)cryptedDataWithData:(NSData *)originalData rawKey:(NSData *)rawKey {
133 | size_t size;
134 | char *cryptedBytes = CryptedDataUtil::cryptedDataFromData((char*)[originalData bytes], originalData.length, (char*)[rawKey bytes], rawKey.length, &size);
135 | return [NSData dataWithBytesNoCopy:cryptedBytes length:size freeWhenDone:YES];
136 | }
137 |
138 | #pragma mark - AES256 encryption support
139 |
140 | /**
141 | * Return an original data by AES256 decrypting the encrypted data with a privided raw key.
142 | * @param encryptedData The encrypted data to be decrypted using AES256 algorithm with given raw binary key to obtain the original data.
143 | * @param rawKey A raw key to be used for AES256 encryption.
144 | * @return Original data.
145 | */
146 | + (NSData *)dataWithAes256CryptedData:(NSData *)encryptedData rawKey:(NSData *)rawKey {
147 | size_t size;
148 | char *cryptedBytes = CryptedDataUtil::aes256DataFromCryptedData((char*)[encryptedData bytes], encryptedData.length, (char*)[rawKey bytes], rawKey.length, &size);
149 | return [NSData dataWithBytesNoCopy:cryptedBytes length:size freeWhenDone:YES];
150 | }
151 |
152 | /**
153 | * Return an original data by AES256 decrypting the encrypted data with a privided hex key.
154 | * @param encryptedData The encrypted data to be decrypted using AES256 algorithm with given hex key to obtain the original data.
155 | * @param rawKey A hex key to be used for AES256 encryption.
156 | * @return Original data.
157 | */
158 | + (NSData *)dataWithAes256CryptedData:(NSData *)encryptedData hexKey:(NSString *)hexKey {
159 | size_t size;
160 | char *rawKey = CryptedDataUtil::hex2bytes((char*)[hexKey cStringUsingEncoding:NSASCIIStringEncoding], [hexKey length]);
161 | char *cryptedBytes = CryptedDataUtil::aes256DataFromCryptedData((char*)[encryptedData bytes], encryptedData.length, rawKey, [hexKey length] / 2, &size);
162 | return [NSData dataWithBytesNoCopy:cryptedBytes length:size freeWhenDone:YES];
163 | }
164 |
165 | /**
166 | * Return an original data by AES256 decrypting the encrypted data with the default key.
167 | * @param encryptedData The encrypted data to be decrypted using AES256 algorithm with the default key to obtain the original data.
168 | * @return Original data.
169 | */
170 | + (NSData *)dataWithAes256CryptedData:(NSData *)encryptedData {
171 | size_t size;
172 | char *rawKey = CryptedDataUtil::hex2bytes((char*)[DEFAULT_KEY cStringUsingEncoding:NSASCIIStringEncoding], [DEFAULT_KEY length]);
173 | char *cryptedBytes = CryptedDataUtil::aes256DataFromCryptedData((char*)[encryptedData bytes], encryptedData.length, rawKey, [DEFAULT_KEY length] / 2, &size);
174 | return [NSData dataWithBytesNoCopy:cryptedBytes length:size freeWhenDone:YES];
175 | }
176 |
177 | /**
178 | * Return an encrypted data by AES256 crypting the original data with a privided raw key.
179 | * @param originalData The original data to be encrypted using AES256 algorithm with given raw binary key.
180 | * @param rawKey A raw key to be used for AES256 encryption.
181 | * @return AES256 encrypted data using a given raw key.
182 | */
183 | + (NSData *)aes256cryptedDataWithData:(NSData *)originalData rawKey:(NSData *)rawKey {
184 | size_t size;
185 | char *cryptedBytes = CryptedDataUtil::aes256CryptedDataFromData((char*)[originalData bytes], originalData.length, (char*)[rawKey bytes], rawKey.length, &size);
186 | return [NSData dataWithBytesNoCopy:cryptedBytes length:size freeWhenDone:YES];
187 | }
188 |
189 | /**
190 | * Return an encrypted data by AES256 crypting the original data with a privided hex key.
191 | * @param originalData The original data to be encrypted using AES256 algorithm with given hex key.
192 | * @param hexKey A hex key to be used for AES256 encryption.
193 | * @return AES256 encrypted data using a given hex key.
194 | */
195 | + (NSData *)aes256cryptedDataWithData:(NSData *)originalData hexKey:(NSString *)hexKey {
196 | size_t size;
197 | char *rawKey = CryptedDataUtil::hex2bytes((char*)[hexKey cStringUsingEncoding:NSASCIIStringEncoding], [hexKey length]);
198 | char *cryptedBytes = CryptedDataUtil::aes256CryptedDataFromData((char*)[originalData bytes], originalData.length, rawKey, [hexKey length] / 2, &size);
199 | return [NSData dataWithBytesNoCopy:cryptedBytes length:size freeWhenDone:YES];
200 | }
201 |
202 | /**
203 | * Return an encrypted data by AES256 crypting the original data with the default key.
204 | * @param originalData The original data to be encrypted using AES256 algorithm with the default key.
205 | * @return AES256 encrypted data using the default key.
206 | */
207 | + (NSData *)aes256cryptedDataWithData:(NSData *)originalData {
208 | size_t size;
209 | char *rawKey = CryptedDataUtil::hex2bytes((char*)[DEFAULT_KEY cStringUsingEncoding:NSASCIIStringEncoding], [DEFAULT_KEY length]);
210 | char *cryptedBytes = CryptedDataUtil::aes256CryptedDataFromData((char*)[originalData bytes], originalData.length, rawKey, [DEFAULT_KEY length] / 2, &size);
211 | return [NSData dataWithBytesNoCopy:cryptedBytes length:size freeWhenDone:YES];
212 | }
213 |
214 | /**
215 | * Returns data obtained after decrypting crypted data stored in a specified file using
216 | * AES256 algorithm with the client provided raw key.
217 | * @param fullPath A full path to the binary file with the AES256 crypted data.
218 | * @param rawKey A key used to decrypt the crypted data, raw bytes.
219 | * @return An instance of NSData obrained by decrypting the crypted data using AES256. The decrypted data
220 | * does not have to be valid when using the incorrect key.
221 | */
222 | + (NSData*) dataWithContentsOfAes256CryptedFile:(NSString *)fullPath rawKey:(NSData*)rawKey {
223 | size_t size;
224 | if (![[NSFileManager defaultManager] fileExistsAtPath:fullPath]) {
225 | return nil;
226 | }
227 | char *originalBytes = CryptedDataUtil::aes256DataFromCryptedFile([fullPath UTF8String], (char*)[rawKey bytes], [rawKey length], &size);
228 | return [NSData dataWithBytesNoCopy:originalBytes length:size freeWhenDone:YES];
229 | }
230 |
231 | /**
232 | * Returns data obtained after decrypting crypted data stored in a specified file using
233 | * AES256 algorithm with the client provided hex key.
234 | * @param fullPath A full path to the binary file with the AES256 crypted data.
235 | * @param hex A key used to decrypt the crypted data, raw bytes.
236 | * @return An instance of NSData obrained by decrypting the crypted data using AES256. The decrypted data
237 | * does not have to be valid when using the incorrect key.
238 | */
239 | + (NSData*) dataWithContentsOfAes256CryptedFile:(NSString *)fullPath hexKey:(NSString*)hexKey {
240 | size_t size;
241 | if (![[NSFileManager defaultManager] fileExistsAtPath:fullPath]) {
242 | return nil;
243 | }
244 | char *rawKey = CryptedDataUtil::hex2bytes((char*)[hexKey cStringUsingEncoding:NSASCIIStringEncoding], [hexKey length]);
245 | char *originalBytes = CryptedDataUtil::aes256DataFromCryptedFile([fullPath UTF8String], (char*)rawKey, [hexKey length] / 2, &size);
246 | return [NSData dataWithBytesNoCopy:originalBytes length:size freeWhenDone:YES];
247 | }
248 |
249 | /**
250 | * Returns data obtained after decrypting crypted data stored in a specified file using
251 | * AES256 algorithm with the default key.
252 | * @param fullPath A full path to the binary file with the AES256 crypted data.
253 | * @return An instance of NSData obrained by decrypting the crypted data using AES256. The decrypted data
254 | * does not have to be valid when using the incorrect key.
255 | */
256 | + (NSData*) dataWithContentsOfAes256CryptedFile:(NSString *)fullPath {
257 | return [NSData dataWithContentsOfAes256CryptedFile:fullPath hexKey:DEFAULT_KEY];
258 | }
259 |
260 | @end
261 |
--------------------------------------------------------------------------------
/crypted-resource-ios/CryptedResources/CryptedResourceLib/NSString+CryptedString.h:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2013, Inmite s.r.o. (www.inmite.eu).
3 | *
4 | * All rights reserved. This source code can be used only for purposes specified
5 | * by the given license contract signed by the rightful deputy of Inmite s.r.o.
6 | * This source code can be used only by the owner of the license.
7 | *
8 | * Any disputes arising in respect of this agreement (license) shall be brought
9 | * before the Municipal Court of Prague.
10 | *
11 | */
12 |
13 | #import
14 |
15 | @interface NSString (CryptedString)
16 |
17 | + (NSString*) stringWithCryptedData:(NSData*)encryptedData encoding:(NSStringEncoding)encoding rawKey:(NSData*)rawKey;
18 | + (NSString*) stringWithContentsOfCryptedFile:(NSString *)fullPath encoding:(NSStringEncoding)encoding rawKey:(NSData*)rawKey;
19 |
20 | + (NSString*) stringWithCryptedData:(NSData*)encryptedData encoding:(NSStringEncoding)encoding hexKey:(NSString*)hexKey;
21 | + (NSString*) stringWithContentsOfCryptedFile:(NSString *)fullPath encoding:(NSStringEncoding)encoding hexKey:(NSString*)hexKey;
22 |
23 | + (NSString*) stringWithCryptedData:(NSData*)encryptedData encoding:(NSStringEncoding)encoding;
24 | + (NSString*) stringWithContentsOfCryptedFile:(NSString *)fullPath encoding:(NSStringEncoding)encoding;
25 |
26 | @end
27 |
--------------------------------------------------------------------------------
/crypted-resource-ios/CryptedResources/CryptedResourceLib/NSString+CryptedString.mm:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2013, Inmite s.r.o. (www.inmite.eu).
3 | *
4 | * All rights reserved. This source code can be used only for purposes specified
5 | * by the given license contract signed by the rightful deputy of Inmite s.r.o.
6 | * This source code can be used only by the owner of the license.
7 | *
8 | * Any disputes arising in respect of this agreement (license) shall be brought
9 | * before the Municipal Court of Prague.
10 | *
11 | */
12 |
13 | #import "NSString+CryptedString.h"
14 | #import "CryptedConstants.h"
15 | #import "NSData+CryptedData.h"
16 |
17 | @implementation NSString (CryptedString)
18 |
19 | /**
20 | * Returns a string constructed from decrypted data using a specified NSString encoding.
21 | * This method uses client provided raw key to decrypt the data.
22 | * @param encryptedData A crypted data with the contents of the original string.
23 | * @param encoding An NSString encoding to be used when converting raw bytes to string instance.
24 | * @param rawKey A key used to decrypt the crypted data, raw bytes.
25 | * @return An instance of NSString with decrypted data from the original bytes in NSData instance, or null
26 | * if the decryption was not successful.
27 | */
28 | + (NSString*) stringWithCryptedData:(NSData*)encryptedData encoding:(NSStringEncoding)encoding rawKey:(NSData*)rawKey {
29 | NSData *data = [NSData dataWithCryptedData:encryptedData rawKey:rawKey];
30 | return [[NSString alloc] initWithData:data encoding:encoding];
31 | }
32 |
33 | /**
34 | * Returns an original string read from the crypted file using a specified NSString encoding.
35 | * This method uses client provided raw key to decrypt the data.
36 | * @param fullPath A full path to the crypted text file with the contents of the string.
37 | * @param encoding An NSString encoding to be used when converting raw bytes to string instance.
38 | * @param rawKey A key used to decrypt the crypted file, raw bytes.
39 | * @return An instance of NSString with decrypted data from the file, or null
40 | * if the decryption was not successful or file does not exist.
41 | */
42 | + (NSString*) stringWithContentsOfCryptedFile:(NSString *)fullPath encoding:(NSStringEncoding)encoding rawKey:(NSData*)rawKey {
43 | NSData *data = [NSData dataWithContentsOfCryptedFile:fullPath rawKey:rawKey];
44 | return [[NSString alloc] initWithData:data encoding:encoding];
45 | }
46 |
47 | /**
48 | * Returns a string constructed from decrypted data using a specified NSString encoding.
49 | * This method uses client provided key to decrypt the data.
50 | * @param encryptedData A crypted data with the contents of the original string.
51 | * @param encoding An NSString encoding to be used when converting raw bytes to string instance.
52 | * @param hexKey A key used to decrypt the crypted data, a hexadecimal string.
53 | * @return An instance of NSString with decrypted data from the original bytes in NSData instance, or null
54 | * if the decryption was not successful.
55 | */
56 | + (NSString*) stringWithCryptedData:(NSData*)encryptedData encoding:(NSStringEncoding)encoding hexKey:(NSString *)hexKey {
57 | NSData *data = [NSData dataWithCryptedData:encryptedData hexKey:hexKey];
58 | return [[NSString alloc] initWithData:data encoding:encoding];
59 | }
60 |
61 | /**
62 | * Returns an original string read from the crypted file using a specified NSString encoding.
63 | * This method uses client provided key to decrypt the data.
64 | * @param fullPath A full path to the crypted text file with the contents of the string.
65 | * @param encoding An NSString encoding to be used when converting raw bytes to string instance.
66 | * @param hexKey A key used to decrypt the crypted file, a hexadecimal string.
67 | * @return An instance of NSString with decrypted data from the file, or null
68 | * if the decryption was not successful or file does not exist.
69 | */
70 | + (NSString*) stringWithContentsOfCryptedFile:(NSString *)fullPath encoding:(NSStringEncoding)encoding hexKey:(NSString *)hexKey {
71 | NSData *data = [NSData dataWithContentsOfCryptedFile:fullPath hexKey:hexKey];
72 | return [[NSString alloc] initWithData:data encoding:encoding];
73 | }
74 |
75 | /**
76 | * Returns a string constructed from decrypted data using a specified NSString encoding.
77 | * This method uses shared default key to decrypt the data.
78 | * @param encryptedData A crypted data with the contents of the original string.
79 | * @param encoding An NSString encoding to be used when converting raw bytes to string instance.
80 | * @return An instance of NSString with decrypted data from the original bytes in NSData instance, or null
81 | * if the decryption was not successful.
82 | */
83 | + (NSString*) stringWithCryptedData:(NSData*)encryptedData encoding:(NSStringEncoding)encoding {
84 | return [NSString stringWithCryptedData:encryptedData encoding:encoding hexKey:DEFAULT_KEY];
85 | }
86 |
87 | /**
88 | * Returns an original string read from the crypted file using a specified NSString encoding.
89 | * This method uses shared default key to decrypt the data.
90 | * @param fullPath A full path to the crypted text file with the contents of the string.
91 | * @param encoding An NSString encoding to be used when converting raw bytes to string instance.
92 | * @return An instance of NSString with decrypted data from the file, or null
93 | * if the decryption was not successful or file does not exist.
94 | */
95 | + (NSString*) stringWithContentsOfCryptedFile:(NSString *)fullPath encoding:(NSStringEncoding)encoding {
96 | return [NSString stringWithContentsOfCryptedFile:fullPath encoding:encoding hexKey:DEFAULT_KEY];
97 | }
98 |
99 | @end
100 |
--------------------------------------------------------------------------------
/crypted-resource-ios/CryptedResources/CryptedResourceLib/UIImage+CryptedImage.h:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2013, Inmite s.r.o. (www.inmite.eu).
3 | *
4 | * All rights reserved. This source code can be used only for purposes specified
5 | * by the given license contract signed by the rightful deputy of Inmite s.r.o.
6 | * This source code can be used only by the owner of the license.
7 | *
8 | * Any disputes arising in respect of this agreement (license) shall be brought
9 | * before the Municipal Court of Prague.
10 | *
11 | */
12 |
13 | #import
14 |
15 | @interface UIImage (CryptedImage)
16 |
17 | + (UIImage*) imageWithCryptedData:(NSData*)encryptedData rawKey:(NSData*)rawKey;
18 | + (UIImage*) cryptedImageWithData:(NSData*)encryptedData rawKey:(NSData*)rawKey;
19 | + (UIImage*) cryptedImageNamed:(NSString *)name rawKey:(NSData*)rawKey;
20 | + (UIImage*) cryptedImageWithContentsOfFile:(NSString *)fullPath rawKey:(NSData*)rawKey;
21 |
22 | + (UIImage*) imageWithCryptedData:(NSData*)encryptedData hexKey:(NSString*)hexKey;
23 | + (UIImage*) cryptedImageWithData:(NSData*)encryptedData hexKey:(NSString*)hexKey;
24 | + (UIImage*) cryptedImageNamed:(NSString *)name hexKey:(NSString*)hexKey;
25 | + (UIImage*) cryptedImageWithContentsOfFile:(NSString *)fullPath hexKey:(NSString*)hexKey;
26 |
27 | + (UIImage*) imageWithCryptedData:(NSData*)encryptedData;
28 | + (UIImage*) cryptedImageWithData:(NSData*)encryptedData;
29 | + (UIImage*) cryptedImageNamed:(NSString *)name;
30 | + (UIImage*) cryptedImageWithContentsOfFile:(NSString *)fullPath;
31 |
32 | @end
33 |
--------------------------------------------------------------------------------
/crypted-resource-ios/CryptedResources/CryptedResourceLib/UIImage+CryptedImage.mm:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2013, Inmite s.r.o. (www.inmite.eu).
3 | *
4 | * All rights reserved. This source code can be used only for purposes specified
5 | * by the given license contract signed by the rightful deputy of Inmite s.r.o.
6 | * This source code can be used only by the owner of the license.
7 | *
8 | * Any disputes arising in respect of this agreement (license) shall be brought
9 | * before the Municipal Court of Prague.
10 | *
11 | */
12 |
13 | #import "UIImage+CryptedImage.h"
14 | #import "CryptedDataUtil.h"
15 | #import "CryptedConstants.h"
16 |
17 | @implementation UIImage (CryptedImage)
18 |
19 | /**
20 | * Alias for cryptedImageWithData:rawKey:
21 | */
22 | + (UIImage*) imageWithCryptedData:(NSData*)encryptedData rawKey:(NSData*)rawKey {
23 | return [self cryptedImageWithData:encryptedData rawKey:rawKey];
24 | }
25 |
26 | /**
27 | * Returns a UIImage from the crypted chunk of data. This method uses client provided raw key
28 | * to decrypt the data.
29 | * @param encryptedData A chunk of crypted data that includes a crypted image.
30 | * @param rawKey A key used to decrypt the crypted data, raw bytes.
31 | * @return An instance of UIImage in case the data contain umage after being decrypted, null otherwise.
32 | */
33 | + (UIImage*) cryptedImageWithData:(NSData*)encryptedData rawKey:(NSData*)rawKey {
34 | UIImage *image = nil;
35 | size_t size;
36 | char *originalBytes = CryptedDataUtil::dataFromCryptedData((char*)[encryptedData bytes], [encryptedData length], (char*)[rawKey bytes], [rawKey length], &size);
37 | NSData *data = [NSData dataWithBytesNoCopy:originalBytes length:size freeWhenDone:YES];
38 | image = [UIImage imageWithData:data];
39 | return image;
40 | }
41 |
42 | /**
43 | * Returns a UIImage from the crypted image in the application bundle. This method uses client provided raw key
44 | * to decrypt the data.
45 | * @param name A crypted image name in the bundle, including the file extension.
46 | * @param rawKey A key used to decrypt the crypted resource, raw bytes.
47 | * @return An instance of UIImage in case the resource exists in the bundle and was successfully decrypted, null otherwise.
48 | */
49 | + (UIImage*) cryptedImageNamed:(NSString *)name rawKey:(NSData*)rawKey {
50 | NSString *path = [[NSBundle mainBundle] pathForResource:name ofType:@""];
51 | if (path == nil) {
52 | return nil;
53 | }
54 | return [UIImage cryptedImageWithContentsOfFile:path rawKey:rawKey];
55 | }
56 |
57 | /**
58 | * Returns a UIImage from the crypted image file specified by the full path. This method uses client provided raw key
59 | * to decrypt the data.
60 | * @param fullPath A full path to the crypted image file.
61 | * @param rawKey A key used to decrypt the crypted file, raw bytes.
62 | * @return An instance of UIImage in case the file exists and was successfully decrypted, null otherwise.
63 | */
64 | + (UIImage*) cryptedImageWithContentsOfFile:(NSString *)fullPath rawKey:(NSData*)rawKey {
65 | UIImage *image = nil;
66 | size_t size;
67 | if (![[NSFileManager defaultManager] fileExistsAtPath:fullPath]) {
68 | return nil;
69 | }
70 | char *originalBytes = CryptedDataUtil::dataFromCryptedFile([fullPath UTF8String], (char*)[rawKey bytes], [rawKey length], &size);
71 | NSData *data = [NSData dataWithBytesNoCopy:originalBytes length:size freeWhenDone:YES];
72 | image = [UIImage imageWithData:data];
73 | return image;
74 | }
75 |
76 | /**
77 | * Returns a UIImage from the crypted image file specified by the full path. This method uses client provided key
78 | * to decrypt the data.
79 | * @param fullPath A full path to the crypted image file.
80 | * @param hexKey A key used to decrypt the crypted file, a hexadecimal string.
81 | * @return An instance of UIImage in case the file exists and was successfully decrypted, null otherwise.
82 | */
83 | + (UIImage*) cryptedImageWithContentsOfFile:(NSString *)fullPath hexKey:(NSString *)hexKey {
84 | char *rawKey = CryptedDataUtil::hex2bytes((char*)[hexKey cStringUsingEncoding:NSASCIIStringEncoding], [hexKey length]);
85 | return [UIImage cryptedImageWithContentsOfFile:fullPath rawKey:[NSData dataWithBytesNoCopy:rawKey length:[hexKey length] / 2 freeWhenDone:YES]];
86 | }
87 |
88 | /**
89 | * Returns a UIImage from the crypted image in the application bundle. This method uses client provided key
90 | * to decrypt the data.
91 | * @param name A crypted image name in the bundle, including the file extension.
92 | * @param hexKey A key used to decrypt the crypted resource, a hexadecimal string.
93 | * @return An instance of UIImage in case the resource exists in the bundle and was successfully decrypted, null otherwise.
94 | */
95 | + (UIImage*) cryptedImageNamed:(NSString *)name hexKey:(NSString *)hexKey {
96 | NSString *path = [[NSBundle mainBundle] pathForResource:name ofType:@""];
97 | if (path == nil) {
98 | return nil;
99 | }
100 | return [UIImage cryptedImageWithContentsOfFile:path hexKey:hexKey];
101 | }
102 |
103 | /**
104 | * Alias for cryptedImageWithData:hexKey:
105 | */
106 | + (UIImage *)imageWithCryptedData:(NSData *)encryptedData hexKey:(NSString *)hexKey {
107 | return [self cryptedImageWithData:encryptedData hexKey:hexKey];
108 | }
109 |
110 | /**
111 | * Returns a UIImage from the crypted chunk of data. This method uses client provided key
112 | * to decrypt the data.
113 | * @param encryptedData A chunk of crypted data that includes a crypted image.
114 | * @param hexKey A key used to decrypt the crypted data, a hexadecimal string.
115 | * @return An instance of UIImage in case the data contain umage after being decrypted, null otherwise.
116 | */
117 | + (UIImage*) cryptedImageWithData:(NSData*)encryptedData hexKey:(NSString *)hexKey {
118 | UIImage *image = nil;
119 | size_t size;
120 | char *originalBytes = CryptedDataUtil::dataFromCryptedData((char*)[encryptedData bytes], [encryptedData length], (char*)[hexKey cStringUsingEncoding:NSASCIIStringEncoding], [hexKey length], &size);
121 | NSData *data = [NSData dataWithBytesNoCopy:originalBytes length:size freeWhenDone:YES];
122 | image = [UIImage imageWithData:data];
123 | return image;
124 | }
125 |
126 | /**
127 | * Alias for cryptedImageWithData:
128 | */
129 | + (UIImage *)imageWithCryptedData:(NSData *)encryptedData {
130 | return [self cryptedImageWithData:encryptedData];
131 | }
132 |
133 | /**
134 | * Returns a UIImage from the crypted chunk of data. This method uses default shared key
135 | * to decrypt the data.
136 | * @param encryptedData A chunk of crypted data that includes a crypted image.
137 | * @return An instance of UIImage in case the data contain umage after being decrypted, null otherwise.
138 | */
139 | + (UIImage*) cryptedImageWithData:(NSData*)encryptedData {
140 | return [UIImage cryptedImageWithData:encryptedData hexKey:DEFAULT_KEY];
141 | }
142 |
143 | /**
144 | * Returns a UIImage from the crypted image in the application bundle. This method uses default shared key
145 | * to decrypt the data.
146 | * @param name A crypted image name in the bundle, including the file extension.
147 | * @return An instance of UIImage in case the resource exists in the bundle and was successfully decrypted, null otherwise.
148 | */
149 | + (UIImage*) cryptedImageNamed:(NSString *)name {
150 | return [UIImage cryptedImageNamed:name hexKey:DEFAULT_KEY];
151 | }
152 |
153 | /**
154 | * Returns a UIImage from the crypted image file specified by the full path. This method uses default shared key
155 | * to decrypt the data.
156 | * @param fullPath A full path to the crypted image file.
157 | * @return An instance of UIImage in case the file exists and was successfully decrypted, null otherwise.
158 | */
159 | + (UIImage*) cryptedImageWithContentsOfFile:(NSString *)fullPath {
160 | return [UIImage cryptedImageWithContentsOfFile:fullPath hexKey:DEFAULT_KEY];
161 | }
162 |
163 |
164 | @end
165 |
--------------------------------------------------------------------------------
/crypted-resource-ios/CryptedResources/CryptedResources-Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | UIStatusBarStyle
6 | UIStatusBarStyleBlackOpaque
7 | UIPrerenderedIcon
8 |
9 | CFBundleDevelopmentRegion
10 | en
11 | CFBundleDisplayName
12 | CryptedDemo
13 | CFBundleExecutable
14 | ${EXECUTABLE_NAME}
15 | CFBundleIdentifier
16 | eu.inmite.app.${PRODUCT_NAME:rfc1034identifier}
17 | CFBundleInfoDictionaryVersion
18 | 6.0
19 | CFBundleName
20 | ${PRODUCT_NAME}
21 | CFBundlePackageType
22 | APPL
23 | CFBundleShortVersionString
24 | 1.0
25 | CFBundleSignature
26 | ????
27 | CFBundleVersion
28 | 1.0
29 | LSRequiresIPhoneOS
30 |
31 | UIMainStoryboardFile
32 | MainStoryboard
33 | UIRequiredDeviceCapabilities
34 |
35 | armv7
36 |
37 | UISupportedInterfaceOrientations
38 |
39 | UIInterfaceOrientationPortrait
40 |
41 |
42 |
43 |
--------------------------------------------------------------------------------
/crypted-resource-ios/CryptedResources/CryptedResources-Prefix.pch:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2013, Inmite s.r.o. (www.inmite.eu).
3 | *
4 | * All rights reserved. This source code can be used only for purposes specified
5 | * by the given license contract signed by the rightful deputy of Inmite s.r.o.
6 | * This source code can be used only by the owner of the license.
7 | *
8 | * Any disputes arising in respect of this agreement (license) shall be brought
9 | * before the Municipal Court of Prague.
10 | *
11 | */
12 |
13 | #import
14 |
15 | #ifndef __IPHONE_5_0
16 | #warning "This project uses features only available in iOS SDK 5.0 and later."
17 | #endif
18 |
19 | #ifdef __OBJC__
20 | #import
21 | #import
22 | #endif
23 |
--------------------------------------------------------------------------------
/crypted-resource-ios/CryptedResources/IMTAppDelegate.h:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2013, Inmite s.r.o. (www.inmite.eu).
3 | *
4 | * All rights reserved. This source code can be used only for purposes specified
5 | * by the given license contract signed by the rightful deputy of Inmite s.r.o.
6 | * This source code can be used only by the owner of the license.
7 | *
8 | * Any disputes arising in respect of this agreement (license) shall be brought
9 | * before the Municipal Court of Prague.
10 | *
11 | */
12 |
13 | #import
14 |
15 | @interface IMTAppDelegate : UIResponder
16 |
17 | @property (strong, nonatomic) UIWindow *window;
18 |
19 | @end
20 |
--------------------------------------------------------------------------------
/crypted-resource-ios/CryptedResources/IMTAppDelegate.m:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2013, Inmite s.r.o. (www.inmite.eu).
3 | *
4 | * All rights reserved. This source code can be used only for purposes specified
5 | * by the given license contract signed by the rightful deputy of Inmite s.r.o.
6 | * This source code can be used only by the owner of the license.
7 | *
8 | * Any disputes arising in respect of this agreement (license) shall be brought
9 | * before the Municipal Court of Prague.
10 | *
11 | */
12 |
13 | #import "IMTAppDelegate.h"
14 |
15 | @implementation IMTAppDelegate
16 |
17 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
18 | {
19 | // Override point for customization after application launch.
20 | return YES;
21 | }
22 |
23 | - (void)applicationWillResignActive:(UIApplication *)application
24 | {
25 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
26 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
27 | }
28 |
29 | - (void)applicationDidEnterBackground:(UIApplication *)application
30 | {
31 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
32 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
33 | }
34 |
35 | - (void)applicationWillEnterForeground:(UIApplication *)application
36 | {
37 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
38 | }
39 |
40 | - (void)applicationDidBecomeActive:(UIApplication *)application
41 | {
42 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
43 | }
44 |
45 | - (void)applicationWillTerminate:(UIApplication *)application
46 | {
47 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
48 | }
49 |
50 | @end
51 |
--------------------------------------------------------------------------------
/crypted-resource-ios/CryptedResources/IMTViewController.h:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2013, Inmite s.r.o. (www.inmite.eu).
3 | *
4 | * All rights reserved. This source code can be used only for purposes specified
5 | * by the given license contract signed by the rightful deputy of Inmite s.r.o.
6 | * This source code can be used only by the owner of the license.
7 | *
8 | * Any disputes arising in respect of this agreement (license) shall be brought
9 | * before the Municipal Court of Prague.
10 | *
11 | */
12 |
13 |
14 | #import
15 |
16 | @interface IMTViewController : UIViewController
17 |
18 | @end
19 |
--------------------------------------------------------------------------------
/crypted-resource-ios/CryptedResources/IMTViewController.m:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2013, Inmite s.r.o. (www.inmite.eu).
3 | *
4 | * All rights reserved. This source code can be used only for purposes specified
5 | * by the given license contract signed by the rightful deputy of Inmite s.r.o.
6 | * This source code can be used only by the owner of the license.
7 | *
8 | * Any disputes arising in respect of this agreement (license) shall be brought
9 | * before the Municipal Court of Prague.
10 | *
11 | */
12 |
13 |
14 | #import "IMTViewController.h"
15 | #import "CryptedResources.h"
16 |
17 | @interface IMTViewController ()
18 | @property (nonatomic,assign) IBOutlet UIImageView *imageView;
19 | @property (nonatomic,assign) IBOutlet UILabel *label;
20 | @end
21 |
22 | @implementation IMTViewController
23 |
24 | - (void)viewDidLoad
25 | {
26 | [super viewDidLoad];
27 | self.imageView.image = [UIImage cryptedImageNamed:@"inmite.cri"];
28 | self.label.text = [NSString stringWithContentsOfCryptedFile:[[NSBundle mainBundle] pathForResource:@"text" ofType:@"crs"]
29 | encoding:NSUTF8StringEncoding];
30 |
31 | // AES256 Example Code
32 | // NSData *originalData = UIImagePNGRepresentation(self.imageView.image);
33 | // NSData *encryptedData = [NSData aes256cryptedDataWithData:originalData hexKey:DEFAULT_KEY];
34 | // originalData = [NSData dataWithAes256CryptedData:encryptedData hexKey:DEFAULT_KEY];
35 | // self.imageView.image = [UIImage imageWithData:originalData];
36 | }
37 |
38 | - (void)didReceiveMemoryWarning
39 | {
40 | [super didReceiveMemoryWarning];
41 | self.imageView.image = nil;
42 | }
43 |
44 | - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {
45 | return UIInterfaceOrientationIsPortrait(toInterfaceOrientation);
46 | }
47 |
48 | @end
49 |
--------------------------------------------------------------------------------
/crypted-resource-ios/CryptedResources/Resources/Default-568h@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/inmite/imt-crypted-resources/5f57097481d38ad5f7c3c80fda42d4b4254cdaff/crypted-resource-ios/CryptedResources/Resources/Default-568h@2x.png
--------------------------------------------------------------------------------
/crypted-resource-ios/CryptedResources/Resources/Default.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/inmite/imt-crypted-resources/5f57097481d38ad5f7c3c80fda42d4b4254cdaff/crypted-resource-ios/CryptedResources/Resources/Default.png
--------------------------------------------------------------------------------
/crypted-resource-ios/CryptedResources/Resources/Default@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/inmite/imt-crypted-resources/5f57097481d38ad5f7c3c80fda42d4b4254cdaff/crypted-resource-ios/CryptedResources/Resources/Default@2x.png
--------------------------------------------------------------------------------
/crypted-resource-ios/CryptedResources/Resources/Icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/inmite/imt-crypted-resources/5f57097481d38ad5f7c3c80fda42d4b4254cdaff/crypted-resource-ios/CryptedResources/Resources/Icon.png
--------------------------------------------------------------------------------
/crypted-resource-ios/CryptedResources/Resources/Icon@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/inmite/imt-crypted-resources/5f57097481d38ad5f7c3c80fda42d4b4254cdaff/crypted-resource-ios/CryptedResources/Resources/Icon@2x.png
--------------------------------------------------------------------------------
/crypted-resource-ios/CryptedResources/Resources/inmite.cri:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/inmite/imt-crypted-resources/5f57097481d38ad5f7c3c80fda42d4b4254cdaff/crypted-resource-ios/CryptedResources/Resources/inmite.cri
--------------------------------------------------------------------------------
/crypted-resource-ios/CryptedResources/Resources/text.crs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/inmite/imt-crypted-resources/5f57097481d38ad5f7c3c80fda42d4b4254cdaff/crypted-resource-ios/CryptedResources/Resources/text.crs
--------------------------------------------------------------------------------
/crypted-resource-ios/CryptedResources/en.lproj/InfoPlist.strings:
--------------------------------------------------------------------------------
1 | /* Localized versions of Info.plist keys */
2 |
3 |
--------------------------------------------------------------------------------
/crypted-resource-ios/CryptedResources/en.lproj/MainStoryboard.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
--------------------------------------------------------------------------------
/crypted-resource-ios/CryptedResources/main.m:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2013, Inmite s.r.o. (www.inmite.eu).
3 | *
4 | * All rights reserved. This source code can be used only for purposes specified
5 | * by the given license contract signed by the rightful deputy of Inmite s.r.o.
6 | * This source code can be used only by the owner of the license.
7 | *
8 | * Any disputes arising in respect of this agreement (license) shall be brought
9 | * before the Municipal Court of Prague.
10 | *
11 | */
12 |
13 | #import
14 |
15 | #import "IMTAppDelegate.h"
16 |
17 | int main(int argc, char *argv[])
18 | {
19 | @autoreleasepool {
20 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([IMTAppDelegate class]));
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/crypted-resource-java-tool/build.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 | Builds, tests, and runs the project crypted-resource-java-tool.
12 |
13 |
74 |
75 |
--------------------------------------------------------------------------------
/crypted-resource-java-tool/lib/nblibraries.properties:
--------------------------------------------------------------------------------
1 | libs.CopyLibs.classpath=\
2 | ${base}/CopyLibs/org-netbeans-modules-java-j2seproject-copylibstask.jar
3 | libs.CopyLibs.displayName=CopyLibs Task
4 | libs.CopyLibs.prop-version=1.0
5 |
--------------------------------------------------------------------------------
/crypted-resource-java-tool/manifest.mf:
--------------------------------------------------------------------------------
1 | Manifest-Version: 1.0
2 | X-COMMENT: Main-Class will be added automatically by build
3 |
4 |
--------------------------------------------------------------------------------
/crypted-resource-java-tool/nbproject/build-impl.xml:
--------------------------------------------------------------------------------
1 |
2 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 |
156 |
157 |
158 |
159 |
160 |
161 |
162 |
163 |
164 |
165 |
166 |
167 |
168 |
169 |
170 |
171 |
172 |
173 |
174 |
175 |
176 |
177 |
178 |
179 |
180 |
181 |
182 |
183 |
184 |
185 |
186 |
187 |
188 |
189 |
190 |
191 |
192 |
193 |
194 |
195 |
196 |
197 |
198 |
199 |
200 |
201 |
202 |
203 |
204 |
205 |
206 |
207 |
208 |
209 |
210 |
211 |
212 |
213 |
214 |
215 |
216 |
217 |
218 |
219 |
220 |
221 |
222 |
223 |
224 |
225 |
226 |
227 |
228 |
229 |
230 |
231 |
232 |
233 |
234 |
235 |
236 |
237 |
238 |
239 |
240 |
241 |
242 |
243 |
244 |
245 |
246 |
247 |
248 |
249 |
250 |
251 |
252 |
253 |
254 |
255 |
256 | Must set src.dir
257 | Must set test.src.dir
258 | Must set build.dir
259 | Must set dist.dir
260 | Must set build.classes.dir
261 | Must set dist.javadoc.dir
262 | Must set build.test.classes.dir
263 | Must set build.test.results.dir
264 | Must set build.classes.excludes
265 | Must set dist.jar
266 |
267 |
268 |
269 |
270 |
271 |
272 |
273 |
274 |
275 |
276 |
277 |
278 |
279 |
280 |
281 |
282 |
283 |
284 |
285 |
286 |
287 |
288 |
289 |
290 |
291 |
292 |
293 |
294 |
295 |
296 |
297 |
298 |
299 |
300 |
301 |
302 |
303 |
304 |
305 |
306 |
307 |
308 |
309 |
310 |
311 |
312 |
313 |
314 |
315 |
316 |
317 |
318 |
319 |
320 |
321 |
322 |
323 |
324 |
325 |
326 |
327 |
328 |
329 |
330 |
331 |
332 |
333 |
334 |
335 |
336 |
337 |
338 |
339 |
340 |
341 |
342 |
343 |
344 |
345 |
346 |
347 |
348 |
349 |
350 |
351 |
352 |
353 |
354 |
355 |
356 |
357 |
358 |
359 |
360 |
361 |
362 |
363 |
364 | Must set javac.includes
365 |
366 |
367 |
368 |
369 |
370 |
371 |
372 |
373 |
374 |
375 |
376 |
377 |
378 |
379 |
380 |
381 |
382 |
383 |
384 |
385 |
386 |
387 |
388 |
389 |
390 |
391 |
392 |
393 |
394 |
395 |
396 |
397 |
398 |
399 |
400 |
401 |
402 |
403 |
404 |
405 |
406 |
407 |
408 |
409 |
410 |
411 |
412 |
413 |
414 |
415 |
416 |
417 |
418 |
419 |
420 |
421 |
422 |
423 |
424 |
425 |
426 |
427 |
428 |
429 |
430 |
431 |
432 |
433 |
434 |
435 |
436 |
437 |
438 |
439 |
440 |
441 |
442 |
443 |
444 |
445 |
446 |
447 |
448 |
449 |
450 |
451 |
452 |
453 |
454 |
455 |
456 |
457 |
458 |
459 |
460 |
461 |
462 |
463 |
464 |
465 |
466 |
467 |
468 |
469 |
470 |
471 |
472 |
473 |
474 |
475 |
476 |
477 |
478 |
479 |
480 |
481 |
482 |
483 |
484 |
485 |
486 |
487 |
488 |
489 |
490 |
491 |
492 |
493 | No tests executed.
494 |
495 |
496 |
497 |
498 |
499 |
500 |
501 |
502 |
503 |
504 |
505 |
506 |
507 |
508 |
509 |
510 |
511 |
512 |
513 |
514 |
515 |
516 |
517 |
518 |
519 |
520 |
521 |
522 |
523 |
524 |
525 |
526 |
527 |
528 |
529 |
530 |
531 |
532 |
533 |
534 |
535 |
536 |
537 |
538 |
539 |
540 |
541 |
542 |
543 |
544 |
545 |
546 |
547 |
548 |
549 |
550 |
551 |
552 |
553 |
554 |
555 |
556 |
557 |
558 |
559 |
560 |
561 |
562 |
563 |
564 |
565 |
566 |
567 |
568 |
569 |
570 |
571 |
572 |
573 |
574 |
575 |
576 |
577 |
578 |
579 |
580 |
581 |
582 |
583 |
584 |
585 |
586 |
587 |
588 |
589 |
590 |
591 |
592 |
593 |
594 |
595 |
596 |
597 |
598 |
599 |
600 |
601 |
602 |
603 |
604 |
605 |
606 |
607 |
608 |
609 |
610 |
611 |
612 |
613 |
614 |
615 |
616 |
617 |
618 |
619 |
620 |
621 |
622 |
623 |
624 |
625 |
626 |
627 |
628 |
629 |
630 |
631 |
632 |
633 |
634 |
635 |
636 |
637 |
638 |
639 |
640 |
641 |
642 |
643 |
644 |
645 |
646 |
647 |
648 |
649 |
650 |
651 |
652 |
653 |
654 |
655 |
656 |
657 |
658 |
659 |
660 |
661 |
662 |
663 |
664 |
665 |
666 |
667 |
668 |
669 |
670 |
671 |
672 |
673 |
674 |
675 |
676 |
677 |
678 |
679 |
680 |
681 |
682 |
683 |
684 |
685 |
686 |
687 |
688 |
689 |
690 |
691 |
692 |
693 |
694 |
695 |
696 |
697 |
698 |
701 |
702 |
703 |
704 |
705 |
706 |
707 |
708 |
709 |
710 |
711 |
712 |
713 |
714 |
715 |
716 |
717 |
718 |
719 |
720 |
721 |
722 |
723 |
724 |
725 |
726 |
727 |
728 |
729 |
730 |
731 |
732 |
733 |
734 |
735 |
736 |
737 |
738 |
739 |
740 |
741 |
742 |
743 | Must set JVM to use for profiling in profiler.info.jvm
744 | Must set profiler agent JVM arguments in profiler.info.jvmargs.agent
745 |
746 |
749 |
750 |
751 |
752 |
753 |
754 |
755 |
756 |
757 |
758 |
759 |
760 |
761 |
762 |
763 |
764 |
765 |
766 |
767 |
768 |
769 |
770 |
771 |
772 |
773 |
774 |
775 |
776 |
777 |
778 |
779 |
780 |
781 |
782 |
783 |
784 |
785 |
786 |
787 |
788 |
789 |
790 |
791 |
792 |
793 |
794 |
795 |
796 |
797 |
798 |
799 |
800 |
801 |
802 |
803 |
804 |
805 |
806 |
807 |
808 |
809 |
810 |
811 |
812 |
813 |
814 |
815 |
816 |
817 |
818 |
819 |
820 |
821 |
822 |
823 |
824 |
825 |
826 |
827 |
828 |
829 |
830 |
831 |
832 |
833 |
834 |
835 |
836 |
837 |
838 |
839 |
840 |
841 |
842 |
843 |
844 |
845 |
846 |
847 |
848 |
849 |
850 |
851 |
852 |
853 |
854 |
855 |
856 |
857 |
858 |
859 |
860 |
861 |
862 |
863 |
864 |
865 |
866 |
867 |
868 |
869 |
870 |
871 |
872 |
873 |
874 |
875 |
876 |
877 |
878 |
879 |
880 |
881 |
882 |
883 |
884 |
885 |
886 |
887 |
888 |
889 |
890 |
891 |
892 |
893 |
894 |
895 |
896 |
897 |
898 |
899 |
900 |
901 |
902 |
903 |
904 |
905 |
906 |
907 |
912 |
913 |
914 |
915 |
916 |
917 |
918 |
919 |
920 |
921 |
922 |
923 |
924 |
925 |
926 |
927 |
928 |
929 |
930 |
931 |
932 |
933 |
934 |
935 |
936 |
937 |
938 |
939 |
940 |
941 |
942 |
943 |
944 |
945 |
946 |
947 |
948 |
949 |
950 |
951 |
952 |
953 |
954 |
955 |
956 |
957 |
958 |
959 |
960 |
961 |
962 |
963 |
964 |
965 |
966 |
967 |
968 |
969 |
970 |
971 |
972 | Must select some files in the IDE or set javac.includes
973 |
974 |
975 |
976 |
977 |
978 |
979 |
980 |
981 |
986 |
987 |
988 |
989 |
990 |
991 |
992 |
993 |
994 |
995 |
996 |
997 |
998 |
999 |
1000 |
1001 |
1002 |
1003 |
1004 |
1005 |
1006 | To run this application from the command line without Ant, try:
1007 |
1008 |
1009 |
1010 |
1011 |
1012 |
1013 | java -cp "${run.classpath.with.dist.jar}" ${main.class}
1014 |
1015 |
1016 |
1017 |
1018 |
1019 |
1020 |
1021 |
1022 |
1023 |
1024 |
1025 |
1026 |
1027 |
1028 |
1029 |
1030 |
1031 |
1032 |
1033 |
1034 |
1035 |
1036 |
1037 |
1038 | To run this application from the command line without Ant, try:
1039 |
1040 | java -jar "${dist.jar.resolved}"
1041 |
1042 |
1043 |
1044 |
1045 |
1046 |
1047 |
1048 |
1049 |
1050 |
1051 |
1052 |
1053 |
1058 |
1059 |
1060 |
1061 |
1062 |
1063 |
1064 |
1065 |
1066 |
1067 |
1068 |
1069 | Must select one file in the IDE or set run.class
1070 |
1071 |
1072 |
1073 | Must select one file in the IDE or set run.class
1074 |
1075 |
1076 |
1081 |
1082 |
1083 |
1084 |
1085 |
1086 |
1087 |
1088 |
1089 |
1090 |
1091 |
1092 |
1093 |
1094 |
1095 |
1096 |
1097 |
1098 |
1099 |
1100 | Must select one file in the IDE or set debug.class
1101 |
1102 |
1103 |
1104 |
1105 | Must select one file in the IDE or set debug.class
1106 |
1107 |
1108 |
1109 |
1110 | Must set fix.includes
1111 |
1112 |
1113 |
1114 |
1115 |
1116 |
1117 |
1122 |
1125 |
1126 | This target only works when run from inside the NetBeans IDE.
1127 |
1128 |
1129 |
1130 |
1131 |
1132 |
1133 |
1134 |
1135 | Must select one file in the IDE or set profile.class
1136 | This target only works when run from inside the NetBeans IDE.
1137 |
1138 |
1139 |
1140 |
1141 |
1142 |
1143 |
1144 |
1145 | This target only works when run from inside the NetBeans IDE.
1146 |
1147 |
1148 |
1149 |
1150 |
1151 |
1152 |
1153 |
1154 |
1155 |
1156 |
1157 |
1158 | This target only works when run from inside the NetBeans IDE.
1159 |
1160 |
1161 |
1162 |
1163 |
1164 |
1165 |
1166 |
1167 |
1168 |
1169 |
1170 |
1171 |
1172 |
1173 |
1174 |
1175 |
1176 |
1177 |
1178 |
1179 |
1180 |
1183 |
1184 |
1185 |
1186 |
1187 |
1188 |
1189 |
1190 |
1191 |
1192 |
1193 |
1194 |
1195 |
1196 | Must select one file in the IDE or set run.class
1197 |
1198 |
1199 |
1200 |
1201 |
1202 | Must select some files in the IDE or set test.includes
1203 |
1204 |
1205 |
1206 |
1207 | Must select one file in the IDE or set run.class
1208 |
1209 |
1210 |
1211 |
1212 | Must select one file in the IDE or set applet.url
1213 |
1214 |
1215 |
1216 |
1221 |
1222 |
1223 |
1224 |
1225 |
1226 |
1227 |
1228 |
1229 |
1230 |
1231 |
1232 |
1233 |
1234 |
1235 |
1236 |
1237 |
1238 |
1239 |
1240 |
1241 |
1242 |
1243 |
1244 |
1245 |
1246 |
1247 |
1248 |
1249 |
1250 |
1251 |
1252 |
1253 |
1254 |
1255 |
1256 |
1257 |
1262 |
1263 |
1264 |
1265 |
1266 |
1267 |
1268 |
1269 |
1270 |
1271 |
1272 |
1273 |
1274 |
1275 |
1276 |
1277 |
1278 |
1279 |
1280 |
1281 |
1282 |
1283 |
1284 |
1285 |
1286 |
1287 |
1288 | Must select some files in the IDE or set javac.includes
1289 |
1290 |
1291 |
1292 |
1293 |
1294 |
1295 |
1296 |
1297 |
1298 |
1299 |
1300 |
1305 |
1306 |
1307 |
1308 |
1309 |
1310 |
1311 |
1312 | Some tests failed; see details above.
1313 |
1314 |
1315 |
1316 |
1317 |
1318 |
1319 |
1320 |
1321 | Must select some files in the IDE or set test.includes
1322 |
1323 |
1324 |
1325 | Some tests failed; see details above.
1326 |
1327 |
1328 |
1329 | Must select some files in the IDE or set test.class
1330 | Must select some method in the IDE or set test.method
1331 |
1332 |
1333 |
1334 | Some tests failed; see details above.
1335 |
1336 |
1337 |
1342 |
1343 | Must select one file in the IDE or set test.class
1344 |
1345 |
1346 |
1347 | Must select one file in the IDE or set test.class
1348 | Must select some method in the IDE or set test.method
1349 |
1350 |
1351 |
1352 |
1353 |
1354 |
1355 |
1356 |
1357 |
1358 |
1359 |
1360 |
1365 |
1366 | Must select one file in the IDE or set applet.url
1367 |
1368 |
1369 |
1370 |
1371 |
1372 |
1373 |
1378 |
1379 | Must select one file in the IDE or set applet.url
1380 |
1381 |
1382 |
1383 |
1384 |
1385 |
1386 |
1387 |
1392 |
1393 |
1394 |
1395 |
1396 |
1397 |
1398 |
1399 |
1400 |
1401 |
1402 |
1403 |
1404 |
1405 |
1406 |
1407 |
1408 |
1409 |
1410 |
1411 |
1412 |
1413 |
1414 |
1415 |
1416 |
1417 |
1418 |
1419 |
1420 |
1421 |
1422 |
1423 |
1424 |
1425 |
1426 |
1427 |
1428 |
1429 |
1430 |
1431 |
1432 |
1433 |
1434 |
1435 |
1436 |
1437 |
--------------------------------------------------------------------------------
/crypted-resource-java-tool/nbproject/genfiles.properties:
--------------------------------------------------------------------------------
1 | build.xml.data.CRC32=049cb079
2 | build.xml.script.CRC32=266201d0
3 | build.xml.stylesheet.CRC32=28e38971@1.56.1.46
4 | # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
5 | # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
6 | nbproject/build-impl.xml.data.CRC32=049cb079
7 | nbproject/build-impl.xml.script.CRC32=f732c951
8 | nbproject/build-impl.xml.stylesheet.CRC32=c6d2a60f@1.56.1.46
9 |
--------------------------------------------------------------------------------
/crypted-resource-java-tool/nbproject/project.properties:
--------------------------------------------------------------------------------
1 | annotation.processing.enabled=true
2 | annotation.processing.enabled.in.editor=false
3 | annotation.processing.processors.list=
4 | annotation.processing.run.all.processors=true
5 | annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
6 | application.homepage=http://www.inmite.eu
7 | application.title=crypted-resource-java-tool
8 | application.vendor=Inmite s.r.o.
9 | build.classes.dir=${build.dir}/classes
10 | build.classes.excludes=**/*.java,**/*.form
11 | # This directory is removed when the project is cleaned:
12 | build.dir=build
13 | build.generated.dir=${build.dir}/generated
14 | build.generated.sources.dir=${build.dir}/generated-sources
15 | # Only compile against the classpath explicitly listed here:
16 | build.sysclasspath=ignore
17 | build.test.classes.dir=${build.dir}/test/classes
18 | build.test.results.dir=${build.dir}/test/results
19 | # Uncomment to specify the preferred debugger connection transport:
20 | #debug.transport=dt_socket
21 | debug.classpath=\
22 | ${run.classpath}
23 | debug.test.classpath=\
24 | ${run.test.classpath}
25 | # This directory is removed when the project is cleaned:
26 | dist.dir=dist
27 | dist.jar=${dist.dir}/crypted-resource-java-tool.jar
28 | dist.javadoc.dir=${dist.dir}/javadoc
29 | endorsed.classpath=
30 | excludes=
31 | includes=**
32 | jar.archive.disabled=${jnlp.enabled}
33 | jar.compress=false
34 | jar.index=${jnlp.enabled}
35 | javac.classpath=
36 | # Space-separated list of extra javac options
37 | javac.compilerargs=
38 | javac.deprecation=false
39 | javac.processorpath=\
40 | ${javac.classpath}
41 | javac.source=1.6
42 | javac.target=1.6
43 | javac.test.classpath=\
44 | ${javac.classpath}:\
45 | ${build.classes.dir}
46 | javac.test.processorpath=\
47 | ${javac.test.classpath}
48 | javadoc.additionalparam=
49 | javadoc.author=false
50 | javadoc.encoding=${source.encoding}
51 | javadoc.noindex=false
52 | javadoc.nonavbar=false
53 | javadoc.notree=false
54 | javadoc.private=false
55 | javadoc.splitindex=true
56 | javadoc.use=true
57 | javadoc.version=false
58 | javadoc.windowtitle=
59 | jnlp.codebase.type=no.codebase
60 | jnlp.descriptor=application
61 | jnlp.enabled=false
62 | jnlp.mixed.code=default
63 | jnlp.offline-allowed=false
64 | jnlp.signed=false
65 | jnlp.signing=
66 | jnlp.signing.alias=
67 | jnlp.signing.keystore=
68 | main.class=eu.inmite.application.CryptedResource
69 | manifest.file=manifest.mf
70 | meta.inf.dir=${src.dir}/META-INF
71 | mkdist.disabled=false
72 | platform.active=default_platform
73 | run.classpath=\
74 | ${javac.classpath}:\
75 | ${build.classes.dir}
76 | # Space-separated list of JVM arguments used when running the project.
77 | # You may also define separate properties like run-sys-prop.name=value instead of -Dname=value.
78 | # To set system properties for unit tests define test-sys-prop.name=value:
79 | run.jvmargs=
80 | run.test.classpath=\
81 | ${javac.test.classpath}:\
82 | ${build.test.classes.dir}
83 | source.encoding=UTF-8
84 | src.dir=src
85 | test.src.dir=test
86 |
--------------------------------------------------------------------------------
/crypted-resource-java-tool/nbproject/project.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | org.netbeans.modules.java.j2seproject
4 |
5 |
6 | crypted-resource-java-tool
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 | ./lib/nblibraries.properties
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/crypted-resource-java-tool/src/eu/inmite/application/CryptedResource.java:
--------------------------------------------------------------------------------
1 | /*
2 | * To change this template, choose Tools | Templates
3 | * and open the template in the editor.
4 | */
5 | package eu.inmite.application;
6 |
7 | import java.io.BufferedInputStream;
8 | import java.io.BufferedOutputStream;
9 | import java.io.BufferedReader;
10 | import java.io.FileInputStream;
11 | import java.io.FileNotFoundException;
12 | import java.io.FileOutputStream;
13 | import java.io.IOException;
14 | import java.io.InputStream;
15 | import java.io.InputStreamReader;
16 | import java.security.SecureRandom;
17 |
18 | /**
19 | *
20 | * @author petrdvorak
21 | */
22 | public class CryptedResource {
23 |
24 | /**
25 | * @param args the command line arguments
26 | */
27 | public static void main(String[] args) throws FileNotFoundException, IOException {
28 |
29 | if (args == null || args.length == 0) {
30 | CryptedResource.printHelp();
31 | }
32 |
33 | if ("xor".equals(args[0].toLowerCase())) {
34 |
35 | FileInputStream fis = new FileInputStream(args[1]);
36 | BufferedInputStream bis = new BufferedInputStream(fis);
37 |
38 | FileOutputStream fos = new FileOutputStream(args[2]);
39 | BufferedOutputStream bos = new BufferedOutputStream(fos);
40 |
41 | byte[] bufferOrig = new byte[1 * 1024 * 1024]; //1MB
42 | byte[] bufferEncr = new byte[1 * 1024 * 1024]; //1MB
43 | byte[] symKey = unescapeString(args[3]); // see how long the key is
44 |
45 | int readBytes = 0;
46 |
47 | // iterate over the IN and KEY bytes, XOR them and write to OUT
48 | while (readBytes >= 0) {
49 | readBytes = bis.read(bufferOrig);
50 | if (readBytes == -1) {
51 | break;
52 | }
53 | for (int i = 0; i < readBytes; i++) {
54 | bufferEncr[i] = (byte) (bufferOrig[i] ^ symKey[i % symKey.length]);
55 | }
56 | bos.write(bufferEncr, 0, readBytes);
57 | bos.flush();
58 | }
59 |
60 | fos.close();
61 | bos.close();
62 |
63 | fis.close();
64 | bis.close();
65 | } else if ("gen".equals(args[0].toLowerCase())) {
66 | int size = Integer.valueOf(args[1]);
67 | byte[] buffer = new byte[size];
68 | new SecureRandom().nextBytes(buffer);
69 | System.out.println(escapedString(buffer));
70 | } else {
71 | CryptedResource.printHelp();
72 | }
73 | }
74 |
75 |
76 | private static String escapedString(byte[] inBytes) {
77 | if (inBytes.length % 2 != 0) return null;
78 | StringBuilder builder = new StringBuilder();
79 | for (int i = 0; i < inBytes.length ; i++) {
80 | String hex1 = Integer.toHexString(inBytes[i] & 0xFF);
81 | if (hex1.length() == 1) {
82 | hex1 = "0" + hex1;
83 | }
84 | builder.append(hex1);
85 | }
86 | return builder.toString();
87 | }
88 |
89 | private static byte[] unescapeString(String inString) {
90 | return hexStringToByteArray(inString);
91 | }
92 |
93 | private static byte[] hexStringToByteArray(String s) {
94 | int len = s.length();
95 | byte[] data = new byte[len / 2];
96 | for (int i = 0; i < len; i += 2) {
97 | data[i / 2] = (byte) ((Character.digit(s.charAt(i), 16) << 4) + Character.digit(s.charAt(i + 1), 16));
98 | }
99 | return data;
100 | }
101 |
102 | private static void printHelp() throws IOException {
103 | InputStream is = Object.class.getResourceAsStream("/eu/inmite/application/resources/help.txt");
104 | BufferedReader reader = new BufferedReader(new InputStreamReader(is));
105 | String line = reader.readLine();
106 | while (line != null) {
107 | System.out.println(line);
108 | line = reader.readLine();
109 | }
110 | }
111 | }
112 |
--------------------------------------------------------------------------------
/crypted-resource-java-tool/src/eu/inmite/application/resources/help.txt:
--------------------------------------------------------------------------------
1 |
2 | This is a utility for a simple XOR file encryption. The utility is written in
3 | Java and can be launched as such:
4 |
5 | java -jar crypted-resource-java-tool.jar [command] [params ...]
6 |
7 | The allowed commands are:
8 |
9 | - gen - Generate a new key for image encryption in base64 encoding. This command
10 | has only one parameter - the length of key in bytes.
11 |
12 | Example:
13 | java -jar crypted-resource-java-tool.jar gen 256
14 | # command generates 256 bytes = 2048 bits in hex string encoding
15 |
16 | - xor - Outputs XOR of an input file and a key (hex string) into the output file.
17 | Since XOR is a symmetric operation, this command is used for both
18 | encryption end decryption. Command has 3 parameters: input file, output
19 | file and key in hex string encoding.
20 |
21 | Example:
22 | java -jar crypted-resource-java-tool.jar in.bin out.bin p15xmz9k1MdqhlFgN1y95Q==
23 | # command takes bytes of in.bin, xors them (cyclically) with bits of
24 | # the key (decoded from hex string) and outputs the bytes in out.bin
25 |
26 | - help - Prints this help.
27 |
28 |
--------------------------------------------------------------------------------
/pngcrypt/pngcrypt.xcodeproj/project.pbxproj:
--------------------------------------------------------------------------------
1 | // !$*UTF8*$!
2 | {
3 | archiveVersion = 1;
4 | classes = {
5 | };
6 | objectVersion = 46;
7 | objects = {
8 |
9 | /* Begin PBXBuildFile section */
10 | 275530FD1B3365E600249210 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 275530FC1B3365E600249210 /* main.m */; };
11 | 2755310E1B33718A00249210 /* CryptedDataUtil.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 275531051B33718A00249210 /* CryptedDataUtil.cpp */; };
12 | 2755310F1B33718A00249210 /* NSData+CryptedData.mm in Sources */ = {isa = PBXBuildFile; fileRef = 275531091B33718A00249210 /* NSData+CryptedData.mm */; };
13 | 275531101B33718A00249210 /* NSString+CryptedString.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2755310B1B33718A00249210 /* NSString+CryptedString.mm */; };
14 | /* End PBXBuildFile section */
15 |
16 | /* Begin PBXCopyFilesBuildPhase section */
17 | 275530F71B3365E600249210 /* CopyFiles */ = {
18 | isa = PBXCopyFilesBuildPhase;
19 | buildActionMask = 2147483647;
20 | dstPath = /usr/share/man/man1/;
21 | dstSubfolderSpec = 0;
22 | files = (
23 | );
24 | runOnlyForDeploymentPostprocessing = 1;
25 | };
26 | /* End PBXCopyFilesBuildPhase section */
27 |
28 | /* Begin PBXFileReference section */
29 | 275530F91B3365E600249210 /* pngcrypt */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = pngcrypt; sourceTree = BUILT_PRODUCTS_DIR; };
30 | 275530FC1B3365E600249210 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; };
31 | 275531041B33718A00249210 /* CryptedConstants.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CryptedConstants.h; sourceTree = ""; };
32 | 275531051B33718A00249210 /* CryptedDataUtil.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CryptedDataUtil.cpp; sourceTree = ""; };
33 | 275531061B33718A00249210 /* CryptedDataUtil.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CryptedDataUtil.h; sourceTree = ""; };
34 | 275531071B33718A00249210 /* CryptedResources.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CryptedResources.h; sourceTree = ""; };
35 | 275531081B33718A00249210 /* NSData+CryptedData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSData+CryptedData.h"; sourceTree = ""; };
36 | 275531091B33718A00249210 /* NSData+CryptedData.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = "NSData+CryptedData.mm"; sourceTree = ""; };
37 | 2755310A1B33718A00249210 /* NSString+CryptedString.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSString+CryptedString.h"; sourceTree = ""; };
38 | 2755310B1B33718A00249210 /* NSString+CryptedString.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = "NSString+CryptedString.mm"; sourceTree = ""; };
39 | 2755310C1B33718A00249210 /* UIImage+CryptedImage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIImage+CryptedImage.h"; sourceTree = ""; };
40 | 2755310D1B33718A00249210 /* UIImage+CryptedImage.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = "UIImage+CryptedImage.mm"; sourceTree = ""; };
41 | /* End PBXFileReference section */
42 |
43 | /* Begin PBXFrameworksBuildPhase section */
44 | 275530F61B3365E600249210 /* Frameworks */ = {
45 | isa = PBXFrameworksBuildPhase;
46 | buildActionMask = 2147483647;
47 | files = (
48 | );
49 | runOnlyForDeploymentPostprocessing = 0;
50 | };
51 | /* End PBXFrameworksBuildPhase section */
52 |
53 | /* Begin PBXGroup section */
54 | 275530F01B3365E600249210 = {
55 | isa = PBXGroup;
56 | children = (
57 | 275530FB1B3365E600249210 /* pngcrypt */,
58 | 275530FA1B3365E600249210 /* Products */,
59 | );
60 | sourceTree = "";
61 | };
62 | 275530FA1B3365E600249210 /* Products */ = {
63 | isa = PBXGroup;
64 | children = (
65 | 275530F91B3365E600249210 /* pngcrypt */,
66 | );
67 | name = Products;
68 | sourceTree = "";
69 | };
70 | 275530FB1B3365E600249210 /* pngcrypt */ = {
71 | isa = PBXGroup;
72 | children = (
73 | 275531031B33718A00249210 /* CryptedResourceLib */,
74 | 275530FC1B3365E600249210 /* main.m */,
75 | );
76 | path = pngcrypt;
77 | sourceTree = "";
78 | };
79 | 275531031B33718A00249210 /* CryptedResourceLib */ = {
80 | isa = PBXGroup;
81 | children = (
82 | 275531041B33718A00249210 /* CryptedConstants.h */,
83 | 275531051B33718A00249210 /* CryptedDataUtil.cpp */,
84 | 275531061B33718A00249210 /* CryptedDataUtil.h */,
85 | 275531071B33718A00249210 /* CryptedResources.h */,
86 | 275531081B33718A00249210 /* NSData+CryptedData.h */,
87 | 275531091B33718A00249210 /* NSData+CryptedData.mm */,
88 | 2755310A1B33718A00249210 /* NSString+CryptedString.h */,
89 | 2755310B1B33718A00249210 /* NSString+CryptedString.mm */,
90 | 2755310C1B33718A00249210 /* UIImage+CryptedImage.h */,
91 | 2755310D1B33718A00249210 /* UIImage+CryptedImage.mm */,
92 | );
93 | name = CryptedResourceLib;
94 | path = "../../../../GitHub/imt-crypted-resources/crypted-resource-ios/CryptedResources/CryptedResourceLib";
95 | sourceTree = "";
96 | };
97 | /* End PBXGroup section */
98 |
99 | /* Begin PBXNativeTarget section */
100 | 275530F81B3365E600249210 /* pngcrypt */ = {
101 | isa = PBXNativeTarget;
102 | buildConfigurationList = 275531001B3365E600249210 /* Build configuration list for PBXNativeTarget "pngcrypt" */;
103 | buildPhases = (
104 | 275530F51B3365E600249210 /* Sources */,
105 | 275530F61B3365E600249210 /* Frameworks */,
106 | 275530F71B3365E600249210 /* CopyFiles */,
107 | );
108 | buildRules = (
109 | );
110 | dependencies = (
111 | );
112 | name = pngcrypt;
113 | productName = pngcrypt;
114 | productReference = 275530F91B3365E600249210 /* pngcrypt */;
115 | productType = "com.apple.product-type.tool";
116 | };
117 | /* End PBXNativeTarget section */
118 |
119 | /* Begin PBXProject section */
120 | 275530F11B3365E600249210 /* Project object */ = {
121 | isa = PBXProject;
122 | attributes = {
123 | LastUpgradeCheck = 0630;
124 | ORGANIZATIONNAME = "Nikolay Kapustin";
125 | TargetAttributes = {
126 | 275530F81B3365E600249210 = {
127 | CreatedOnToolsVersion = 6.3.2;
128 | };
129 | };
130 | };
131 | buildConfigurationList = 275530F41B3365E600249210 /* Build configuration list for PBXProject "pngcrypt" */;
132 | compatibilityVersion = "Xcode 3.2";
133 | developmentRegion = English;
134 | hasScannedForEncodings = 0;
135 | knownRegions = (
136 | en,
137 | );
138 | mainGroup = 275530F01B3365E600249210;
139 | productRefGroup = 275530FA1B3365E600249210 /* Products */;
140 | projectDirPath = "";
141 | projectRoot = "";
142 | targets = (
143 | 275530F81B3365E600249210 /* pngcrypt */,
144 | );
145 | };
146 | /* End PBXProject section */
147 |
148 | /* Begin PBXSourcesBuildPhase section */
149 | 275530F51B3365E600249210 /* Sources */ = {
150 | isa = PBXSourcesBuildPhase;
151 | buildActionMask = 2147483647;
152 | files = (
153 | 2755310F1B33718A00249210 /* NSData+CryptedData.mm in Sources */,
154 | 275530FD1B3365E600249210 /* main.m in Sources */,
155 | 275531101B33718A00249210 /* NSString+CryptedString.mm in Sources */,
156 | 2755310E1B33718A00249210 /* CryptedDataUtil.cpp in Sources */,
157 | );
158 | runOnlyForDeploymentPostprocessing = 0;
159 | };
160 | /* End PBXSourcesBuildPhase section */
161 |
162 | /* Begin XCBuildConfiguration section */
163 | 275530FE1B3365E600249210 /* Debug */ = {
164 | isa = XCBuildConfiguration;
165 | buildSettings = {
166 | ALWAYS_SEARCH_USER_PATHS = NO;
167 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
168 | CLANG_CXX_LIBRARY = "libc++";
169 | CLANG_ENABLE_MODULES = YES;
170 | CLANG_ENABLE_OBJC_ARC = YES;
171 | CLANG_WARN_BOOL_CONVERSION = YES;
172 | CLANG_WARN_CONSTANT_CONVERSION = YES;
173 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
174 | CLANG_WARN_EMPTY_BODY = YES;
175 | CLANG_WARN_ENUM_CONVERSION = YES;
176 | CLANG_WARN_INT_CONVERSION = YES;
177 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
178 | CLANG_WARN_UNREACHABLE_CODE = YES;
179 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
180 | COPY_PHASE_STRIP = NO;
181 | DEBUG_INFORMATION_FORMAT = dwarf;
182 | ENABLE_STRICT_OBJC_MSGSEND = YES;
183 | GCC_C_LANGUAGE_STANDARD = gnu99;
184 | GCC_DYNAMIC_NO_PIC = NO;
185 | GCC_NO_COMMON_BLOCKS = YES;
186 | GCC_OPTIMIZATION_LEVEL = 0;
187 | GCC_PREPROCESSOR_DEFINITIONS = (
188 | "DEBUG=1",
189 | "$(inherited)",
190 | );
191 | GCC_SYMBOLS_PRIVATE_EXTERN = NO;
192 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
193 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
194 | GCC_WARN_UNDECLARED_SELECTOR = YES;
195 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
196 | GCC_WARN_UNUSED_FUNCTION = YES;
197 | GCC_WARN_UNUSED_VARIABLE = YES;
198 | MACOSX_DEPLOYMENT_TARGET = 10.10;
199 | MTL_ENABLE_DEBUG_INFO = YES;
200 | ONLY_ACTIVE_ARCH = YES;
201 | SDKROOT = macosx;
202 | };
203 | name = Debug;
204 | };
205 | 275530FF1B3365E600249210 /* Release */ = {
206 | isa = XCBuildConfiguration;
207 | buildSettings = {
208 | ALWAYS_SEARCH_USER_PATHS = NO;
209 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
210 | CLANG_CXX_LIBRARY = "libc++";
211 | CLANG_ENABLE_MODULES = YES;
212 | CLANG_ENABLE_OBJC_ARC = YES;
213 | CLANG_WARN_BOOL_CONVERSION = YES;
214 | CLANG_WARN_CONSTANT_CONVERSION = YES;
215 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
216 | CLANG_WARN_EMPTY_BODY = YES;
217 | CLANG_WARN_ENUM_CONVERSION = YES;
218 | CLANG_WARN_INT_CONVERSION = YES;
219 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
220 | CLANG_WARN_UNREACHABLE_CODE = YES;
221 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
222 | COPY_PHASE_STRIP = NO;
223 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
224 | ENABLE_NS_ASSERTIONS = NO;
225 | ENABLE_STRICT_OBJC_MSGSEND = YES;
226 | GCC_C_LANGUAGE_STANDARD = gnu99;
227 | GCC_NO_COMMON_BLOCKS = YES;
228 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
229 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
230 | GCC_WARN_UNDECLARED_SELECTOR = YES;
231 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
232 | GCC_WARN_UNUSED_FUNCTION = YES;
233 | GCC_WARN_UNUSED_VARIABLE = YES;
234 | MACOSX_DEPLOYMENT_TARGET = 10.10;
235 | MTL_ENABLE_DEBUG_INFO = NO;
236 | SDKROOT = macosx;
237 | };
238 | name = Release;
239 | };
240 | 275531011B3365E600249210 /* Debug */ = {
241 | isa = XCBuildConfiguration;
242 | buildSettings = {
243 | PRODUCT_NAME = "$(TARGET_NAME)";
244 | };
245 | name = Debug;
246 | };
247 | 275531021B3365E600249210 /* Release */ = {
248 | isa = XCBuildConfiguration;
249 | buildSettings = {
250 | PRODUCT_NAME = "$(TARGET_NAME)";
251 | };
252 | name = Release;
253 | };
254 | /* End XCBuildConfiguration section */
255 |
256 | /* Begin XCConfigurationList section */
257 | 275530F41B3365E600249210 /* Build configuration list for PBXProject "pngcrypt" */ = {
258 | isa = XCConfigurationList;
259 | buildConfigurations = (
260 | 275530FE1B3365E600249210 /* Debug */,
261 | 275530FF1B3365E600249210 /* Release */,
262 | );
263 | defaultConfigurationIsVisible = 0;
264 | defaultConfigurationName = Release;
265 | };
266 | 275531001B3365E600249210 /* Build configuration list for PBXNativeTarget "pngcrypt" */ = {
267 | isa = XCConfigurationList;
268 | buildConfigurations = (
269 | 275531011B3365E600249210 /* Debug */,
270 | 275531021B3365E600249210 /* Release */,
271 | );
272 | defaultConfigurationIsVisible = 0;
273 | };
274 | /* End XCConfigurationList section */
275 | };
276 | rootObject = 275530F11B3365E600249210 /* Project object */;
277 | }
278 |
--------------------------------------------------------------------------------
/pngcrypt/pngcrypt/main.m:
--------------------------------------------------------------------------------
1 |
2 | /*
3 | main.m
4 | pngcrypt
5 |
6 | Created by Nikolay Kapustin on 18.06.15.
7 | Copyright (c) 2015 Nikolay Kapustin. All rights reserved.
8 |
9 | The MIT License (MIT)
10 |
11 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
12 | documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
13 | rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
14 | permit persons to whom the Software is furnished to do so, subject to the following conditions:
15 |
16 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
17 | Software.
18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
19 | WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
20 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
21 | OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 | */
23 |
24 | #import
25 | #import "CryptedResources.h"
26 |
27 | void printHelp();
28 | BOOL isReachFile(NSString* fileName);
29 | BOOL cryptFile(NSString* sourceFileName, NSString* destinationFileName, NSString *key);
30 |
31 | int main(int argc, const char * argv[]) {
32 | @autoreleasepool {
33 | NSArray* args = [[NSProcessInfo processInfo] arguments];
34 | if ([args count] == 1 || [args count] > 5) {
35 | printHelp();
36 | return 1;
37 | }
38 | if ([[args[1] lowercaseString] isEqualToString:@"help"]) {
39 | printHelp();
40 | }
41 | else{
42 | NSString *keyFile = args[1];
43 | NSError *error;
44 | NSString *key = [NSString stringWithContentsOfFile:keyFile encoding:NSUTF8StringEncoding error:&error];
45 | if (!key) {
46 | printf("%s", [@"Sorry, unable to load key file." UTF8String]);
47 | return 1;
48 | }
49 | NSString *newFileExtention = @"CRI";
50 | NSString *sourcePathFolder = [[NSFileManager defaultManager] currentDirectoryPath];
51 | NSString *destinationPathFolder = [[NSFileManager defaultManager] currentDirectoryPath];
52 |
53 | if ([args count] > 2){
54 | NSString* sourcePathFolder_Verify = args[2];
55 | if (![sourcePathFolder_Verify isEqualToString:[NSString string]] || isReachFile(sourcePathFolder_Verify))
56 | sourcePathFolder = sourcePathFolder_Verify;
57 | }
58 |
59 | if ([args count] > 3){
60 | NSString* destinationPathFolder_Verify = args[3];
61 | if (![destinationPathFolder_Verify isEqualToString:[NSString string]] || isReachFile(destinationPathFolder_Verify))
62 | destinationPathFolder = destinationPathFolder_Verify;
63 | }
64 | if ([args count] > 4){
65 | if ([[args[4] lowercaseString] isEqualToString:@"png"]){
66 | printf("%s", [@"Sorry, but new extension parameter will be ignored. Use other than PNG." UTF8String]);
67 | return 1;
68 | }
69 | else
70 | newFileExtention = args[4];
71 | }
72 |
73 | NSFileManager *localFileManager=[[NSFileManager alloc] init];
74 | NSDirectoryEnumerator *dirEnum = [localFileManager enumeratorAtPath:sourcePathFolder];
75 |
76 | NSString *file;
77 | while ((file = [dirEnum nextObject])) {
78 | if ([[[file pathExtension] lowercaseString] isEqualToString: @"png"]) {
79 | // process the file
80 | NSString *newFileName = [[file stringByDeletingPathExtension] stringByAppendingPathExtension:newFileExtention];
81 | cryptFile([sourcePathFolder stringByAppendingPathComponent:file], [destinationPathFolder stringByAppendingPathComponent:newFileName], key);
82 | }
83 | }
84 | }
85 | }
86 | return 0;
87 | }
88 |
89 | BOOL cryptFile(NSString* sourceFileName, NSString* destinationFileName, NSString *key){
90 | NSError *err;
91 | NSData *imageData = [NSData dataWithContentsOfFile:sourceFileName options:NSDataReadingUncached error:&err];
92 | if (!imageData){
93 | NSString *message = [NSString stringWithFormat:@"%@ %@", @"Unable to load image source.", err.localizedDescription];
94 | printf("%s\n", [message UTF8String]);
95 | return NO;
96 | }
97 | NSData *encryptedData = [NSData aes256cryptedDataWithData:imageData hexKey:key];
98 |
99 | BOOL result = [encryptedData writeToFile:destinationFileName options:NSDataWritingWithoutOverwriting error:&err];
100 | if (!result){
101 | printf("%s\n", [err.localizedDescription UTF8String]);
102 | return NO;
103 | }
104 | return YES;
105 | }
106 |
107 | void printHelp(){
108 | NSString* helpText =
109 | @"pngcrypt ver. 0.1\n"
110 | @"A simple tool for encrypt (AES256) PNG image files.\n"
111 | @"\n"
112 | @"Usage:\n"
113 | @" pngcrypt [original_path_folder] [destination_path_folder] [new_extension_file] - all PNG images from [original_path_folder] will be encrypted with key and put into [destination_path_folder].\n"
114 |
115 | @" If any of source or destination path parameter not set, tool operate with current folder.\n"
116 | @" By default for new created crypted file used CRI extension.\n"
117 | @"\n"
118 | @" pngcrypt help - prints this text\n"
119 | @"\n"
120 | @"NOTES\n"
121 | @" Currently this program does not support any type of files. Only PNG.\n";
122 | printf("%s", [helpText UTF8String]);
123 | }
124 |
125 | BOOL isReachFile(NSString* fileName){
126 | return [[NSFileManager defaultManager] isReadableFileAtPath:fileName];
127 | }
--------------------------------------------------------------------------------