OpenSSL is the most powerful SSL and TLS library available which wraps a full cryptographic library. The library is written in pure C and due to its endless size and not-so-well-designed C interface it is very hard for beginners to step into it.
The aim of the MIHCrypto library is to provide an object-oriented interface which allows developers to write simple and clean code by still using the power of the OpenSSL libCrypto
library. OpenSSL is a very large library so (yet) not the whole library is wrapped by MIHCrypto. Since I am developing the library because personal needs focus of the functionallity is on modern cryptographic apporaches, but everybody is welcome to contrbute other parts to the library.
CocoaPods is a dependency manager for Objective-C, which automates and simplifies the process of using 3rd-party libraries like MIHCrypto in your projects.
platform :ios, '5.0'
pod "MIHCrypto", "~> 1.0.0"
MIHCrypto is based on some less protocol declarations (in MIHCrypto/Core
). MIHSymmetricKey
, MIHPrivateKey
and MIHPublicKey
are used for encryption and decryption.
id<MIHSymmetricKey> symmetricKey = ...
NSError *encryptionError = nil;
NSData *messageData = [@"My top secret message" dataByUsingEncoding:NSUTF8Encoding];
NSData *encryptedData = [symmetricKey encrypt:messageData error:&encryptionError];
These keys are either loaded from a file or generated by using an implementation of MIHKeyFactory
.
MIHAESKeyFactory *factory = [[MIHAESKeyFactory alloc] init];
id<MIHSymmetricKey> aesKey = [factory generateKey];
MIHCrypto requires Xcode 4 and above, targeting either iOS 5.0 and above, or Mac OS 10.7 Mountain Lion (64-bit with modern Cocoa runtime) and above.
As already mentioned OpenSSL is very powerful and large project so this library doesn't support all functionallity of it yet and new functions are added as needed. At the moment following cryptographic approaches are supported:
- AES (block cipher)
- MD5 (hash algorithm)
- RSA (public-key cryptography)
- SHA, SHA256, SHA384, SHA512 (hash algorithm)
Following approaches are in progress and may get published shortly:
- ECC (public-key cryptography)
- DES (block cipher)
Anybody is welcome to add additional support for other approaches.
MIHCrypto is available under the MIT license. See the LICENSE file for more info.