OTRKit is an Objective-C wrapper for the OTRv3 encrypted messaging protocol, using libotr. This library was designed for use with the encrypted iOS messaging app ChatSecure, but should theoretically work for Mac OS X as well with some minor tweaking to the build scripts.
Install this project as a submodule in your repository (make sure to fork it first if you plan to make changes):
git submodule add https://github.com/ChatSecure/OTRKit.git Submodules/OTRKit
To compile libotr and dependencies for iOS, run the included scripts in this order (or use build-all.sh
):
build-libgpg-error.sh
build-libgcrypt.sh
build-libotr.sh
Then do these things:
- Drag
OTRKit.xcodeproj
to the left-hand file pane in Xcode to add it to your project. - Make sure to add
OTRKit (OTRKit)
to your project's Targent Dependencies in the Build Phases tab of your target settings. - Add
libOTRKit.a
to the Link Binary With Libraries step within the same window.
Check out OTRKit.h because it is the most up-to-date reference at the moment.
Implement the required delegate methods somewhere that makes sense for your project.
@protocol OTRKitDelegate <NSObject>
@required
// Implement this delegate method to forward the injected message to the appropriate protocol
- (void) injectMessage:(NSString*)message recipient:(NSString*)recipient accountName:(NSString*)accountName protocol:(NSString*)protocol;
- (void) updateMessageStateForUsername:(NSString*)username accountName:(NSString*)accountName protocol:(NSString*)protocol messageState:(OTRKitMessageState)messageState;
To encode a message:
NSString *message = @"Something in plain text.";
NSString *recipientAccount = @"bob@example.com";
NSString *sendingAccount = @"alice@example.com";
NSString *protocol = @"xmpp"; // OTR can work over any protocol
[[OTRKit sharedInstance] encodeMessage:message recipient:recipientAccount accountName:sendingAccount protocol:protocol success:^(NSString *encryptedMessage) {
// you might want to pass this along to diffie
NSLog(@"Encrypted ciphertext: %@", encryptedMessage);
}];
To decode a message:
[[OTRKit sharedInstance] decodeMessage:message recipient:friendAccount accountName:myAccountName protocol:protocol]
- Refactor to clean up the code a bit
- Documentation!
- Add Mac OS X support
- Change project to use git submodules for the dependencies.
- Figure out how to make
libgcrypt
,libgpg-error
, andlibotr
build within Xcode to assist in debugging. - Preserve the debugging symbols to allow for better crash reports when used in conjuction with dSYM files.
Please fork the project and submit a pull request and (preferrably) squash your commits. Thank you! If you're interested in privacy and security, check out chatsecure.org and The Guardian Project.
The code for this project is provided under the Modified BSD license. The required dependencies are under terms of a seperate license (LGPL). More information is available in the LICENSE file.