Skip to content

Commit 6202a1b

Browse files
author
David Benko
committed
Merge pull request #6 from DavidBenko/NameChange
Change name to DBTransitEncryption
2 parents e9b072b + e2877bc commit 6202a1b

4 files changed

Lines changed: 37 additions & 37 deletions

File tree

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
Pod::Spec.new do |s|
2-
s.name = "ObjectiveTLS"
2+
s.name = "DBTransitEncryption"
33
s.version = "0.1.1"
4-
s.summary = "Encryption for data in transit; ObjectiveTLS will secure data for transit similar to the handshake protocol of TLS."
4+
s.summary = "Encryption for data in transit; DBTransitEncryption will secure data for transit similar to the handshake protocol of TLS."
55
s.description = <<-DESC
66
Transport Layer Security for securing data payloads in Objective-C. An easy way to secure data by providing a symmetric key for that transaction. Keys are generated on the fly and every message will have a new key.
77
DESC
8-
s.homepage = "https://github.com/DavidBenko/Objective-TLS"
8+
s.homepage = "https://github.com/DavidBenko/DBTransitEncryption"
99
s.license = 'MIT'
1010
s.author = { "David Benko" => "dbenko@prndl.us" }
11-
s.source = { :git => "https://github.com/DavidBenko/Objective-TLS.git", :tag => s.version.to_s }
11+
s.source = { :git => "https://github.com/DavidBenko/DBTransitEncryption.git", :tag => s.version.to_s }
1212
s.social_media_url = 'https://twitter.com/davidwbenko'
1313

1414
s.platform = :ios
1515
s.requires_arc = true
1616

17-
s.source_files = 'ObjectiveTLS'
17+
s.source_files = 'DBTransitEncryption'
1818
end
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//
2-
// ObjectiveTLS.h
2+
// DBTransitEncryption.h
33
// DBTransitEncryption
44
//
55
// Created by David Benko on 5/9/14.
@@ -16,7 +16,7 @@
1616
typedef void (^IVMixerBlock) (NSData **data,NSData **key, NSData *iv);
1717
typedef NSData* (^IVSeparatorBlock) (NSData **data, NSData **key);
1818

19-
@interface ObjectiveTLS : NSObject
19+
@interface DBTransitEncryption : NSObject
2020

2121
@property (nonatomic, assign) NSUInteger rsaKeySize; // RSA key size in bits
2222
@property (nonatomic, assign) SecPadding rsaPadding; // RSA padding
@@ -37,15 +37,15 @@ typedef NSData* (^IVSeparatorBlock) (NSData **data, NSData **key);
3737
* @param base64KeyData The contents of the public key
3838
* @return new ObjectiveTLS instance
3939
*/
40-
- (ObjectiveTLS *)initWithX509PublicKeyData:(NSData *)base64KeyData;
40+
- (DBTransitEncryption *)initWithX509PublicKeyData:(NSData *)base64KeyData;
4141

4242
/**
4343
* Initializes a new ObjectiveTLS object with the contents of a X.509 RSA public key at a given path
4444
*
4545
* @param publicKeyPath The file path of the public key
4646
* @return new ObjectiveTLS instance
4747
*/
48-
- (ObjectiveTLS *)initWithX509PublicKey:(NSString *)publicKeyPath;
48+
- (DBTransitEncryption *)initWithX509PublicKey:(NSString *)publicKeyPath;
4949

5050
#pragma mark - PKCS#12 RSA Private Key (.p12)
5151

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//
2-
// ObjectiveTLS.m
2+
// DBTransitEncryption.m
33
// DBTransitEncryption
44
//
55
// Created by David Benko on 5/9/14.
@@ -10,9 +10,9 @@
1010
// https://github.com/xjunior/XRSA RSA Encryption Algorithms
1111
//
1212

13-
#import "ObjectiveTLS.h"
13+
#import "DBTransitEncryption.h"
1414

15-
@interface ObjectiveTLS (){
15+
@interface DBTransitEncryption (){
1616
SecKeyRef publicKey;
1717
SecKeyRef privateKey;
1818
SecCertificateRef certificate;
@@ -22,13 +22,13 @@ @interface ObjectiveTLS (){
2222
}
2323
@end
2424

25-
@implementation ObjectiveTLS
25+
@implementation DBTransitEncryption
2626

27-
static NSString * const kObjectiveTLSErrorDomain = @"com.davidbenko.objectivetls";
27+
static NSString * const kObjectiveTLSErrorDomain = @"com.davidbenko.dbtransitencryption";
2828

2929
#pragma mark - Init
3030

31-
- (ObjectiveTLS *)initWithX509PublicKeyData:(NSData *)base64KeyData {
31+
- (DBTransitEncryption *)initWithX509PublicKeyData:(NSData *)base64KeyData {
3232
self = [super init];
3333
if (self) {
3434

@@ -53,7 +53,7 @@ - (ObjectiveTLS *)initWithX509PublicKeyData:(NSData *)base64KeyData {
5353
return self;
5454
}
5555

56-
- (ObjectiveTLS *)initWithX509PublicKey:(NSString *)publicKeyPath {
56+
- (DBTransitEncryption *)initWithX509PublicKey:(NSString *)publicKeyPath {
5757
if (publicKeyPath == nil) {
5858
NSLog(@"Can not find %@", publicKeyPath);
5959
return nil;

README.md

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
ObjectiveTLS
1+
DBTransitEncryption
22
=====================
33

44
Overview
@@ -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

124124
Public 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

142142
IV 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

146146
The `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

Comments
 (0)