• Stars
    star
    135
  • Rank 269,297 (Top 6 %)
  • Language
    Objective-C
  • License
    Other
  • Created over 12 years ago
  • Updated over 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

An Objective-C Off-the-Record library for iOS.

OTRKit

Build Status

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.

Dependencies

Installation

To compile libotr and dependencies for iOS, run the included script, build-all.sh.

$ bash build-all.sh

Cocoapods

We now support Cocoapods but haven't pushed OTRKit.podspec to the public repository yet. Feel free to use the one in this repo in the meantime, but the public API may change slightly before release.

pod 'OTRKit', :git => 'https://github.com/ChatSecure/OTRKit.git'

Usage

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
/**
 *  This method **MUST** be implemented or OTR will not work. All outgoing messages
 *  should be sent first through OTRKit encodeMessage and then passed from this delegate
 *  to the appropriate chat protocol manager to send the actual message.
 *
 *  @param otrKit      reference to shared instance
 *  @param message     message to be sent over the network. may contain ciphertext.
 *  @param recipient   intended recipient of the message
 *  @param accountName your local account name
 *  @param protocol    protocol for account name such as "xmpp"
 *  @param tag optional tag to attached to message. Only used locally.
 */
- (void) otrKit:(OTRKit*)otrKit
  injectMessage:(NSString*)message
       username:(NSString*)username
    accountName:(NSString*)accountName
       protocol:(NSString*)protocol
            tag:(id)tag;

/**
 *  All outgoing messages should be sent to the OTRKit encodeMessage method before being
 *  sent over the network.
 *
 *  @param otrKit      reference to shared instance
 *  @param message     plaintext message
 *  @param sender      buddy who sent the message
 *  @param accountName your local account name
 *  @param protocol    protocol for account name such as "xmpp"
 *  @param tag optional tag to attach additional application-specific data to message. Only used locally.
 */
- (void) otrKit:(OTRKit*)otrKit
 encodedMessage:(NSString*)encodedMessage
       username:(NSString*)username
    accountName:(NSString*)accountName
       protocol:(NSString*)protocol
            tag:(id)tag
          error:(NSError*)error;


/**
 *  All incoming messages should be sent to the OTRKit decodeMessage method before being
 *  processed by your application. You should only display the messages coming from this delegate method.
 *
 *  @param otrKit      reference to shared instance
 *  @param message     plaintext message
 *  @param tlvs        OTRTLV values that may be present.
 *  @param sender      buddy who sent the message
 *  @param accountName your local account name
 *  @param protocol    protocol for account name such as "xmpp"
 *  @param tag optional tag to attach additional application-specific data to message. Only used locally.
 */
- (void) otrKit:(OTRKit*)otrKit
 decodedMessage:(NSString*)decodedMessage
           tlvs:(NSArray*)tlvs
       username:(NSString*)username
    accountName:(NSString*)accountName
       protocol:(NSString*)protocol
            tag:(id)tag;

/**
 *  When the encryption status changes this method is called
 *
 *  @param otrKit      reference to shared instance
 *  @param messageState plaintext, encrypted or finished
 *  @param username     buddy whose state has changed
 *  @param accountName your local account name
 *  @param protocol    protocol for account name such as "xmpp"
 */
- (void)    otrKit:(OTRKit*)otrKit
updateMessageState:(OTRKitMessageState)messageState
          username:(NSString*)username
       accountName:(NSString*)accountName
          protocol:(NSString*)protocol;
...

To encode a message:

/**
 * Encodes a message and optional array of OTRTLVs, splits it into fragments,
 * then injects the encoded data via the injectMessage: delegate method.
 * @param message The message to be encoded
 * @param tlvs Array of OTRTLVs, the data length of each TLV must be smaller than UINT16_MAX or it will be ignored.
 * @param recipient The intended recipient of the message
 * @param accountName Your account name
 * @param protocol the protocol of accountName, such as @"xmpp"
 *  @param tag optional tag to attach additional application-specific data to message. Only used locally.
 */
- (void)encodeMessage:(NSString*)message
                 tlvs:(NSArray*)tlvs
             username:(NSString*)username
          accountName:(NSString*)accountName
             protocol:(NSString*)protocol
                  tag:(id)tag;

To decode a message:

/**
 *  All messages should be sent through here before being processed by your program.
 *
 *  @param message     Encoded or plaintext incoming message
 *  @param sender      account name of buddy who sent the message
 *  @param accountName your account name
 *  @param protocol    the protocol of accountName, such as @"xmpp"
 *  @param tag optional tag to attach additional application-specific data to message. Only used locally.
 */
- (void)decodeMessage:(NSString*)message
             username:(NSString*)username
          accountName:(NSString*)accountName
             protocol:(NSString*)protocol
                  tag:(id)tag;

TODO

  • Documentation!
  • Add Mac OS X support
  • Tests

Contributing

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.

License

The code for this project is dual licensed under the LGPLv2.1+ and MPL 2.0. The required dependencies are under terms of a seperate license (LGPL). More information is available in the LICENSE file.

More Repositories

1

ChatSecure-iOS

ChatSecure is a free and open source encrypted chat client for iOS that supports OTR and OMEMO encryption over XMPP.
Objective-C
3,130
star
2

ChatSecure-Push-Server

An experimental design for a privacy-minded push server.
Python
112
star
3

OnionKit

Objective-C Tor Wrapper Framework for iOS
Shell
41
star
4

xmpp-server-list

Public XMPP server list and metadata in JSON format
28
star
5

ChatSecure-Push-Android

The Android SDK for ChatSecure-Push-Server
Java
17
star
6

ChatSecure-Push-iOS

The iOS SDK for ChatSecure-Push-Server
Swift
16
star
7

RubDub

A Node XMPP Push Service for XEP-0357: Push Notifications
JavaScript
15
star
8

IOCipher-ObjC

IOCipher for iOS and OS X
Objective-C
15
star
9

SignalProtocol-ObjC

Unofficial Objective-C wrapper for libsignal-protocol-c
Objective-C
12
star
10

SignalProtocolC

Unofficial podspec and framework for libsignal-protocol-c
Ruby
12
star
11

apns-client

Python client for Apple Push Notification service (APNs).
Python
7
star
12

chatsecure-web

Deprecated in favor of Jekyll https://github.com/chatsecure/chatsecure.github.io
Python
6
star
13

tor

Fork of https://git.torproject.org/tor.git for use in OnionKit
C
5
star
14

chef-chatsecure

Chef Repo for chatsecure.org
Ruby
4
star
15

Zom-iOS

Zom - whitelabel fork of ChatSecure for the Tibetan community
Objective-C
4
star
16

OpenSSL

Mirror of OpenSSL for including as a submodule
C
4
star
17

ChatSecure-Core

Splitting apart the non-UI code from ChatSecure iOS
3
star
18

ChatSecure-Metadata

Various metadata for ChatSecure
Ruby
3
star
19

Crittercism-SDK

Unofficial Mirror of Crittercism SDK to include as a submodule
Objective-C
2
star
20

chatsecure-users-cookbook

Chef cookbook for managing users
Ruby
2
star
21

PLCrashReporter

Mirror of PLCrashReporter
Objective-C
1
star
22

ChatSecure-Presentations

Slides and such.
1
star