TestsTested | ✗ |
LangLanguage | Obj-CObjective C |
License | MIT |
ReleasedLast Release | Mar 2017 |
Maintained by Taras Kalapun.
// generate a unique AES key and (later) encrypt it with the public RSA key of the merchant
NSMutableData *key = [NSMutableData dataWithLength:kCCKeySizeAES256];
SecRandomCopyBytes(NULL, kCCKeySizeAES256, key.mutableBytes);
// generate a nonce
NSMutableData *iv = [NSMutableData dataWithLength:12];
SecRandomCopyBytes(NULL, 12, iv.mutableBytes);
NSData *cipherText = [TKAESCCMCryptor encrypt:data withKey:key iv:iv];
NSData *encryptedKey = [TKRSACryptor encrypt:key withKeyInHex:keyInHex];
Or use the wrapper class TKCryptor
and it's method
+ (NSString *)encrypt:(NSData *)data publicKeyInHex:(NSString *)keyInHex;
wich does:
""
)$
)$
)Note:
tagLength = 8
ivLength = 12
L = 3
Exponent|Modulus
TKCryptor is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod "TKCryptor", :git => "https://github.com/xslim/TKCryptor.git"
TKCryptor is available under the MIT license. See the LICENSE file for more info.