1- ObjectiveTLS
1+ DBTransitEncryption
22=====================
33
44Overview
@@ -9,7 +9,7 @@ Transport Layer Security for securing data payloads in Objective-C. An easy way
99** TL;DR** AES encrypts data with a random key, RSA encrypts key and provides both.
1010
1111### What does it do?
12- ** ObjectiveTLS ** will secure data for transit similar to the handshake protocol of TLS.
12+ ** DBTransitEncryption ** will secure data for transit similar to the handshake protocol of TLS.
1313- Generate AES symmetric key
1414- Encrypt data payload with AES key
1515- Encrypt AES key with X.509 RSA public key
@@ -18,13 +18,13 @@ Transport Layer Security for securing data payloads in Objective-C. An easy way
1818### Installation
1919
2020##### Via CocoaPods
21- - Add ` pod 'ObjectiveTLS ' ` to your podfile
21+ - Add ` pod 'DBTransitEncryption ' ` to your podfile
2222- Run ` pod install `
2323
2424##### Manual Installation
2525- Link project against ` Security.framework `
26- - Add ` ObjectiveTLS ` folder to your project
27- - Import header (` #import "ObjectiveTLS .h" ` )
26+ - Add ` DBTransitEncryption ` folder to your project
27+ - Import header (` #import "DBTransitEncryption .h" ` )
2828
2929### Generate X.509 RSA Key Pair
3030- Run the following commands to generate a personal key pair for testing.
@@ -47,7 +47,7 @@ Encryption
4747 NSString *keyPath = [[NSBundle mainBundle ] pathForResource: @"public_key"
4848 ofType:@"der"] ;
4949
50- ObjectiveTLS * otls = [[ ObjectiveTLS alloc] initWithX509PublicKey: keyPath ] ;
50+ DBTransitEncryption * encryptor = [[ DBTransitEncryption alloc] initWithX509PublicKey: keyPath ] ;
5151```
5252
5353### Using in-memory X.509 Public Key (Recommended)
@@ -56,18 +56,18 @@ Encryption
5656 NSString *publicKey = @"MIICs ... kT0=\n"; // Base64 encoded key
5757 NSData *data = [[NSData alloc] initWithBase64EncodedString:publicKey options:NSDataBase64DecodingIgnoreUnknownCharacters];
5858
59- ObjectiveTLS *otls = [[ObjectiveTLS alloc]initWithX509PublicKeyData:data];
59+ DBTransitEncryption *encryptor = [[DBTransitEncryption alloc]initWithX509PublicKeyData:data];
6060```
6161
6262### Encrypt NSString
6363``` objc
6464
65- ObjectiveTLS *otls = [[ObjectiveTLS alloc ]initWithX509PublicKey:keyPath];
65+ DBTransitEncryption *encryptor = [[DBTransitEncryption alloc ]initWithX509PublicKey:keyPath];
6666 NSError *err = nil ;
6767 NSData *key = nil ; // AES Key, Encrypted with RSA public key
6868 NSData *iv = nil ; // Randomly Generated IV
6969
70- NSData *encryptedPayload = [otls aesEncryptString : @"Hello World Text"
70+ NSData *encryptedPayload = [encryptor encryptString : @"Hello World Text"
7171 rsaEncryptedKey:&key
7272 iv:&iv
7373 error:&err] ;
@@ -79,12 +79,12 @@ Encryption
7979 NSString *string = @"Hello World Text";
8080 NSData *dataToEncrypt = [string dataUsingEncoding:kStringEncoding];
8181
82- ObjectiveTLS *otls = [[ObjectiveTLS alloc]initWithX509PublicKey:keyPath];
82+ DBTransitEncryption *encryptor = [[DBTransitEncryption alloc]initWithX509PublicKey:keyPath];
8383 NSError *err = nil;
8484 NSData *key = nil; // AES Key, Encrypted with RSA public key
8585 NSData *iv = nil; // Randomly Generated IV
8686
87- NSData *encryptedPayload = [otls aesEncryptData :dataToEncrypt
87+ NSData *encryptedPayload = [encryptor encryptData :dataToEncrypt
8888 rsaEncryptedKey:&key
8989 iv:&iv
9090 error:&err];
@@ -100,8 +100,8 @@ Decryption
100100 NSString * privateKeyPath = [[ NSBundle mainBundle] pathForResource:@"private_key" ofType:@"p12"] ;
101101 NSString * privateKeyPassword = @"Password for .p12 file"
102102
103- ObjectiveTLS * otls = [[ ObjectiveTLS alloc] initWithX509PublicKey: publicKeyPath ] ;
104- [ otls setPrivateKey: privateKeyPath withPassphrase: privateKeyPassword ] ;
103+ DBTransitEncryption * encryptor = [[ DBTransitEncryption alloc] initWithX509PublicKey: publicKeyPath ] ;
104+ [ encryptor setPrivateKey: privateKeyPath withPassphrase: privateKeyPassword ] ;
105105```
106106
107107### Decrypt NSData
@@ -111,19 +111,19 @@ Decryption
111111 NSData *rsaEncryptedKey; // some encrypted key
112112 NSData *iv = nil; // some iv
113113
114- ObjectiveTLS *otls = [[ObjectiveTLS alloc]initWithX509PublicKey:publicKeyPath];
115- [otls setPrivateKey:privateKeyPath withPassphrase:@".p12 password"];
114+ DBTransitEncryption *encryptor = [[DBTransitEncryption alloc]initWithX509PublicKey:publicKeyPath];
115+ [encryptor setPrivateKey:privateKeyPath withPassphrase:@".p12 password"];
116116 NSError *err = nil;
117117
118- NSData *decryptedPayload = [otls aesDecryptData :dataToEncrypt
118+ NSData *decryptedPayload = [encryptor decryptData :dataToEncrypt
119119 rsaEncryptedKey:key
120120 iv:iv
121121 error:&err];
122122```
123123
124124Public Properties
125125---------
126- ** ObjectiveTLS ** has a few public properties which allow you to modify the encryption algorithms to suit your project's needs.
126+ ** DBTransitEncryption ** has a few public properties which allow you to modify the encryption algorithms to suit your project's needs.
127127
128128``` objc
129129@property (nonatomic, assign) NSUInteger rsaKeySize; // RSA key size in bits
@@ -141,7 +141,7 @@ Public Properties
141141
142142IV Mixer Blocks
143143---------
144- ** ObjectiveTLS ** allows you to define custom blocks to mix and separate the initialization vector with the key and/or the encrypted data.
144+ ** DBTransitEncryption ** allows you to define custom blocks to mix and separate the initialization vector with the key and/or the encrypted data.
145145
146146The ` ivMixer ` gives access to the data, key, and iv immediately after the data is encrypted, but before the key is encrypted. This allows you to mix the iv with key before it is RSA encrypted, to further secure the iv.
147147
@@ -150,19 +150,19 @@ The `ivSeparator` is the opposite of the `ivMixer`. The `ivSeparator` should be
150150### IV Mixing Example
151151``` objc
152152
153- ObjectiveTLS *otls = [[ObjectiveTLS alloc ]initWithX509PublicKeyData:pubkeyb64data];
153+ DBTransitEncryption *encryptor = [[DBTransitEncryption alloc ]initWithX509PublicKeyData:pubkeyb64data];
154154
155155 // Prepends the iv to the key before the key is encrypted
156156
157- [otls setIvMixer: ^(NSData ** data,NSData ** key, NSData * iv){
157+ [encryptor setIvMixer: ^(NSData ** data,NSData ** key, NSData * iv){
158158 NSMutableData * mutableKey = [ iv mutableCopy] ;
159159 [ mutableKey appendBytes:[ * key bytes] length:[ * key length]] ;
160160 * key = mutableKey;
161161 }] ;
162162
163163 // Extracts the iv from the key before decryption
164164
165- [ otls setIvSeparator:^NSData * (NSData ** data, NSData ** key){
165+ [ encryptor setIvSeparator:^NSData * (NSData ** data, NSData ** key){
166166 NSInteger ivSize = 16;
167167 NSMutableData * mutableKey = [ * key mutableCopy] ;
168168 NSRange range = NSMakeRange(0, ivSize);
0 commit comments