From 719eb543a8d08c4f536ea7933ffb3af0a8553e87 Mon Sep 17 00:00:00 2001 From: Chris Ballinger Date: Fri, 8 Apr 2016 17:24:41 -0700 Subject: Xcode, podspec, wrapper --- xcode/OLMKit/Info.plist | 26 + xcode/OLMKit/OLMAccount.h | 37 ++ xcode/OLMKit/OLMAccount.m | 116 +++++ xcode/OLMKit/OLMAccount_Private.h | 15 + xcode/OLMKit/OLMKit.h | 23 + xcode/OLMKit/OLMMessage.h | 24 + xcode/OLMKit/OLMMessage.m | 13 + xcode/OLMKit/OLMSerializable.h | 19 + xcode/OLMKit/OLMSession.h | 29 ++ xcode/OLMKit/OLMSession.m | 30 ++ xcode/OLMKit/OLMUtility.h | 15 + xcode/OLMKit/OLMUtility.m | 28 ++ xcode/OLMKitTests/Info.plist | 24 + xcode/OLMKitTests/OLMKitTests.m | 41 ++ xcode/Podfile | 6 + xcode/Podfile.lock | 14 + xcode/olm.xcodeproj/project.pbxproj | 557 +++++++++++++++++++++ .../xcshareddata/xcschemes/OLMKit.xcscheme | 99 ++++ .../xcshareddata/xcschemes/OLMKitTests.xcscheme | 90 ++++ xcode/olm.xcworkspace/contents.xcworkspacedata | 10 + 20 files changed, 1216 insertions(+) create mode 100644 xcode/OLMKit/Info.plist create mode 100644 xcode/OLMKit/OLMAccount.h create mode 100644 xcode/OLMKit/OLMAccount.m create mode 100644 xcode/OLMKit/OLMAccount_Private.h create mode 100644 xcode/OLMKit/OLMKit.h create mode 100644 xcode/OLMKit/OLMMessage.h create mode 100644 xcode/OLMKit/OLMMessage.m create mode 100644 xcode/OLMKit/OLMSerializable.h create mode 100644 xcode/OLMKit/OLMSession.h create mode 100644 xcode/OLMKit/OLMSession.m create mode 100644 xcode/OLMKit/OLMUtility.h create mode 100644 xcode/OLMKit/OLMUtility.m create mode 100644 xcode/OLMKitTests/Info.plist create mode 100644 xcode/OLMKitTests/OLMKitTests.m create mode 100644 xcode/Podfile create mode 100644 xcode/Podfile.lock create mode 100644 xcode/olm.xcodeproj/project.pbxproj create mode 100644 xcode/olm.xcodeproj/xcshareddata/xcschemes/OLMKit.xcscheme create mode 100644 xcode/olm.xcodeproj/xcshareddata/xcschemes/OLMKitTests.xcscheme create mode 100644 xcode/olm.xcworkspace/contents.xcworkspacedata (limited to 'xcode') diff --git a/xcode/OLMKit/Info.plist b/xcode/OLMKit/Info.plist new file mode 100644 index 0000000..d3de8ee --- /dev/null +++ b/xcode/OLMKit/Info.plist @@ -0,0 +1,26 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + FMWK + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + $(CURRENT_PROJECT_VERSION) + NSPrincipalClass + + + diff --git a/xcode/OLMKit/OLMAccount.h b/xcode/OLMKit/OLMAccount.h new file mode 100644 index 0000000..cfa7129 --- /dev/null +++ b/xcode/OLMKit/OLMAccount.h @@ -0,0 +1,37 @@ +// +// OLMAccount.h +// olm +// +// Created by Chris Ballinger on 4/8/16. +// +// + +#import +#import "OLMSerializable.h" + +@interface OLMAccount : NSObject + +/** Creates new account */ +- (instancetype) initNewAccount; + +/** public identity keys. base64 encoded in "curve25519" and "ed25519" keys */ +- (NSDictionary*) identityKeys; + +/** signs message with ed25519 key for account */ +- (NSData*) signMessage:(NSData*)messageData; + +/** Public parts of the unpublished one time keys for the account */ +- (NSDictionary*) oneTimeKeys; + +/** Marks the current set of one time keys as being published. */ +- (void) markKeysAsPublished; + +/** The largest number of one time keys this account can store. */ +- (NSUInteger) maxOneTimeKeys; + +/** Generates a number of new one time keys. If the total number of keys stored + * by this account exceeds -maxOneTimeKeys then the old keys are + * discarded. */ +- (void) generateOneTimeKeys:(NSUInteger)numberOfKeys; + +@end diff --git a/xcode/OLMKit/OLMAccount.m b/xcode/OLMKit/OLMAccount.m new file mode 100644 index 0000000..58dd4ad --- /dev/null +++ b/xcode/OLMKit/OLMAccount.m @@ -0,0 +1,116 @@ +// +// OLMAccount.m +// olm +// +// Created by Chris Ballinger on 4/8/16. +// +// + +#import "OLMAccount.h" +#import "OLMAccount_Private.h" +#import "OLMUtility.h" + +@import Security; + +@implementation OLMAccount + +- (void) dealloc { + olm_clear_account(_account); + free(_account); +} + +- (BOOL) initializeAccountMemory { + size_t accountSize = olm_account_size(); + _account = malloc(accountSize); + NSParameterAssert(_account != nil); + if (!_account) { + return NO; + } + _account = olm_account(_account); + NSParameterAssert(_account != nil); + if (!_account) { + return NO; + } + return YES; +} + +- (instancetype) initNewAccount { + self = [super init]; + if (!self) { + return nil; + } + BOOL success = [self initializeAccountMemory]; + if (!success) { + return nil; + } + size_t randomLength = olm_create_account_random_length(_account); + size_t accountResult = olm_create_account(_account, (void*)[OLMUtility randomBytesOfLength:randomLength].bytes, randomLength); + if (accountResult == olm_error()) { + const char *error = olm_account_last_error(_account); + NSLog(@"error creating account: %s", error); + return nil; + } + return self; +} + +- (size_t) maxOneTimeKeys { + return olm_account_max_number_of_one_time_keys(_account); +} + + +/** public identity keys */ +- (NSDictionary*) identityKeys { + size_t identityKeysLength = olm_account_identity_keys_length(_account); + uint8_t *identityKeysBytes = malloc(identityKeysLength); + if (!identityKeysBytes) { + return nil; + } + size_t result = olm_account_identity_keys(_account, identityKeysBytes, identityKeysLength); + if (result == olm_error()) { + const char *error = olm_account_last_error(_account); + NSLog(@"error getting id keys: %s", error); + free(identityKeysBytes); + return nil; + } + NSData *idKeyData = [NSData dataWithBytesNoCopy:identityKeysBytes length:identityKeysLength freeWhenDone:YES]; + NSError *error = nil; + NSDictionary *keysDictionary = [NSJSONSerialization JSONObjectWithData:idKeyData options:0 error:&error]; + if (error) { + NSLog(@"Could not decode JSON: %@", error.localizedDescription); + } + return keysDictionary; +} + +- (NSDictionary*) oneTimeKeys { + size_t otkLength = olm_account_one_time_keys_length(_account); + uint8_t *otkBytes = malloc(otkLength); + if (!otkBytes) { + return nil; + } + size_t result = olm_account_one_time_keys(_account, otkBytes, otkLength); + if (result == olm_error()) { + const char *error = olm_account_last_error(_account); + NSLog(@"error getting id keys: %s", error); + free(otkBytes); + } + NSData *otk = [NSData dataWithBytesNoCopy:otkBytes length:otkLength freeWhenDone:YES]; + NSError *error = nil; + NSDictionary *keysDictionary = [NSJSONSerialization JSONObjectWithData:otk options:0 error:&error]; + if (error) { + NSLog(@"Could not decode JSON: %@", error.localizedDescription); + } + return keysDictionary; +} + + +- (void) generateOneTimeKeys:(NSUInteger)numberOfKeys { + size_t randomLength = olm_account_generate_one_time_keys_random_length(_account, numberOfKeys); + size_t result = olm_account_generate_one_time_keys(_account, numberOfKeys, (void*)[OLMUtility randomBytesOfLength:randomLength].bytes, randomLength); + if (result == olm_error()) { + const char *error = olm_account_last_error(_account); + NSLog(@"error generating keys: %s", error); + } +} + + +@end diff --git a/xcode/OLMKit/OLMAccount_Private.h b/xcode/OLMKit/OLMAccount_Private.h new file mode 100644 index 0000000..4eb3e2b --- /dev/null +++ b/xcode/OLMKit/OLMAccount_Private.h @@ -0,0 +1,15 @@ +// +// OLMAccount_Private.h +// olm +// +// Created by Chris Ballinger on 4/8/16. +// +// + +@import olm; + +@interface OLMAccount() + +@property (nonatomic) OlmAccount *account; + +@end \ No newline at end of file diff --git a/xcode/OLMKit/OLMKit.h b/xcode/OLMKit/OLMKit.h new file mode 100644 index 0000000..745af43 --- /dev/null +++ b/xcode/OLMKit/OLMKit.h @@ -0,0 +1,23 @@ +// +// OLMKit.h +// OLMKit +// +// Created by Chris Ballinger on 4/8/16. +// +// + +#import + +//! Project version number for OLMKit. +FOUNDATION_EXPORT double OLMKitVersionNumber; + +//! Project version string for OLMKit. +FOUNDATION_EXPORT const unsigned char OLMKitVersionString[]; + +// In this header, you should import all the public headers of your framework using statements like #import + + +#import "OLMAccount.h" +#import "OLMSession.h" +#import "OLMMessage.h" +#import "OLMUtility.h" \ No newline at end of file diff --git a/xcode/OLMKit/OLMMessage.h b/xcode/OLMKit/OLMMessage.h new file mode 100644 index 0000000..2b747fb --- /dev/null +++ b/xcode/OLMKit/OLMMessage.h @@ -0,0 +1,24 @@ +// +// OLMMessage.h +// olm +// +// Created by Chris Ballinger on 4/8/16. +// +// + +#import + +typedef NS_ENUM(NSUInteger, OLMMessageType) { + OLMMessageTypeUnknown, + OLMMessageTypePreKey, + OLMMessageTypeMessage +}; + +@interface OLMMessage : NSObject + +@property (nonatomic, readonly, nonnull) NSString *message; +@property (readonly) OLMMessageType type; + +- (nonnull instancetype) initWithMessage:(nonnull NSString*)message type:(OLMMessageType)type; + +@end diff --git a/xcode/OLMKit/OLMMessage.m b/xcode/OLMKit/OLMMessage.m new file mode 100644 index 0000000..ce732ec --- /dev/null +++ b/xcode/OLMKit/OLMMessage.m @@ -0,0 +1,13 @@ +// +// OLMMessage.m +// olm +// +// Created by Chris Ballinger on 4/8/16. +// +// + +#import "OLMMessage.h" + +@implementation OLMMessage + +@end diff --git a/xcode/OLMKit/OLMSerializable.h b/xcode/OLMKit/OLMSerializable.h new file mode 100644 index 0000000..afacdaa --- /dev/null +++ b/xcode/OLMKit/OLMSerializable.h @@ -0,0 +1,19 @@ +// +// OLMSerializable.h +// olm +// +// Created by Chris Ballinger on 4/8/16. +// +// + +#import + +@protocol OLMSerializable + +/** Initializes from encrypted serialized data. Will throw error if invalid key or invalid base64. */ +- (instancetype) initWithSerializedData:(NSData*)serializedData key:(NSData*)key error:(NSError**)error; + +/** Serializes and encrypts object data */ +- (NSData*) serializeDataWithKey:(NSData*)key; + +@end diff --git a/xcode/OLMKit/OLMSession.h b/xcode/OLMKit/OLMSession.h new file mode 100644 index 0000000..196900f --- /dev/null +++ b/xcode/OLMKit/OLMSession.h @@ -0,0 +1,29 @@ +// +// OLMSession.h +// olm +// +// Created by Chris Ballinger on 4/8/16. +// +// + +#import +#import "OLMSerializable.h" +#import "OLMAccount.h" + +@interface OLMSession : NSObject + +- (instancetype) initOutboundSessionWithAccount:(OLMAccount*)account theirIdentityKey:(NSData*)theirIdentityKey theirOneTimeKey:(NSData*)theirOneTimeKey; + +- (instancetype) initInboundSessionWithAccount:(OLMAccount*)account oneTimeKeyMessage:(NSData*)oneTimeKeyMessage; + +- (instancetype) initInboundSessionWithAccount:(OLMAccount*)account theirIdentityKey:(NSData*)theirIdentityKey oneTimeKeyMessage:(NSData*)oneTimeKeyMessage; + +- (NSData*) sessionIdentifier; + +- (BOOL) matchesInboundSession:(NSData*)oneTimeKeyMessage; + +- (BOOL) matchesInboundSessionFrom:(NSData*)theirIdentityKey oneTimeKeyMessage:(NSData *)oneTimeKeyMessage; + +- (void) removeOneTimeKeys; + +@end diff --git a/xcode/OLMKit/OLMSession.m b/xcode/OLMKit/OLMSession.m new file mode 100644 index 0000000..24a8b36 --- /dev/null +++ b/xcode/OLMKit/OLMSession.m @@ -0,0 +1,30 @@ +// +// OLMSession.m +// olm +// +// Created by Chris Ballinger on 4/8/16. +// +// + +#import "OLMSession.h" +@import olm; + +@interface OLMSession() +@property (nonatomic) OlmSession *session; +@end + +@implementation OLMSession + +- (instancetype) initOutboundSessionWithAccount:(OLMAccount*)account theirIdentityKey:(NSData*)theirIdentityKey theirOneTimeKey:(NSData*)theirOneTimeKey { + +} + +- (instancetype) initInboundSessionWithAccount:(OLMAccount*)account oneTimeKeyMessage:(NSData*)oneTimeKeyMessage { + +} + +- (instancetype) initInboundSessionWithAccount:(OLMAccount*)account theirIdentityKey:(NSData*)theirIdentityKey oneTimeKeyMessage:(NSData*)oneTimeKeyMessage { + +} + +@end diff --git a/xcode/OLMKit/OLMUtility.h b/xcode/OLMKit/OLMUtility.h new file mode 100644 index 0000000..0de9725 --- /dev/null +++ b/xcode/OLMKit/OLMUtility.h @@ -0,0 +1,15 @@ +// +// OLMUtility.h +// olm +// +// Created by Chris Ballinger on 4/8/16. +// +// + +#import + +@interface OLMUtility : NSObject + ++ (NSData*) randomBytesOfLength:(NSUInteger)length; + +@end diff --git a/xcode/OLMKit/OLMUtility.m b/xcode/OLMKit/OLMUtility.m new file mode 100644 index 0000000..0148932 --- /dev/null +++ b/xcode/OLMKit/OLMUtility.m @@ -0,0 +1,28 @@ +// +// OLMUtility.m +// olm +// +// Created by Chris Ballinger on 4/8/16. +// +// + +#import "OLMUtility.h" + +@implementation OLMUtility + ++ (NSData*) randomBytesOfLength:(NSUInteger)length { + uint8_t *randomBytes = malloc(length * sizeof(uint8_t)); + NSParameterAssert(randomBytes != NULL); + if (!randomBytes) { + return nil; + } + int result = SecRandomCopyBytes(kSecRandomDefault, length, randomBytes); + if (result != 0) { + free(randomBytes); + return nil; + } + NSData *data = [NSData dataWithBytesNoCopy:randomBytes length:length freeWhenDone:YES]; + return data; +} + +@end diff --git a/xcode/OLMKitTests/Info.plist b/xcode/OLMKitTests/Info.plist new file mode 100644 index 0000000..ba72822 --- /dev/null +++ b/xcode/OLMKitTests/Info.plist @@ -0,0 +1,24 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + BNDL + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1 + + diff --git a/xcode/OLMKitTests/OLMKitTests.m b/xcode/OLMKitTests/OLMKitTests.m new file mode 100644 index 0000000..944d11c --- /dev/null +++ b/xcode/OLMKitTests/OLMKitTests.m @@ -0,0 +1,41 @@ +// +// OLMKitTests.m +// OLMKitTests +// +// Created by Chris Ballinger on 4/8/16. +// +// + +#import +@import OLMKit; + +@interface OLMKitTests : XCTestCase + +@end + +@implementation OLMKitTests + +- (void)setUp { + [super setUp]; + // Put setup code here. This method is called before the invocation of each test method in the class. +} + +- (void)tearDown { + // Put teardown code here. This method is called after the invocation of each test method in the class. + [super tearDown]; +} + +- (void)testExample { + // This is an example of a functional test case. + // Use XCTAssert and related functions to verify your tests produce the correct results. + OLMAccount *alice = [[OLMAccount alloc] initNewAccount]; + OLMAccount *bob = [[OLMAccount alloc] initNewAccount]; + [bob generateOneTimeKeys:5]; + NSDictionary *identityKeys = bob.identityKeys; + NSDictionary *oneTimeKeys = bob.oneTimeKeys; + NSParameterAssert(identityKeys != nil); + NSParameterAssert(oneTimeKeys != nil); +} + + +@end diff --git a/xcode/Podfile b/xcode/Podfile new file mode 100644 index 0000000..7bd8189 --- /dev/null +++ b/xcode/Podfile @@ -0,0 +1,6 @@ +# Uncomment this line to define a global platform for your project +platform :ios, '8.0' +# Uncomment this line if you're using Swift +use_frameworks! + +pod 'olm', :path => '../olm.podspec' \ No newline at end of file diff --git a/xcode/Podfile.lock b/xcode/Podfile.lock new file mode 100644 index 0000000..4639dc0 --- /dev/null +++ b/xcode/Podfile.lock @@ -0,0 +1,14 @@ +PODS: + - olm (0.1.0) + +DEPENDENCIES: + - olm (from `../olm.podspec`) + +EXTERNAL SOURCES: + olm: + :path: "../olm.podspec" + +SPEC CHECKSUMS: + olm: ba8c1a7ca04486ec1ad958ec9feef73c0939ae27 + +COCOAPODS: 0.39.0 diff --git a/xcode/olm.xcodeproj/project.pbxproj b/xcode/olm.xcodeproj/project.pbxproj new file mode 100644 index 0000000..b1a62b0 --- /dev/null +++ b/xcode/olm.xcodeproj/project.pbxproj @@ -0,0 +1,557 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + D976E4411CB852E000F5C124 /* OLMKit.h in Headers */ = {isa = PBXBuildFile; fileRef = D976E4401CB852E000F5C124 /* OLMKit.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D976E4481CB852E000F5C124 /* OLMKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D976E43E1CB852E000F5C124 /* OLMKit.framework */; }; + D976E44D1CB852E000F5C124 /* OLMKitTests.m in Sources */ = {isa = PBXBuildFile; fileRef = D976E44C1CB852E000F5C124 /* OLMKitTests.m */; }; + D976E4571CB8536500F5C124 /* OLMAccount.h in Headers */ = {isa = PBXBuildFile; fileRef = D976E4551CB8536500F5C124 /* OLMAccount.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D976E4581CB8536500F5C124 /* OLMAccount.m in Sources */ = {isa = PBXBuildFile; fileRef = D976E4561CB8536500F5C124 /* OLMAccount.m */; }; + D976E45B1CB8538300F5C124 /* OLMSession.h in Headers */ = {isa = PBXBuildFile; fileRef = D976E4591CB8538300F5C124 /* OLMSession.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D976E45C1CB8538300F5C124 /* OLMSession.m in Sources */ = {isa = PBXBuildFile; fileRef = D976E45A1CB8538300F5C124 /* OLMSession.m */; }; + D976E45F1CB8538E00F5C124 /* OLMUtility.h in Headers */ = {isa = PBXBuildFile; fileRef = D976E45D1CB8538E00F5C124 /* OLMUtility.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D976E4601CB8538E00F5C124 /* OLMUtility.m in Sources */ = {isa = PBXBuildFile; fileRef = D976E45E1CB8538E00F5C124 /* OLMUtility.m */; }; + D976E4621CB860E200F5C124 /* OLMSerializable.h in Headers */ = {isa = PBXBuildFile; fileRef = D976E4611CB860E200F5C124 /* OLMSerializable.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D976E4651CB8674900F5C124 /* OLMMessage.h in Headers */ = {isa = PBXBuildFile; fileRef = D976E4631CB8674900F5C124 /* OLMMessage.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D976E4661CB8674900F5C124 /* OLMMessage.m in Sources */ = {isa = PBXBuildFile; fileRef = D976E4641CB8674900F5C124 /* OLMMessage.m */; }; + D976E4681CB8787D00F5C124 /* OLMAccount_Private.h in Headers */ = {isa = PBXBuildFile; fileRef = D976E4671CB8696100F5C124 /* OLMAccount_Private.h */; settings = {ATTRIBUTES = (Private, ); }; }; + DE4C8FA4266B10FC69A1C762 /* Pods.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 235C5A0B708438C11BCE552C /* Pods.framework */; }; +/* End PBXBuildFile section */ + +/* Begin PBXContainerItemProxy section */ + D976E4491CB852E000F5C124 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = D9679C4D1C87B53E007F67AA /* Project object */; + proxyType = 1; + remoteGlobalIDString = D976E43D1CB852E000F5C124; + remoteInfo = OLMKit; + }; +/* End PBXContainerItemProxy section */ + +/* Begin PBXFileReference section */ + 0A0809C67039D4BDCE9CE9AF /* Pods.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.debug.xcconfig; path = "Pods/Target Support Files/Pods/Pods.debug.xcconfig"; sourceTree = ""; }; + 235C5A0B708438C11BCE552C /* Pods.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + 81B8A7B31F3BA6548ACC45DE /* Pods.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.release.xcconfig; path = "Pods/Target Support Files/Pods/Pods.release.xcconfig"; sourceTree = ""; }; + D976E43E1CB852E000F5C124 /* OLMKit.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = OLMKit.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + D976E4401CB852E000F5C124 /* OLMKit.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = OLMKit.h; sourceTree = ""; }; + D976E4421CB852E000F5C124 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + D976E4471CB852E000F5C124 /* OLMKitTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = OLMKitTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; + D976E44C1CB852E000F5C124 /* OLMKitTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = OLMKitTests.m; sourceTree = ""; }; + D976E44E1CB852E000F5C124 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + D976E4551CB8536500F5C124 /* OLMAccount.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OLMAccount.h; sourceTree = ""; }; + D976E4561CB8536500F5C124 /* OLMAccount.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OLMAccount.m; sourceTree = ""; }; + D976E4591CB8538300F5C124 /* OLMSession.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OLMSession.h; sourceTree = ""; }; + D976E45A1CB8538300F5C124 /* OLMSession.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OLMSession.m; sourceTree = ""; }; + D976E45D1CB8538E00F5C124 /* OLMUtility.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OLMUtility.h; sourceTree = ""; }; + D976E45E1CB8538E00F5C124 /* OLMUtility.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OLMUtility.m; sourceTree = ""; }; + D976E4611CB860E200F5C124 /* OLMSerializable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OLMSerializable.h; sourceTree = ""; }; + D976E4631CB8674900F5C124 /* OLMMessage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OLMMessage.h; sourceTree = ""; }; + D976E4641CB8674900F5C124 /* OLMMessage.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OLMMessage.m; sourceTree = ""; }; + D976E4671CB8696100F5C124 /* OLMAccount_Private.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = OLMAccount_Private.h; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + D976E43A1CB852E000F5C124 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + DE4C8FA4266B10FC69A1C762 /* Pods.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + D976E4441CB852E000F5C124 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + D976E4481CB852E000F5C124 /* OLMKit.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + C125031A628591D7E1C25FD8 /* Frameworks */ = { + isa = PBXGroup; + children = ( + 235C5A0B708438C11BCE552C /* Pods.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; + D9679C4C1C87B53E007F67AA = { + isa = PBXGroup; + children = ( + D96991B7CDE3F0F8C3A52C54 /* Pods */, + D976E43F1CB852E000F5C124 /* OLMKit */, + D976E44B1CB852E000F5C124 /* OLMKitTests */, + C125031A628591D7E1C25FD8 /* Frameworks */, + D976E43E1CB852E000F5C124 /* OLMKit.framework */, + D976E4471CB852E000F5C124 /* OLMKitTests.xctest */, + ); + sourceTree = ""; + }; + D96991B7CDE3F0F8C3A52C54 /* Pods */ = { + isa = PBXGroup; + children = ( + 0A0809C67039D4BDCE9CE9AF /* Pods.debug.xcconfig */, + 81B8A7B31F3BA6548ACC45DE /* Pods.release.xcconfig */, + ); + name = Pods; + sourceTree = ""; + }; + D976E43F1CB852E000F5C124 /* OLMKit */ = { + isa = PBXGroup; + children = ( + D976E4631CB8674900F5C124 /* OLMMessage.h */, + D976E4641CB8674900F5C124 /* OLMMessage.m */, + D976E4401CB852E000F5C124 /* OLMKit.h */, + D976E4611CB860E200F5C124 /* OLMSerializable.h */, + D976E4551CB8536500F5C124 /* OLMAccount.h */, + D976E4671CB8696100F5C124 /* OLMAccount_Private.h */, + D976E4561CB8536500F5C124 /* OLMAccount.m */, + D976E4591CB8538300F5C124 /* OLMSession.h */, + D976E45A1CB8538300F5C124 /* OLMSession.m */, + D976E45D1CB8538E00F5C124 /* OLMUtility.h */, + D976E45E1CB8538E00F5C124 /* OLMUtility.m */, + D976E4421CB852E000F5C124 /* Info.plist */, + ); + path = OLMKit; + sourceTree = ""; + }; + D976E44B1CB852E000F5C124 /* OLMKitTests */ = { + isa = PBXGroup; + children = ( + D976E44C1CB852E000F5C124 /* OLMKitTests.m */, + D976E44E1CB852E000F5C124 /* Info.plist */, + ); + path = OLMKitTests; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXHeadersBuildPhase section */ + D976E43B1CB852E000F5C124 /* Headers */ = { + isa = PBXHeadersBuildPhase; + buildActionMask = 2147483647; + files = ( + D976E45B1CB8538300F5C124 /* OLMSession.h in Headers */, + D976E4681CB8787D00F5C124 /* OLMAccount_Private.h in Headers */, + D976E4651CB8674900F5C124 /* OLMMessage.h in Headers */, + D976E4621CB860E200F5C124 /* OLMSerializable.h in Headers */, + D976E45F1CB8538E00F5C124 /* OLMUtility.h in Headers */, + D976E4571CB8536500F5C124 /* OLMAccount.h in Headers */, + D976E4411CB852E000F5C124 /* OLMKit.h in Headers */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXHeadersBuildPhase section */ + +/* Begin PBXNativeTarget section */ + D976E43D1CB852E000F5C124 /* OLMKit */ = { + isa = PBXNativeTarget; + buildConfigurationList = D976E44F1CB852E000F5C124 /* Build configuration list for PBXNativeTarget "OLMKit" */; + buildPhases = ( + 5DFDEA7662CDB902F5544BBD /* Check Pods Manifest.lock */, + D976E4391CB852E000F5C124 /* Sources */, + D976E43A1CB852E000F5C124 /* Frameworks */, + D976E43B1CB852E000F5C124 /* Headers */, + D976E43C1CB852E000F5C124 /* Resources */, + DC41A6806320B8867B32F48B /* Copy Pods Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = OLMKit; + productName = OLMKit; + productReference = D976E43E1CB852E000F5C124 /* OLMKit.framework */; + productType = "com.apple.product-type.framework"; + }; + D976E4461CB852E000F5C124 /* OLMKitTests */ = { + isa = PBXNativeTarget; + buildConfigurationList = D976E4521CB852E000F5C124 /* Build configuration list for PBXNativeTarget "OLMKitTests" */; + buildPhases = ( + D976E4431CB852E000F5C124 /* Sources */, + D976E4441CB852E000F5C124 /* Frameworks */, + D976E4451CB852E000F5C124 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + D976E44A1CB852E000F5C124 /* PBXTargetDependency */, + ); + name = OLMKitTests; + productName = OLMKitTests; + productReference = D976E4471CB852E000F5C124 /* OLMKitTests.xctest */; + productType = "com.apple.product-type.bundle.unit-test"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + D9679C4D1C87B53E007F67AA /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 0730; + TargetAttributes = { + D976E43D1CB852E000F5C124 = { + CreatedOnToolsVersion = 7.3; + }; + D976E4461CB852E000F5C124 = { + CreatedOnToolsVersion = 7.3; + }; + }; + }; + buildConfigurationList = D9679C501C87B53E007F67AA /* Build configuration list for PBXProject "olm" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; + hasScannedForEncodings = 0; + knownRegions = ( + en, + ); + mainGroup = D9679C4C1C87B53E007F67AA; + productRefGroup = D9679C4C1C87B53E007F67AA; + projectDirPath = ""; + projectRoot = ""; + targets = ( + D976E43D1CB852E000F5C124 /* OLMKit */, + D976E4461CB852E000F5C124 /* OLMKitTests */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + D976E43C1CB852E000F5C124 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + D976E4451CB852E000F5C124 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXShellScriptBuildPhase section */ + 5DFDEA7662CDB902F5544BBD /* Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "Check Pods Manifest.lock"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n"; + showEnvVarsInLog = 0; + }; + DC41A6806320B8867B32F48B /* Copy Pods Resources */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "Copy Pods Resources"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods/Pods-resources.sh\"\n"; + showEnvVarsInLog = 0; + }; +/* End PBXShellScriptBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + D976E4391CB852E000F5C124 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + D976E4661CB8674900F5C124 /* OLMMessage.m in Sources */, + D976E4581CB8536500F5C124 /* OLMAccount.m in Sources */, + D976E45C1CB8538300F5C124 /* OLMSession.m in Sources */, + D976E4601CB8538E00F5C124 /* OLMUtility.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + D976E4431CB852E000F5C124 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + D976E44D1CB852E000F5C124 /* OLMKitTests.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXTargetDependency section */ + D976E44A1CB852E000F5C124 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = D976E43D1CB852E000F5C124 /* OLMKit */; + targetProxy = D976E4491CB852E000F5C124 /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + +/* Begin XCBuildConfiguration section */ + D9679C511C87B53E007F67AA /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ENABLE_TESTABILITY = YES; + ONLY_ACTIVE_ARCH = YES; + }; + name = Debug; + }; + D9679C521C87B53E007F67AA /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + }; + name = Release; + }; + D976E4501CB852E000F5C124 /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 0A0809C67039D4BDCE9CE9AF /* Pods.debug.xcconfig */; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + CURRENT_PROJECT_VERSION = 1; + DEBUG_INFORMATION_FORMAT = dwarf; + DEFINES_MODULE = YES; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + DYLIB_INSTALL_NAME_BASE = "@rpath"; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + INFOPLIST_FILE = OLMKit/Info.plist; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + IPHONEOS_DEPLOYMENT_TARGET = 9.3; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + PRODUCT_BUNDLE_IDENTIFIER = io.ballinger.OLMKit; + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = iphoneos; + SKIP_INSTALL = YES; + TARGETED_DEVICE_FAMILY = "1,2"; + VERSIONING_SYSTEM = "apple-generic"; + VERSION_INFO_PREFIX = ""; + }; + name = Debug; + }; + D976E4511CB852E000F5C124 /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 81B8A7B31F3BA6548ACC45DE /* Pods.release.xcconfig */; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + CURRENT_PROJECT_VERSION = 1; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + DEFINES_MODULE = YES; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + DYLIB_INSTALL_NAME_BASE = "@rpath"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + INFOPLIST_FILE = OLMKit/Info.plist; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + IPHONEOS_DEPLOYMENT_TARGET = 9.3; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + MTL_ENABLE_DEBUG_INFO = NO; + PRODUCT_BUNDLE_IDENTIFIER = io.ballinger.OLMKit; + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = iphoneos; + SKIP_INSTALL = YES; + TARGETED_DEVICE_FAMILY = "1,2"; + VALIDATE_PRODUCT = YES; + VERSIONING_SYSTEM = "apple-generic"; + VERSION_INFO_PREFIX = ""; + }; + name = Release; + }; + D976E4531CB852E000F5C124 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + INFOPLIST_FILE = OLMKitTests/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 9.3; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + PRODUCT_BUNDLE_IDENTIFIER = io.ballinger.OLMKitTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = iphoneos; + }; + name = Debug; + }; + D976E4541CB852E000F5C124 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + INFOPLIST_FILE = OLMKitTests/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 9.3; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + MTL_ENABLE_DEBUG_INFO = NO; + PRODUCT_BUNDLE_IDENTIFIER = io.ballinger.OLMKitTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = iphoneos; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + D9679C501C87B53E007F67AA /* Build configuration list for PBXProject "olm" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + D9679C511C87B53E007F67AA /* Debug */, + D9679C521C87B53E007F67AA /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + D976E44F1CB852E000F5C124 /* Build configuration list for PBXNativeTarget "OLMKit" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + D976E4501CB852E000F5C124 /* Debug */, + D976E4511CB852E000F5C124 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + D976E4521CB852E000F5C124 /* Build configuration list for PBXNativeTarget "OLMKitTests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + D976E4531CB852E000F5C124 /* Debug */, + D976E4541CB852E000F5C124 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = D9679C4D1C87B53E007F67AA /* Project object */; +} diff --git a/xcode/olm.xcodeproj/xcshareddata/xcschemes/OLMKit.xcscheme b/xcode/olm.xcodeproj/xcshareddata/xcschemes/OLMKit.xcscheme new file mode 100644 index 0000000..eee8c5e --- /dev/null +++ b/xcode/olm.xcodeproj/xcshareddata/xcschemes/OLMKit.xcscheme @@ -0,0 +1,99 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xcode/olm.xcodeproj/xcshareddata/xcschemes/OLMKitTests.xcscheme b/xcode/olm.xcodeproj/xcshareddata/xcschemes/OLMKitTests.xcscheme new file mode 100644 index 0000000..300e62c --- /dev/null +++ b/xcode/olm.xcodeproj/xcshareddata/xcschemes/OLMKitTests.xcscheme @@ -0,0 +1,90 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xcode/olm.xcworkspace/contents.xcworkspacedata b/xcode/olm.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..3c8fe35 --- /dev/null +++ b/xcode/olm.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,10 @@ + + + + + + + -- cgit v1.2.3 From f505113fb7a6d61015ad8050b3fb4e26df029150 Mon Sep 17 00:00:00 2001 From: Chris Ballinger Date: Sat, 9 Apr 2016 14:00:30 -0700 Subject: Initial test passing --- xcode/OLMKit/OLMAccount.m | 6 +- xcode/OLMKit/OLMMessage.h | 16 ++-- xcode/OLMKit/OLMMessage.m | 11 +++ xcode/OLMKit/OLMSession.h | 23 ++++-- xcode/OLMKit/OLMSession.m | 165 ++++++++++++++++++++++++++++++++++++++-- xcode/OLMKit/OLMUtility.h | 2 +- xcode/OLMKit/OLMUtility.m | 13 ++-- xcode/OLMKitTests/OLMKitTests.m | 25 +++++- 8 files changed, 227 insertions(+), 34 deletions(-) (limited to 'xcode') diff --git a/xcode/OLMKit/OLMAccount.m b/xcode/OLMKit/OLMAccount.m index 58dd4ad..d56b6b4 100644 --- a/xcode/OLMKit/OLMAccount.m +++ b/xcode/OLMKit/OLMAccount.m @@ -44,7 +44,8 @@ return nil; } size_t randomLength = olm_create_account_random_length(_account); - size_t accountResult = olm_create_account(_account, (void*)[OLMUtility randomBytesOfLength:randomLength].bytes, randomLength); + NSMutableData *random = [OLMUtility randomBytesOfLength:randomLength]; + size_t accountResult = olm_create_account(_account, random.mutableBytes, random.length); if (accountResult == olm_error()) { const char *error = olm_account_last_error(_account); NSLog(@"error creating account: %s", error); @@ -105,7 +106,8 @@ - (void) generateOneTimeKeys:(NSUInteger)numberOfKeys { size_t randomLength = olm_account_generate_one_time_keys_random_length(_account, numberOfKeys); - size_t result = olm_account_generate_one_time_keys(_account, numberOfKeys, (void*)[OLMUtility randomBytesOfLength:randomLength].bytes, randomLength); + NSMutableData *random = [OLMUtility randomBytesOfLength:randomLength]; + size_t result = olm_account_generate_one_time_keys(_account, numberOfKeys, random.mutableBytes, random.length); if (result == olm_error()) { const char *error = olm_account_last_error(_account); NSLog(@"error generating keys: %s", error); diff --git a/xcode/OLMKit/OLMMessage.h b/xcode/OLMKit/OLMMessage.h index 2b747fb..97c748f 100644 --- a/xcode/OLMKit/OLMMessage.h +++ b/xcode/OLMKit/OLMMessage.h @@ -8,17 +8,21 @@ #import -typedef NS_ENUM(NSUInteger, OLMMessageType) { - OLMMessageTypeUnknown, - OLMMessageTypePreKey, - OLMMessageTypeMessage +/* + from olm.hh + static const size_t OLM_MESSAGE_TYPE_PRE_KEY = 0; + static const size_t OLM_MESSAGE_TYPE_MESSAGE = 1; + */ +typedef NS_ENUM(NSInteger, OLMMessageType) { + OLMMessageTypePreKey = 0, + OLMMessageTypeMessage = 1 }; @interface OLMMessage : NSObject -@property (nonatomic, readonly, nonnull) NSString *message; +@property (nonatomic, copy, readonly, nonnull) NSString *ciphertext; @property (readonly) OLMMessageType type; -- (nonnull instancetype) initWithMessage:(nonnull NSString*)message type:(OLMMessageType)type; +- (nullable instancetype) initWithCiphertext:(nonnull NSString*)ciphertext type:(OLMMessageType)type; @end diff --git a/xcode/OLMKit/OLMMessage.m b/xcode/OLMKit/OLMMessage.m index ce732ec..d0cfb41 100644 --- a/xcode/OLMKit/OLMMessage.m +++ b/xcode/OLMKit/OLMMessage.m @@ -10,4 +10,15 @@ @implementation OLMMessage +- (nullable instancetype) initWithCiphertext:(nonnull NSString*)ciphertext type:(OLMMessageType)type { + NSParameterAssert(ciphertext != nil); + self = [super init]; + if (!self) { + return nil; + } + _ciphertext = [ciphertext copy]; + _type = type; + return self; +} + @end diff --git a/xcode/OLMKit/OLMSession.h b/xcode/OLMKit/OLMSession.h index 196900f..1a075e4 100644 --- a/xcode/OLMKit/OLMSession.h +++ b/xcode/OLMKit/OLMSession.h @@ -9,21 +9,30 @@ #import #import "OLMSerializable.h" #import "OLMAccount.h" +#import "OLMMessage.h" @interface OLMSession : NSObject -- (instancetype) initOutboundSessionWithAccount:(OLMAccount*)account theirIdentityKey:(NSData*)theirIdentityKey theirOneTimeKey:(NSData*)theirOneTimeKey; +@property (nonatomic, strong) OLMAccount *account; -- (instancetype) initInboundSessionWithAccount:(OLMAccount*)account oneTimeKeyMessage:(NSData*)oneTimeKeyMessage; +- (instancetype) initOutboundSessionWithAccount:(OLMAccount*)account theirIdentityKey:(NSString*)theirIdentityKey theirOneTimeKey:(NSString*)theirOneTimeKey; -- (instancetype) initInboundSessionWithAccount:(OLMAccount*)account theirIdentityKey:(NSData*)theirIdentityKey oneTimeKeyMessage:(NSData*)oneTimeKeyMessage; +- (instancetype) initInboundSessionWithAccount:(OLMAccount*)account oneTimeKeyMessage:(NSString*)oneTimeKeyMessage; -- (NSData*) sessionIdentifier; +- (instancetype) initInboundSessionWithAccount:(OLMAccount*)account theirIdentityKey:(NSString*)theirIdentityKey oneTimeKeyMessage:(NSString*)oneTimeKeyMessage; -- (BOOL) matchesInboundSession:(NSData*)oneTimeKeyMessage; +- (NSString*) sessionIdentifier; -- (BOOL) matchesInboundSessionFrom:(NSData*)theirIdentityKey oneTimeKeyMessage:(NSData *)oneTimeKeyMessage; +- (BOOL) matchesInboundSession:(NSString*)oneTimeKeyMessage; -- (void) removeOneTimeKeys; +- (BOOL) matchesInboundSessionFrom:(NSString*)theirIdentityKey oneTimeKeyMessage:(NSString *)oneTimeKeyMessage; + +- (BOOL) removeOneTimeKeys; + +/** UTF-8 plaintext -> base64 ciphertext */ +- (OLMMessage*) encryptMessage:(NSString*)message; + +/** base64 ciphertext -> UTF-8 plaintext */ +- (NSString*) decryptMessage:(OLMMessage*)message; @end diff --git a/xcode/OLMKit/OLMSession.m b/xcode/OLMKit/OLMSession.m index 24a8b36..fa7cb62 100644 --- a/xcode/OLMKit/OLMSession.m +++ b/xcode/OLMKit/OLMSession.m @@ -7,6 +7,8 @@ // #import "OLMSession.h" +#import "OLMUtility.h" +#import "OLMAccount_Private.h" @import olm; @interface OLMSession() @@ -15,16 +17,167 @@ @implementation OLMSession -- (instancetype) initOutboundSessionWithAccount:(OLMAccount*)account theirIdentityKey:(NSData*)theirIdentityKey theirOneTimeKey:(NSData*)theirOneTimeKey { - +- (void) dealloc { + olm_clear_session(_session); + free(_session); } -- (instancetype) initInboundSessionWithAccount:(OLMAccount*)account oneTimeKeyMessage:(NSData*)oneTimeKeyMessage { - +- (BOOL) initializeSessionMemory { + size_t size = olm_session_size(); + _session = malloc(size); + NSParameterAssert(_session != nil); + if (!_session) { + return NO; + } + _session = olm_session(_session); + NSParameterAssert(_session != nil); + if (!_session) { + return NO; + } + return YES; } -- (instancetype) initInboundSessionWithAccount:(OLMAccount*)account theirIdentityKey:(NSData*)theirIdentityKey oneTimeKeyMessage:(NSData*)oneTimeKeyMessage { - +- (instancetype) initWithAccount:(OLMAccount*)account { + self = [super init]; + if (!self) { + return nil; + } + BOOL success = [self initializeSessionMemory]; + if (!success) { + return nil; + } + _account = account; + return self; +} + +- (instancetype) initOutboundSessionWithAccount:(OLMAccount*)account theirIdentityKey:(NSString*)theirIdentityKey theirOneTimeKey:(NSString*)theirOneTimeKey { + self = [self initWithAccount:account]; + if (!self) { + return nil; + } + NSMutableData *random = [OLMUtility randomBytesOfLength:olm_create_outbound_session_random_length(_session)]; + NSData *idKey = [theirIdentityKey dataUsingEncoding:NSUTF8StringEncoding]; + NSData *otKey = [theirOneTimeKey dataUsingEncoding:NSUTF8StringEncoding]; + size_t result = olm_create_outbound_session(_session, account.account, idKey.bytes, idKey.length, otKey.bytes, otKey.length, random.mutableBytes, random.length); + if (result == olm_error()) { + const char *error = olm_session_last_error(_session); + NSAssert(NO, @"olm_create_outbound_session error: %s", error); + return nil; + } + return self; +} + +- (instancetype) initInboundSessionWithAccount:(OLMAccount*)account oneTimeKeyMessage:(NSString*)oneTimeKeyMessage { + self = [self initWithAccount:account]; + if (!self) { + return nil; + } + BOOL success = [self initializeSessionMemory]; + if (!success) { + return nil; + } + NSMutableData *otk = [NSMutableData dataWithData:[oneTimeKeyMessage dataUsingEncoding:NSUTF8StringEncoding]]; + size_t result = olm_create_inbound_session(_session, account.account, otk.mutableBytes, oneTimeKeyMessage.length); + if (result == olm_error()) { + const char *error = olm_session_last_error(_session); + NSAssert(NO, @"olm_create_inbound_session error: %s", error); + return nil; + } + return self; +} + +- (instancetype) initInboundSessionWithAccount:(OLMAccount*)account theirIdentityKey:(NSString*)theirIdentityKey oneTimeKeyMessage:(NSString*)oneTimeKeyMessage { + self = [self initWithAccount:account]; + if (!self) { + return nil; + } + BOOL success = [self initializeSessionMemory]; + if (!success) { + return nil; + } + NSData *idKey = [theirIdentityKey dataUsingEncoding:NSUTF8StringEncoding]; + NSMutableData *otk = [NSMutableData dataWithData:[oneTimeKeyMessage dataUsingEncoding:NSUTF8StringEncoding]]; + size_t result = olm_create_inbound_session_from(_session, account.account, idKey.bytes, idKey.length, otk.mutableBytes, otk.length); + if (result == olm_error()) { + const char *error = olm_session_last_error(_session); + NSAssert(NO, @"olm_create_inbound_session_from error: %s", error); + return nil; + } + return self; +} + +- (NSString*) sessionIdentifier { + size_t length = olm_session_id_length(_session); + NSMutableData *idData = [NSMutableData dataWithLength:length]; + if (!idData) { + return nil; + } + size_t result = olm_session_id(_session, idData.mutableBytes, idData.length); + if (result == olm_error()) { + const char *error = olm_session_last_error(_session); + NSAssert(NO, @"olm_session_id error: %s", error); + return nil; + } + NSString *idString = [[NSString alloc] initWithData:idData encoding:NSUTF8StringEncoding]; + return idString; +} + +- (OLMMessage*) encryptMessage:(NSString*)message { + size_t messageType = olm_encrypt_message_type(_session); + size_t randomLength = olm_encrypt_random_length(_session); + NSMutableData *random = [OLMUtility randomBytesOfLength:randomLength]; + NSData *plaintextData = [message dataUsingEncoding:NSUTF8StringEncoding]; + size_t ciphertextLength = olm_encrypt_message_length(_session, plaintextData.length); + NSMutableData *ciphertext = [NSMutableData dataWithLength:ciphertextLength]; + if (!ciphertext) { + return nil; + } + size_t result = olm_encrypt(_session, plaintextData.bytes, plaintextData.length, random.mutableBytes, random.length, ciphertext.mutableBytes, ciphertext.length); + if (result == olm_error()) { + const char *error = olm_session_last_error(_session); + NSAssert(NO, @"olm_encrypt error: %s", error); + return nil; + } + NSString *ciphertextString = [[NSString alloc] initWithData:ciphertext encoding:NSUTF8StringEncoding]; + OLMMessage *encryptedMessage = [[OLMMessage alloc] initWithCiphertext:ciphertextString type:messageType]; + return encryptedMessage; +} + +- (BOOL) removeOneTimeKeys { + size_t result = olm_remove_one_time_keys(_account.account, _session); + if (result == olm_error()) { + const char *error = olm_session_last_error(_session); + NSAssert(NO, @"olm_remove_one_time_keys error: %s", error); + return NO; + } + return YES; +} + +- (NSString*) decryptMessage:(OLMMessage*)message { + NSParameterAssert(message != nil); + NSData *messageData = [message.ciphertext dataUsingEncoding:NSUTF8StringEncoding]; + if (!messageData) { + return nil; + } + NSMutableData *mutMessage = messageData.mutableCopy; + size_t maxPlaintextLength = olm_decrypt_max_plaintext_length(_session, message.type, mutMessage.mutableBytes, mutMessage.length); + if (maxPlaintextLength == olm_error()) { + const char *error = olm_session_last_error(_session); + NSAssert(NO, @"olm_decrypt_max_plaintext_length error: %s", error); + return nil; + } + // message buffer is destroyed by olm_decrypt_max_plaintext_length + mutMessage = messageData.mutableCopy; + NSMutableData *plaintextData = [NSMutableData dataWithLength:maxPlaintextLength]; + size_t plaintextLength = olm_decrypt(_session, message.type, mutMessage.mutableBytes, mutMessage.length, plaintextData.mutableBytes, plaintextData.length); + if (plaintextLength == olm_error()) { + const char *error = olm_session_last_error(_session); + NSAssert(NO, @"olm_decrypt error: %s", error); + return nil; + } + plaintextData.length = plaintextLength; + NSString *plaintext = [[NSString alloc] initWithData:plaintextData encoding:NSUTF8StringEncoding]; + return plaintext; } @end diff --git a/xcode/OLMKit/OLMUtility.h b/xcode/OLMKit/OLMUtility.h index 0de9725..8acbf40 100644 --- a/xcode/OLMKit/OLMUtility.h +++ b/xcode/OLMKit/OLMUtility.h @@ -10,6 +10,6 @@ @interface OLMUtility : NSObject -+ (NSData*) randomBytesOfLength:(NSUInteger)length; ++ (NSMutableData*) randomBytesOfLength:(NSUInteger)length; @end diff --git a/xcode/OLMKit/OLMUtility.m b/xcode/OLMKit/OLMUtility.m index 0148932..5dbe644 100644 --- a/xcode/OLMKit/OLMUtility.m +++ b/xcode/OLMKit/OLMUtility.m @@ -10,19 +10,16 @@ @implementation OLMUtility -+ (NSData*) randomBytesOfLength:(NSUInteger)length { - uint8_t *randomBytes = malloc(length * sizeof(uint8_t)); - NSParameterAssert(randomBytes != NULL); - if (!randomBytes) { ++ (NSMutableData*) randomBytesOfLength:(NSUInteger)length { + NSMutableData *randomData = [NSMutableData dataWithLength:length]; + if (!randomData) { return nil; } - int result = SecRandomCopyBytes(kSecRandomDefault, length, randomBytes); + int result = SecRandomCopyBytes(kSecRandomDefault, randomData.length, randomData.mutableBytes); if (result != 0) { - free(randomBytes); return nil; } - NSData *data = [NSData dataWithBytesNoCopy:randomBytes length:length freeWhenDone:YES]; - return data; + return randomData; } @end diff --git a/xcode/OLMKitTests/OLMKitTests.m b/xcode/OLMKitTests/OLMKitTests.m index 944d11c..7075057 100644 --- a/xcode/OLMKitTests/OLMKitTests.m +++ b/xcode/OLMKitTests/OLMKitTests.m @@ -31,10 +31,27 @@ OLMAccount *alice = [[OLMAccount alloc] initNewAccount]; OLMAccount *bob = [[OLMAccount alloc] initNewAccount]; [bob generateOneTimeKeys:5]; - NSDictionary *identityKeys = bob.identityKeys; - NSDictionary *oneTimeKeys = bob.oneTimeKeys; - NSParameterAssert(identityKeys != nil); - NSParameterAssert(oneTimeKeys != nil); + NSDictionary *bobIdKeys = bob.identityKeys; + NSString *bobIdKey = bobIdKeys[@"curve25519"]; + NSDictionary *bobOneTimeKeys = bob.oneTimeKeys; + NSParameterAssert(bobIdKey != nil); + NSParameterAssert(bobOneTimeKeys != nil); + __block NSString *bobOneTimeKey = nil; + NSDictionary *bobOtkCurve25519 = bobOneTimeKeys[@"curve25519"]; + [bobOtkCurve25519 enumerateKeysAndObjectsUsingBlock:^(id _Nonnull key, id _Nonnull obj, BOOL * _Nonnull stop) { + bobOneTimeKey = obj; + }]; + XCTAssert([bobOneTimeKey isKindOfClass:[NSString class]]); + + OLMSession *aliceSession = [[OLMSession alloc] initOutboundSessionWithAccount:alice theirIdentityKey:bobIdKey theirOneTimeKey:bobOneTimeKey]; + NSString *message = @"Hello!"; + OLMMessage *aliceToBobMsg = [aliceSession encryptMessage:message]; + + OLMSession *bobSession = [[OLMSession alloc] initInboundSessionWithAccount:bob oneTimeKeyMessage:aliceToBobMsg.ciphertext]; + NSString *plaintext = [bobSession decryptMessage:aliceToBobMsg]; + XCTAssertEqualObjects(message, plaintext); + BOOL success = [bobSession removeOneTimeKeys]; + XCTAssertTrue(success); } -- cgit v1.2.3 From daab2a58af947cddd67fe9f30dd3a9fc327650c0 Mon Sep 17 00:00:00 2001 From: Chris Ballinger Date: Wed, 13 Apr 2016 16:53:47 -0700 Subject: OLMAccount and OLMSession serialization --- xcode/OLMKit/OLMAccount.h | 8 ++- xcode/OLMKit/OLMAccount.m | 113 +++++++++++++++++++++++++++++++- xcode/OLMKit/OLMSerializable.h | 6 +- xcode/OLMKit/OLMSession.h | 6 +- xcode/OLMKit/OLMSession.m | 124 +++++++++++++++++++++++++++++------- xcode/OLMKit/OLMSession_Private.h | 16 +++++ xcode/OLMKitTests/OLMKitTests.m | 111 ++++++++++++++++++++++++++++++-- xcode/olm.xcodeproj/project.pbxproj | 4 ++ 8 files changed, 350 insertions(+), 38 deletions(-) create mode 100644 xcode/OLMKit/OLMSession_Private.h (limited to 'xcode') diff --git a/xcode/OLMKit/OLMAccount.h b/xcode/OLMKit/OLMAccount.h index cfa7129..a2923f9 100644 --- a/xcode/OLMKit/OLMAccount.h +++ b/xcode/OLMKit/OLMAccount.h @@ -9,7 +9,9 @@ #import #import "OLMSerializable.h" -@interface OLMAccount : NSObject +@class OLMSession; + +@interface OLMAccount : NSObject /** Creates new account */ - (instancetype) initNewAccount; @@ -18,11 +20,13 @@ - (NSDictionary*) identityKeys; /** signs message with ed25519 key for account */ -- (NSData*) signMessage:(NSData*)messageData; +- (NSString*) signMessage:(NSData*)messageData; /** Public parts of the unpublished one time keys for the account */ - (NSDictionary*) oneTimeKeys; +- (BOOL) removeOneTimeKeysForSession:(OLMSession*)session; + /** Marks the current set of one time keys as being published. */ - (void) markKeysAsPublished; diff --git a/xcode/OLMKit/OLMAccount.m b/xcode/OLMKit/OLMAccount.m index d56b6b4..4561a37 100644 --- a/xcode/OLMKit/OLMAccount.m +++ b/xcode/OLMKit/OLMAccount.m @@ -8,6 +8,8 @@ #import "OLMAccount.h" #import "OLMAccount_Private.h" +#import "OLMSession.h" +#import "OLMSession_Private.h" #import "OLMUtility.h" @import Security; @@ -34,7 +36,7 @@ return YES; } -- (instancetype) initNewAccount { +- (instancetype) init { self = [super init]; if (!self) { return nil; @@ -43,6 +45,14 @@ if (!success) { return nil; } + return self; +} + +- (instancetype) initNewAccount { + self = [self init]; + if (!self) { + return nil; + } size_t randomLength = olm_create_account_random_length(_account); NSMutableData *random = [OLMUtility randomBytesOfLength:randomLength]; size_t accountResult = olm_create_account(_account, random.mutableBytes, random.length); @@ -114,5 +124,106 @@ } } +- (BOOL) removeOneTimeKeysForSession:(OLMSession *)session { + NSParameterAssert(session != nil); + if (!session) { + return nil; + } + size_t result = olm_remove_one_time_keys(self.account, session.session); + if (result == olm_error()) { + const char *error = olm_session_last_error(session.session); + NSAssert(NO, @"olm_remove_one_time_keys error: %s", error); + return NO; + } + return YES; +} + +#pragma mark OLMSerializable + +/** Initializes from encrypted serialized data. Will throw error if invalid key or invalid base64. */ +- (instancetype) initWithSerializedData:(NSString*)serializedData key:(NSData*)key error:(NSError**)error { + self = [self init]; + if (!self) { + return nil; + } + NSParameterAssert(key.length > 0); + NSParameterAssert(serializedData.length > 0); + if (key.length == 0 || serializedData.length == 0) { + if (error) { + *error = [NSError errorWithDomain:@"org.matrix.olm" code:0 userInfo:@{NSLocalizedDescriptionKey: @"Bad length."}]; + } + return nil; + } + NSMutableData *pickle = [serializedData dataUsingEncoding:NSUTF8StringEncoding].mutableCopy; + size_t result = olm_unpickle_account(_account, key.bytes, key.length, pickle.mutableBytes, pickle.length); + if (result == olm_error()) { + const char *olm_error = olm_account_last_error(_account); + NSString *errorString = [NSString stringWithUTF8String:olm_error]; + if (error && errorString) { + *error = [NSError errorWithDomain:@"org.matrix.olm" code:0 userInfo:@{NSLocalizedDescriptionKey: errorString}]; + } + return nil; + } + return self; +} + +/** Serializes and encrypts object data, outputs base64 blob */ +- (NSString*) serializeDataWithKey:(NSData*)key error:(NSError**)error { + NSParameterAssert(key.length > 0); + size_t length = olm_pickle_account_length(_account); + NSMutableData *pickled = [NSMutableData dataWithLength:length]; + size_t result = olm_pickle_account(_account, key.bytes, key.length, pickled.mutableBytes, pickled.length); + if (result == olm_error()) { + const char *olm_error = olm_account_last_error(_account); + NSString *errorString = [NSString stringWithUTF8String:olm_error]; + if (error && errorString) { + *error = [NSError errorWithDomain:@"org.matrix.olm" code:0 userInfo:@{NSLocalizedDescriptionKey: errorString}]; + } + return nil; + } + NSString *pickleString = [[NSString alloc] initWithData:pickled encoding:NSUTF8StringEncoding]; + return pickleString; +} + +#pragma mark NSSecureCoding + ++ (BOOL) supportsSecureCoding { + return YES; +} + +#pragma mark NSCoding + +- (id)initWithCoder:(NSCoder *)decoder { + NSString *version = [decoder decodeObjectOfClass:[NSString class] forKey:@"version"]; + + NSError *error = nil; + + if ([version isEqualToString:@"1"]) { + NSString *pickle = [decoder decodeObjectOfClass:[NSString class] forKey:@"pickle"]; + NSData *key = [decoder decodeObjectOfClass:[NSData class] forKey:@"key"]; + + self = [self initWithSerializedData:pickle key:key error:&error]; + } + + NSParameterAssert(error == nil); + NSParameterAssert(self != nil); + if (!self) { + return nil; + } + + return self; +} + +- (void)encodeWithCoder:(NSCoder *)encoder { + NSData *key = [OLMUtility randomBytesOfLength:32]; + NSError *error = nil; + NSString *pickle = [self serializeDataWithKey:key error:&error]; + NSParameterAssert(pickle.length > 0 && error == nil); + + [encoder encodeObject:pickle forKey:@"pickle"]; + [encoder encodeObject:key forKey:@"key"]; + [encoder encodeObject:@"1" forKey:@"version"]; +} + @end diff --git a/xcode/OLMKit/OLMSerializable.h b/xcode/OLMKit/OLMSerializable.h index afacdaa..b4b115a 100644 --- a/xcode/OLMKit/OLMSerializable.h +++ b/xcode/OLMKit/OLMSerializable.h @@ -11,9 +11,9 @@ @protocol OLMSerializable /** Initializes from encrypted serialized data. Will throw error if invalid key or invalid base64. */ -- (instancetype) initWithSerializedData:(NSData*)serializedData key:(NSData*)key error:(NSError**)error; +- (instancetype) initWithSerializedData:(NSString*)serializedData key:(NSData*)key error:(NSError**)error; -/** Serializes and encrypts object data */ -- (NSData*) serializeDataWithKey:(NSData*)key; +/** Serializes and encrypts object data, outputs base64 blob */ +- (NSString*) serializeDataWithKey:(NSData*)key error:(NSError**)error; @end diff --git a/xcode/OLMKit/OLMSession.h b/xcode/OLMKit/OLMSession.h index 1a075e4..c209564 100644 --- a/xcode/OLMKit/OLMSession.h +++ b/xcode/OLMKit/OLMSession.h @@ -11,9 +11,7 @@ #import "OLMAccount.h" #import "OLMMessage.h" -@interface OLMSession : NSObject - -@property (nonatomic, strong) OLMAccount *account; +@interface OLMSession : NSObject - (instancetype) initOutboundSessionWithAccount:(OLMAccount*)account theirIdentityKey:(NSString*)theirIdentityKey theirOneTimeKey:(NSString*)theirOneTimeKey; @@ -27,8 +25,6 @@ - (BOOL) matchesInboundSessionFrom:(NSString*)theirIdentityKey oneTimeKeyMessage:(NSString *)oneTimeKeyMessage; -- (BOOL) removeOneTimeKeys; - /** UTF-8 plaintext -> base64 ciphertext */ - (OLMMessage*) encryptMessage:(NSString*)message; diff --git a/xcode/OLMKit/OLMSession.m b/xcode/OLMKit/OLMSession.m index fa7cb62..119079f 100644 --- a/xcode/OLMKit/OLMSession.m +++ b/xcode/OLMKit/OLMSession.m @@ -9,12 +9,9 @@ #import "OLMSession.h" #import "OLMUtility.h" #import "OLMAccount_Private.h" +#import "OLMSession_Private.h" @import olm; -@interface OLMSession() -@property (nonatomic) OlmSession *session; -@end - @implementation OLMSession - (void) dealloc { @@ -37,7 +34,7 @@ return YES; } -- (instancetype) initWithAccount:(OLMAccount*)account { +- (instancetype) init { self = [super init]; if (!self) { return nil; @@ -46,6 +43,18 @@ if (!success) { return nil; } + return self; +} + +- (instancetype) initWithAccount:(OLMAccount*)account { + self = [self init]; + if (!self) { + return nil; + } + NSParameterAssert(account != nil && account.account != NULL); + if (account == nil || account.account == NULL) { + return nil; + } _account = account; return self; } @@ -72,10 +81,6 @@ if (!self) { return nil; } - BOOL success = [self initializeSessionMemory]; - if (!success) { - return nil; - } NSMutableData *otk = [NSMutableData dataWithData:[oneTimeKeyMessage dataUsingEncoding:NSUTF8StringEncoding]]; size_t result = olm_create_inbound_session(_session, account.account, otk.mutableBytes, oneTimeKeyMessage.length); if (result == olm_error()) { @@ -91,10 +96,6 @@ if (!self) { return nil; } - BOOL success = [self initializeSessionMemory]; - if (!success) { - return nil; - } NSData *idKey = [theirIdentityKey dataUsingEncoding:NSUTF8StringEncoding]; NSMutableData *otk = [NSMutableData dataWithData:[oneTimeKeyMessage dataUsingEncoding:NSUTF8StringEncoding]]; size_t result = olm_create_inbound_session_from(_session, account.account, idKey.bytes, idKey.length, otk.mutableBytes, otk.length); @@ -143,16 +144,6 @@ return encryptedMessage; } -- (BOOL) removeOneTimeKeys { - size_t result = olm_remove_one_time_keys(_account.account, _session); - if (result == olm_error()) { - const char *error = olm_session_last_error(_session); - NSAssert(NO, @"olm_remove_one_time_keys error: %s", error); - return NO; - } - return YES; -} - - (NSString*) decryptMessage:(OLMMessage*)message { NSParameterAssert(message != nil); NSData *messageData = [message.ciphertext dataUsingEncoding:NSUTF8StringEncoding]; @@ -180,4 +171,91 @@ return plaintext; } +#pragma mark OLMSerializable + +/** Initializes from encrypted serialized data. Will throw error if invalid key or invalid base64. */ +- (instancetype) initWithSerializedData:(NSString*)serializedData key:(NSData*)key error:(NSError**)error { + self = [self init]; + if (!self) { + return nil; + } + NSParameterAssert(key.length > 0); + NSParameterAssert(serializedData.length > 0); + if (key.length == 0 || serializedData.length == 0) { + if (error) { + *error = [NSError errorWithDomain:@"org.matrix.olm" code:0 userInfo:@{NSLocalizedDescriptionKey: @"Bad length."}]; + } + return nil; + } + NSMutableData *pickle = [serializedData dataUsingEncoding:NSUTF8StringEncoding].mutableCopy; + size_t result = olm_unpickle_session(_session, key.bytes, key.length, pickle.mutableBytes, pickle.length); + if (result == olm_error()) { + const char *olm_error = olm_session_last_error(_session); + NSString *errorString = [NSString stringWithUTF8String:olm_error]; + if (error && errorString) { + *error = [NSError errorWithDomain:@"org.matrix.olm" code:0 userInfo:@{NSLocalizedDescriptionKey: errorString}]; + } + return nil; + } + return self; +} + +/** Serializes and encrypts object data, outputs base64 blob */ +- (NSString*) serializeDataWithKey:(NSData*)key error:(NSError**)error { + NSParameterAssert(key.length > 0); + size_t length = olm_pickle_session_length(_session); + NSMutableData *pickled = [NSMutableData dataWithLength:length]; + size_t result = olm_pickle_session(_session, key.bytes, key.length, pickled.mutableBytes, pickled.length); + if (result == olm_error()) { + const char *olm_error = olm_session_last_error(_session); + NSString *errorString = [NSString stringWithUTF8String:olm_error]; + if (error && errorString) { + *error = [NSError errorWithDomain:@"org.matrix.olm" code:0 userInfo:@{NSLocalizedDescriptionKey: errorString}]; + } + return nil; + } + NSString *pickleString = [[NSString alloc] initWithData:pickled encoding:NSUTF8StringEncoding]; + return pickleString; +} + +#pragma mark NSSecureCoding + ++ (BOOL) supportsSecureCoding { + return YES; +} + +#pragma mark NSCoding + +- (id)initWithCoder:(NSCoder *)decoder { + NSString *version = [decoder decodeObjectOfClass:[NSString class] forKey:@"version"]; + + NSError *error = nil; + + if ([version isEqualToString:@"1"]) { + NSString *pickle = [decoder decodeObjectOfClass:[NSString class] forKey:@"pickle"]; + NSData *key = [decoder decodeObjectOfClass:[NSData class] forKey:@"key"]; + + self = [self initWithSerializedData:pickle key:key error:&error]; + } + + NSParameterAssert(error == nil); + NSParameterAssert(self != nil); + if (!self) { + return nil; + } + + return self; +} + +- (void)encodeWithCoder:(NSCoder *)encoder { + NSData *key = [OLMUtility randomBytesOfLength:32]; + NSError *error = nil; + NSString *pickle = [self serializeDataWithKey:key error:&error]; + NSParameterAssert(pickle.length > 0 && error == nil); + + [encoder encodeObject:pickle forKey:@"pickle"]; + [encoder encodeObject:key forKey:@"key"]; + [encoder encodeObject:@"1" forKey:@"version"]; +} + @end diff --git a/xcode/OLMKit/OLMSession_Private.h b/xcode/OLMKit/OLMSession_Private.h new file mode 100644 index 0000000..d906b14 --- /dev/null +++ b/xcode/OLMKit/OLMSession_Private.h @@ -0,0 +1,16 @@ +// +// OLMSession_Private.h +// olm +// +// Created by Chris Ballinger on 4/13/16. +// +// + +@import olm; + +@interface OLMSession() + +@property (nonatomic) OlmSession *session; +@property (nonatomic, strong) OLMAccount *account; + +@end \ No newline at end of file diff --git a/xcode/OLMKitTests/OLMKitTests.m b/xcode/OLMKitTests/OLMKitTests.m index 7075057..c76d636 100644 --- a/xcode/OLMKitTests/OLMKitTests.m +++ b/xcode/OLMKitTests/OLMKitTests.m @@ -25,9 +25,7 @@ [super tearDown]; } -- (void)testExample { - // This is an example of a functional test case. - // Use XCTAssert and related functions to verify your tests produce the correct results. +- (void)testAliceAndBob { OLMAccount *alice = [[OLMAccount alloc] initNewAccount]; OLMAccount *bob = [[OLMAccount alloc] initNewAccount]; [bob generateOneTimeKeys:5]; @@ -50,9 +48,114 @@ OLMSession *bobSession = [[OLMSession alloc] initInboundSessionWithAccount:bob oneTimeKeyMessage:aliceToBobMsg.ciphertext]; NSString *plaintext = [bobSession decryptMessage:aliceToBobMsg]; XCTAssertEqualObjects(message, plaintext); - BOOL success = [bobSession removeOneTimeKeys]; + BOOL success = [bob removeOneTimeKeysForSession:bobSession]; XCTAssertTrue(success); } +- (void) testBackAndForth { + OLMAccount *alice = [[OLMAccount alloc] initNewAccount]; + OLMAccount *bob = [[OLMAccount alloc] initNewAccount]; + [bob generateOneTimeKeys:1]; + NSDictionary *bobIdKeys = bob.identityKeys; + NSString *bobIdKey = bobIdKeys[@"curve25519"]; + NSDictionary *bobOneTimeKeys = bob.oneTimeKeys; + NSParameterAssert(bobIdKey != nil); + NSParameterAssert(bobOneTimeKeys != nil); + __block NSString *bobOneTimeKey = nil; + NSDictionary *bobOtkCurve25519 = bobOneTimeKeys[@"curve25519"]; + [bobOtkCurve25519 enumerateKeysAndObjectsUsingBlock:^(id _Nonnull key, id _Nonnull obj, BOOL * _Nonnull stop) { + bobOneTimeKey = obj; + }]; + XCTAssert([bobOneTimeKey isKindOfClass:[NSString class]]); + + OLMSession *aliceSession = [[OLMSession alloc] initOutboundSessionWithAccount:alice theirIdentityKey:bobIdKey theirOneTimeKey:bobOneTimeKey]; + NSString *message = @"Hello I'm Alice!"; + OLMMessage *aliceToBobMsg = [aliceSession encryptMessage:message]; + + OLMSession *bobSession = [[OLMSession alloc] initInboundSessionWithAccount:bob oneTimeKeyMessage:aliceToBobMsg.ciphertext]; + NSString *plaintext = [bobSession decryptMessage:aliceToBobMsg]; + XCTAssertEqualObjects(message, plaintext); + BOOL success = [bob removeOneTimeKeysForSession:bobSession]; + XCTAssertTrue(success); + + NSString *msg1 = @"Hello I'm Bob!"; + NSString *msg2 = @"Isn't life grand?"; + NSString *msg3 = @"Let's go to the opera."; + + OLMMessage *eMsg1 = [bobSession encryptMessage:msg1]; + OLMMessage *eMsg2 = [bobSession encryptMessage:msg2]; + OLMMessage *eMsg3 = [bobSession encryptMessage:msg3]; + + NSString *dMsg1 = [aliceSession decryptMessage:eMsg1]; + NSString *dMsg2 = [aliceSession decryptMessage:eMsg2]; + NSString *dMsg3 = [aliceSession decryptMessage:eMsg3]; + XCTAssertEqualObjects(msg1, dMsg1); + XCTAssertEqualObjects(msg2, dMsg2); + XCTAssertEqualObjects(msg3, dMsg3); + + +} + +- (void) testAccountSerialization { + OLMAccount *bob = [[OLMAccount alloc] initNewAccount]; + [bob generateOneTimeKeys:5]; + NSDictionary *bobIdKeys = bob.identityKeys; + NSDictionary *bobOneTimeKeys = bob.oneTimeKeys; + + NSData *bobData = [NSKeyedArchiver archivedDataWithRootObject:bob]; + + OLMAccount *bob2 = [NSKeyedUnarchiver unarchiveObjectWithData:bobData]; + NSDictionary *bobIdKeys2 = bob2.identityKeys; + NSDictionary *bobOneTimeKeys2 = bob.oneTimeKeys; + + XCTAssertEqualObjects(bobIdKeys, bobIdKeys2); + XCTAssertEqualObjects(bobOneTimeKeys, bobOneTimeKeys2); +} + +- (void) testSessionSerialization { + OLMAccount *alice = [[OLMAccount alloc] initNewAccount]; + OLMAccount *bob = [[OLMAccount alloc] initNewAccount]; + [bob generateOneTimeKeys:1]; + NSDictionary *bobIdKeys = bob.identityKeys; + NSString *bobIdKey = bobIdKeys[@"curve25519"]; + NSDictionary *bobOneTimeKeys = bob.oneTimeKeys; + NSParameterAssert(bobIdKey != nil); + NSParameterAssert(bobOneTimeKeys != nil); + __block NSString *bobOneTimeKey = nil; + NSDictionary *bobOtkCurve25519 = bobOneTimeKeys[@"curve25519"]; + [bobOtkCurve25519 enumerateKeysAndObjectsUsingBlock:^(id _Nonnull key, id _Nonnull obj, BOOL * _Nonnull stop) { + bobOneTimeKey = obj; + }]; + XCTAssert([bobOneTimeKey isKindOfClass:[NSString class]]); + + OLMSession *aliceSession = [[OLMSession alloc] initOutboundSessionWithAccount:alice theirIdentityKey:bobIdKey theirOneTimeKey:bobOneTimeKey]; + NSString *message = @"Hello I'm Alice!"; + OLMMessage *aliceToBobMsg = [aliceSession encryptMessage:message]; + + OLMSession *bobSession = [[OLMSession alloc] initInboundSessionWithAccount:bob oneTimeKeyMessage:aliceToBobMsg.ciphertext]; + NSString *plaintext = [bobSession decryptMessage:aliceToBobMsg]; + XCTAssertEqualObjects(message, plaintext); + BOOL success = [bob removeOneTimeKeysForSession:bobSession]; + XCTAssertTrue(success); + + NSString *msg1 = @"Hello I'm Bob!"; + NSString *msg2 = @"Isn't life grand?"; + NSString *msg3 = @"Let's go to the opera."; + + OLMMessage *eMsg1 = [bobSession encryptMessage:msg1]; + OLMMessage *eMsg2 = [bobSession encryptMessage:msg2]; + OLMMessage *eMsg3 = [bobSession encryptMessage:msg3]; + + NSData *aliceData = [NSKeyedArchiver archivedDataWithRootObject:aliceSession]; + OLMSession *alice2 = [NSKeyedUnarchiver unarchiveObjectWithData:aliceData]; + + NSString *dMsg1 = [alice2 decryptMessage:eMsg1]; + NSString *dMsg2 = [alice2 decryptMessage:eMsg2]; + NSString *dMsg3 = [alice2 decryptMessage:eMsg3]; + XCTAssertEqualObjects(msg1, dMsg1); + XCTAssertEqualObjects(msg2, dMsg2); + XCTAssertEqualObjects(msg3, dMsg3); +} + @end diff --git a/xcode/olm.xcodeproj/project.pbxproj b/xcode/olm.xcodeproj/project.pbxproj index b1a62b0..6c6fa32 100644 --- a/xcode/olm.xcodeproj/project.pbxproj +++ b/xcode/olm.xcodeproj/project.pbxproj @@ -7,6 +7,7 @@ objects = { /* Begin PBXBuildFile section */ + D9401CDC1CBF10BD003DD078 /* OLMSession_Private.h in Headers */ = {isa = PBXBuildFile; fileRef = D9401CDB1CBF10BD003DD078 /* OLMSession_Private.h */; }; D976E4411CB852E000F5C124 /* OLMKit.h in Headers */ = {isa = PBXBuildFile; fileRef = D976E4401CB852E000F5C124 /* OLMKit.h */; settings = {ATTRIBUTES = (Public, ); }; }; D976E4481CB852E000F5C124 /* OLMKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D976E43E1CB852E000F5C124 /* OLMKit.framework */; }; D976E44D1CB852E000F5C124 /* OLMKitTests.m in Sources */ = {isa = PBXBuildFile; fileRef = D976E44C1CB852E000F5C124 /* OLMKitTests.m */; }; @@ -37,6 +38,7 @@ 0A0809C67039D4BDCE9CE9AF /* Pods.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.debug.xcconfig; path = "Pods/Target Support Files/Pods/Pods.debug.xcconfig"; sourceTree = ""; }; 235C5A0B708438C11BCE552C /* Pods.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 81B8A7B31F3BA6548ACC45DE /* Pods.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.release.xcconfig; path = "Pods/Target Support Files/Pods/Pods.release.xcconfig"; sourceTree = ""; }; + D9401CDB1CBF10BD003DD078 /* OLMSession_Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OLMSession_Private.h; sourceTree = ""; }; D976E43E1CB852E000F5C124 /* OLMKit.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = OLMKit.framework; sourceTree = BUILT_PRODUCTS_DIR; }; D976E4401CB852E000F5C124 /* OLMKit.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = OLMKit.h; sourceTree = ""; }; D976E4421CB852E000F5C124 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; @@ -115,6 +117,7 @@ D976E4671CB8696100F5C124 /* OLMAccount_Private.h */, D976E4561CB8536500F5C124 /* OLMAccount.m */, D976E4591CB8538300F5C124 /* OLMSession.h */, + D9401CDB1CBF10BD003DD078 /* OLMSession_Private.h */, D976E45A1CB8538300F5C124 /* OLMSession.m */, D976E45D1CB8538E00F5C124 /* OLMUtility.h */, D976E45E1CB8538E00F5C124 /* OLMUtility.m */, @@ -139,6 +142,7 @@ isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; files = ( + D9401CDC1CBF10BD003DD078 /* OLMSession_Private.h in Headers */, D976E45B1CB8538300F5C124 /* OLMSession.h in Headers */, D976E4681CB8787D00F5C124 /* OLMAccount_Private.h in Headers */, D976E4651CB8674900F5C124 /* OLMMessage.h in Headers */, -- cgit v1.2.3 From 6f113dd7b3b4de918c4efb81d38a1ffe1d391b5b Mon Sep 17 00:00:00 2001 From: manuroe Date: Tue, 27 Sep 2016 11:57:29 +0200 Subject: OLMKit: Make the project build Make OLMKit CocoaPods expose the obj-c wrapper of libolm --- xcode/OLMKit.xcodeproj/project.pbxproj | 522 +++++++++++++++++++ xcode/OLMKit/OLMAccount_Private.h | 4 +- xcode/OLMKit/OLMKit.h | 8 +- xcode/OLMKit/OLMSession.m | 2 +- xcode/OLMKit/OLMSession_Private.h | 4 +- xcode/OLMKitTests/Info.plist | 2 - xcode/OLMKitTests/OLMKitTests.m | 2 +- xcode/Podfile | 11 +- xcode/Podfile.lock | 18 +- xcode/README.rst | 22 + xcode/olm.xcodeproj/project.pbxproj | 561 --------------------- .../xcshareddata/xcschemes/OLMKit.xcscheme | 99 ---- .../xcshareddata/xcschemes/OLMKitTests.xcscheme | 90 ---- xcode/olm.xcworkspace/contents.xcworkspacedata | 10 - 14 files changed, 572 insertions(+), 783 deletions(-) create mode 100644 xcode/OLMKit.xcodeproj/project.pbxproj create mode 100644 xcode/README.rst delete mode 100644 xcode/olm.xcodeproj/project.pbxproj delete mode 100644 xcode/olm.xcodeproj/xcshareddata/xcschemes/OLMKit.xcscheme delete mode 100644 xcode/olm.xcodeproj/xcshareddata/xcschemes/OLMKitTests.xcscheme delete mode 100644 xcode/olm.xcworkspace/contents.xcworkspacedata (limited to 'xcode') diff --git a/xcode/OLMKit.xcodeproj/project.pbxproj b/xcode/OLMKit.xcodeproj/project.pbxproj new file mode 100644 index 0000000..b50341b --- /dev/null +++ b/xcode/OLMKit.xcodeproj/project.pbxproj @@ -0,0 +1,522 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + 3274F6021D9A633A005282E4 /* OLMKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3274F5F81D9A633A005282E4 /* OLMKit.framework */; }; + 3274F6071D9A633A005282E4 /* OLMKitTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 3274F6061D9A633A005282E4 /* OLMKitTests.m */; }; + 3274F6131D9A698E005282E4 /* OLMKit.h in Headers */ = {isa = PBXBuildFile; fileRef = 3274F6121D9A698E005282E4 /* OLMKit.h */; }; + 7DBAD311AEA85CF6DB80DCFA /* libPods-OLMKitTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 7123FABE917D0FB140E036B7 /* libPods-OLMKitTests.a */; }; + D667051A0BA47E17CCC4E5D7 /* libPods-OLMKit.a in Frameworks */ = {isa = PBXBuildFile; fileRef = F2F22FE8F173AF845B882805 /* libPods-OLMKit.a */; }; +/* End PBXBuildFile section */ + +/* Begin PBXContainerItemProxy section */ + 3274F6031D9A633A005282E4 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 3274F5EF1D9A633A005282E4 /* Project object */; + proxyType = 1; + remoteGlobalIDString = 3274F5F71D9A633A005282E4; + remoteInfo = OLMKit; + }; +/* End PBXContainerItemProxy section */ + +/* Begin PBXFileReference section */ + 1B226B371526F2782C9D6372 /* Pods-OLMKit.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-OLMKit.release.xcconfig"; path = "Pods/Target Support Files/Pods-OLMKit/Pods-OLMKit.release.xcconfig"; sourceTree = ""; }; + 3274F5F81D9A633A005282E4 /* OLMKit.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = OLMKit.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + 3274F5FC1D9A633A005282E4 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 3274F6011D9A633A005282E4 /* OLMKitTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = OLMKitTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; + 3274F6061D9A633A005282E4 /* OLMKitTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = OLMKitTests.m; sourceTree = ""; }; + 3274F6081D9A633A005282E4 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 3274F6121D9A698E005282E4 /* OLMKit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OLMKit.h; sourceTree = ""; }; + 7123FABE917D0FB140E036B7 /* libPods-OLMKitTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-OLMKitTests.a"; sourceTree = BUILT_PRODUCTS_DIR; }; + 875BA7A520258EA15A31DD82 /* Pods-OLMKitTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-OLMKitTests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-OLMKitTests/Pods-OLMKitTests.debug.xcconfig"; sourceTree = ""; }; + D48E486DAE1F59F4F7EA8C25 /* Pods-OLMKitTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-OLMKitTests.release.xcconfig"; path = "Pods/Target Support Files/Pods-OLMKitTests/Pods-OLMKitTests.release.xcconfig"; sourceTree = ""; }; + E50E6B16E3433A5EB3297DEE /* Pods-OLMKit.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-OLMKit.debug.xcconfig"; path = "Pods/Target Support Files/Pods-OLMKit/Pods-OLMKit.debug.xcconfig"; sourceTree = ""; }; + F2F22FE8F173AF845B882805 /* libPods-OLMKit.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-OLMKit.a"; sourceTree = BUILT_PRODUCTS_DIR; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 3274F5F41D9A633A005282E4 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + D667051A0BA47E17CCC4E5D7 /* libPods-OLMKit.a in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 3274F5FE1D9A633A005282E4 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 3274F6021D9A633A005282E4 /* OLMKit.framework in Frameworks */, + 7DBAD311AEA85CF6DB80DCFA /* libPods-OLMKitTests.a in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 1FA3F53DFAAAA773F07F5E56 /* Pods */ = { + isa = PBXGroup; + children = ( + E50E6B16E3433A5EB3297DEE /* Pods-OLMKit.debug.xcconfig */, + 1B226B371526F2782C9D6372 /* Pods-OLMKit.release.xcconfig */, + 875BA7A520258EA15A31DD82 /* Pods-OLMKitTests.debug.xcconfig */, + D48E486DAE1F59F4F7EA8C25 /* Pods-OLMKitTests.release.xcconfig */, + ); + name = Pods; + sourceTree = ""; + }; + 3274F5EE1D9A633A005282E4 = { + isa = PBXGroup; + children = ( + 3274F5FA1D9A633A005282E4 /* OLMKit */, + 3274F6051D9A633A005282E4 /* OLMKitTests */, + 3274F5F91D9A633A005282E4 /* Products */, + 1FA3F53DFAAAA773F07F5E56 /* Pods */, + A5D2E6F079A29F7CC2A8D9FE /* Frameworks */, + ); + sourceTree = ""; + }; + 3274F5F91D9A633A005282E4 /* Products */ = { + isa = PBXGroup; + children = ( + 3274F5F81D9A633A005282E4 /* OLMKit.framework */, + 3274F6011D9A633A005282E4 /* OLMKitTests.xctest */, + ); + name = Products; + sourceTree = ""; + }; + 3274F5FA1D9A633A005282E4 /* OLMKit */ = { + isa = PBXGroup; + children = ( + 3274F6121D9A698E005282E4 /* OLMKit.h */, + 3274F5FC1D9A633A005282E4 /* Info.plist */, + ); + path = OLMKit; + sourceTree = ""; + }; + 3274F6051D9A633A005282E4 /* OLMKitTests */ = { + isa = PBXGroup; + children = ( + 3274F6061D9A633A005282E4 /* OLMKitTests.m */, + 3274F6081D9A633A005282E4 /* Info.plist */, + ); + path = OLMKitTests; + sourceTree = ""; + }; + A5D2E6F079A29F7CC2A8D9FE /* Frameworks */ = { + isa = PBXGroup; + children = ( + F2F22FE8F173AF845B882805 /* libPods-OLMKit.a */, + 7123FABE917D0FB140E036B7 /* libPods-OLMKitTests.a */, + ); + name = Frameworks; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXHeadersBuildPhase section */ + 3274F5F51D9A633A005282E4 /* Headers */ = { + isa = PBXHeadersBuildPhase; + buildActionMask = 2147483647; + files = ( + 3274F6131D9A698E005282E4 /* OLMKit.h in Headers */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXHeadersBuildPhase section */ + +/* Begin PBXNativeTarget section */ + 3274F5F71D9A633A005282E4 /* OLMKit */ = { + isa = PBXNativeTarget; + buildConfigurationList = 3274F60C1D9A633B005282E4 /* Build configuration list for PBXNativeTarget "OLMKit" */; + buildPhases = ( + 7FBCB292198F4156D9CA3B8D /* [CP] Check Pods Manifest.lock */, + 3274F5F31D9A633A005282E4 /* Sources */, + 3274F5F41D9A633A005282E4 /* Frameworks */, + 3274F5F51D9A633A005282E4 /* Headers */, + 3274F5F61D9A633A005282E4 /* Resources */, + 30F93582035CD30D211A6C76 /* [CP] Copy Pods Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = OLMKit; + productName = OLMKit; + productReference = 3274F5F81D9A633A005282E4 /* OLMKit.framework */; + productType = "com.apple.product-type.framework"; + }; + 3274F6001D9A633A005282E4 /* OLMKitTests */ = { + isa = PBXNativeTarget; + buildConfigurationList = 3274F60F1D9A633B005282E4 /* Build configuration list for PBXNativeTarget "OLMKitTests" */; + buildPhases = ( + 47E69E5BE6A019858DC41D4F /* [CP] Check Pods Manifest.lock */, + 3274F5FD1D9A633A005282E4 /* Sources */, + 3274F5FE1D9A633A005282E4 /* Frameworks */, + 3274F5FF1D9A633A005282E4 /* Resources */, + 0A185F0CAE96B33A4CD91B6A /* [CP] Embed Pods Frameworks */, + 793D0533290528B7C0E17CAD /* [CP] Copy Pods Resources */, + ); + buildRules = ( + ); + dependencies = ( + 3274F6041D9A633A005282E4 /* PBXTargetDependency */, + ); + name = OLMKitTests; + productName = OLMKitTests; + productReference = 3274F6011D9A633A005282E4 /* OLMKitTests.xctest */; + productType = "com.apple.product-type.bundle.unit-test"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 3274F5EF1D9A633A005282E4 /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 0800; + ORGANIZATIONNAME = matrix.org; + TargetAttributes = { + 3274F5F71D9A633A005282E4 = { + CreatedOnToolsVersion = 8.0; + ProvisioningStyle = Automatic; + }; + 3274F6001D9A633A005282E4 = { + CreatedOnToolsVersion = 8.0; + ProvisioningStyle = Automatic; + }; + }; + }; + buildConfigurationList = 3274F5F21D9A633A005282E4 /* Build configuration list for PBXProject "OLMKit" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; + hasScannedForEncodings = 0; + knownRegions = ( + en, + ); + mainGroup = 3274F5EE1D9A633A005282E4; + productRefGroup = 3274F5F91D9A633A005282E4 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 3274F5F71D9A633A005282E4 /* OLMKit */, + 3274F6001D9A633A005282E4 /* OLMKitTests */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 3274F5F61D9A633A005282E4 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 3274F5FF1D9A633A005282E4 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXShellScriptBuildPhase section */ + 0A185F0CAE96B33A4CD91B6A /* [CP] Embed Pods Frameworks */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "[CP] Embed Pods Frameworks"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-OLMKitTests/Pods-OLMKitTests-frameworks.sh\"\n"; + showEnvVarsInLog = 0; + }; + 30F93582035CD30D211A6C76 /* [CP] Copy Pods Resources */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "[CP] Copy Pods Resources"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-OLMKit/Pods-OLMKit-resources.sh\"\n"; + showEnvVarsInLog = 0; + }; + 47E69E5BE6A019858DC41D4F /* [CP] Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "[CP] Check Pods Manifest.lock"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n"; + showEnvVarsInLog = 0; + }; + 793D0533290528B7C0E17CAD /* [CP] Copy Pods Resources */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "[CP] Copy Pods Resources"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-OLMKitTests/Pods-OLMKitTests-resources.sh\"\n"; + showEnvVarsInLog = 0; + }; + 7FBCB292198F4156D9CA3B8D /* [CP] Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "[CP] Check Pods Manifest.lock"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n"; + showEnvVarsInLog = 0; + }; +/* End PBXShellScriptBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 3274F5F31D9A633A005282E4 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 3274F5FD1D9A633A005282E4 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 3274F6071D9A633A005282E4 /* OLMKitTests.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXTargetDependency section */ + 3274F6041D9A633A005282E4 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 3274F5F71D9A633A005282E4 /* OLMKit */; + targetProxy = 3274F6031D9A633A005282E4 /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + +/* Begin XCBuildConfiguration section */ + 3274F60A1D9A633B005282E4 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_SUSPICIOUS_MOVES = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + CURRENT_PROJECT_VERSION = 1; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 10.0; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + VERSIONING_SYSTEM = "apple-generic"; + VERSION_INFO_PREFIX = ""; + }; + name = Debug; + }; + 3274F60B1D9A633B005282E4 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_SUSPICIOUS_MOVES = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + CURRENT_PROJECT_VERSION = 1; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 10.0; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + VALIDATE_PRODUCT = YES; + VERSIONING_SYSTEM = "apple-generic"; + VERSION_INFO_PREFIX = ""; + }; + name = Release; + }; + 3274F60D1D9A633B005282E4 /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = E50E6B16E3433A5EB3297DEE /* Pods-OLMKit.debug.xcconfig */; + buildSettings = { + CODE_SIGN_IDENTITY = ""; + DEFINES_MODULE = YES; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + DYLIB_INSTALL_NAME_BASE = "@rpath"; + INFOPLIST_FILE = OLMKit/Info.plist; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = org.matrix.OLMKit; + PRODUCT_NAME = "$(TARGET_NAME)"; + SKIP_INSTALL = YES; + }; + name = Debug; + }; + 3274F60E1D9A633B005282E4 /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 1B226B371526F2782C9D6372 /* Pods-OLMKit.release.xcconfig */; + buildSettings = { + CODE_SIGN_IDENTITY = ""; + DEFINES_MODULE = YES; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + DYLIB_INSTALL_NAME_BASE = "@rpath"; + INFOPLIST_FILE = OLMKit/Info.plist; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = org.matrix.OLMKit; + PRODUCT_NAME = "$(TARGET_NAME)"; + SKIP_INSTALL = YES; + }; + name = Release; + }; + 3274F6101D9A633B005282E4 /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 875BA7A520258EA15A31DD82 /* Pods-OLMKitTests.debug.xcconfig */; + buildSettings = { + INFOPLIST_FILE = OLMKitTests/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = org.matrix.OLMKitTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Debug; + }; + 3274F6111D9A633B005282E4 /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = D48E486DAE1F59F4F7EA8C25 /* Pods-OLMKitTests.release.xcconfig */; + buildSettings = { + INFOPLIST_FILE = OLMKitTests/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = org.matrix.OLMKitTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 3274F5F21D9A633A005282E4 /* Build configuration list for PBXProject "OLMKit" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 3274F60A1D9A633B005282E4 /* Debug */, + 3274F60B1D9A633B005282E4 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 3274F60C1D9A633B005282E4 /* Build configuration list for PBXNativeTarget "OLMKit" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 3274F60D1D9A633B005282E4 /* Debug */, + 3274F60E1D9A633B005282E4 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 3274F60F1D9A633B005282E4 /* Build configuration list for PBXNativeTarget "OLMKitTests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 3274F6101D9A633B005282E4 /* Debug */, + 3274F6111D9A633B005282E4 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 3274F5EF1D9A633A005282E4 /* Project object */; +} diff --git a/xcode/OLMKit/OLMAccount_Private.h b/xcode/OLMKit/OLMAccount_Private.h index 4eb3e2b..b8cf506 100644 --- a/xcode/OLMKit/OLMAccount_Private.h +++ b/xcode/OLMKit/OLMAccount_Private.h @@ -6,10 +6,10 @@ // // -@import olm; +#include "olm/olm.h" @interface OLMAccount() @property (nonatomic) OlmAccount *account; -@end \ No newline at end of file +@end diff --git a/xcode/OLMKit/OLMKit.h b/xcode/OLMKit/OLMKit.h index 745af43..954d6db 100644 --- a/xcode/OLMKit/OLMKit.h +++ b/xcode/OLMKit/OLMKit.h @@ -17,7 +17,7 @@ FOUNDATION_EXPORT const unsigned char OLMKitVersionString[]; // In this header, you should import all the public headers of your framework using statements like #import -#import "OLMAccount.h" -#import "OLMSession.h" -#import "OLMMessage.h" -#import "OLMUtility.h" \ No newline at end of file +#import +#import +#import +#import diff --git a/xcode/OLMKit/OLMSession.m b/xcode/OLMKit/OLMSession.m index 119079f..41aef7e 100644 --- a/xcode/OLMKit/OLMSession.m +++ b/xcode/OLMKit/OLMSession.m @@ -10,7 +10,7 @@ #import "OLMUtility.h" #import "OLMAccount_Private.h" #import "OLMSession_Private.h" -@import olm; +#include "olm/olm.h" @implementation OLMSession diff --git a/xcode/OLMKit/OLMSession_Private.h b/xcode/OLMKit/OLMSession_Private.h index d906b14..bd7d25d 100644 --- a/xcode/OLMKit/OLMSession_Private.h +++ b/xcode/OLMKit/OLMSession_Private.h @@ -6,11 +6,11 @@ // // -@import olm; +#include "olm/olm.h" @interface OLMSession() @property (nonatomic) OlmSession *session; @property (nonatomic, strong) OLMAccount *account; -@end \ No newline at end of file +@end diff --git a/xcode/OLMKitTests/Info.plist b/xcode/OLMKitTests/Info.plist index ba72822..6c6c23c 100644 --- a/xcode/OLMKitTests/Info.plist +++ b/xcode/OLMKitTests/Info.plist @@ -16,8 +16,6 @@ BNDL CFBundleShortVersionString 1.0 - CFBundleSignature - ???? CFBundleVersion 1 diff --git a/xcode/OLMKitTests/OLMKitTests.m b/xcode/OLMKitTests/OLMKitTests.m index c76d636..a7280f8 100644 --- a/xcode/OLMKitTests/OLMKitTests.m +++ b/xcode/OLMKitTests/OLMKitTests.m @@ -7,7 +7,7 @@ // #import -@import OLMKit; +#import @interface OLMKitTests : XCTestCase diff --git a/xcode/Podfile b/xcode/Podfile index 7bd8189..4c60dd3 100644 --- a/xcode/Podfile +++ b/xcode/Podfile @@ -1,6 +1,7 @@ -# Uncomment this line to define a global platform for your project -platform :ios, '8.0' -# Uncomment this line if you're using Swift -use_frameworks! +target "OLMKit" do +pod 'OLMKit', :path => '../OLMKit.podspec' +end -pod 'olm', :path => '../olm.podspec' \ No newline at end of file +target "OLMKitTests" do +pod 'OLMKit', :path => '../OLMKit.podspec' +end \ No newline at end of file diff --git a/xcode/Podfile.lock b/xcode/Podfile.lock index 4639dc0..b091109 100644 --- a/xcode/Podfile.lock +++ b/xcode/Podfile.lock @@ -1,14 +1,20 @@ PODS: - - olm (0.1.0) + - OLMKit (1.3.0): + - OLMKit/olmc (= 1.3.0) + - OLMKit/olmcpp (= 1.3.0) + - OLMKit/olmc (1.3.0) + - OLMKit/olmcpp (1.3.0) DEPENDENCIES: - - olm (from `../olm.podspec`) + - OLMKit (from `../OLMKit.podspec`) EXTERNAL SOURCES: - olm: - :path: "../olm.podspec" + OLMKit: + :path: ../OLMKit.podspec SPEC CHECKSUMS: - olm: ba8c1a7ca04486ec1ad958ec9feef73c0939ae27 + OLMKit: 49b73677a77988cc25e51d023f39a8a3e451cb23 -COCOAPODS: 0.39.0 +PODFILE CHECKSUM: 4e261dae61d833ec5585ced2473023b98909fd35 + +COCOAPODS: 1.0.1 diff --git a/xcode/README.rst b/xcode/README.rst new file mode 100644 index 0000000..db78e57 --- /dev/null +++ b/xcode/README.rst @@ -0,0 +1,22 @@ +OLMKit +====== + +OLMKit exposes an Objective-C wrapper to libolm. + +The original work by Chris Ballinger can be found at https://github.com/chrisballinger/OLMKit. + +Installation +------------ +You can embed OLMKit to your application project with CocoaPods. The pod for +the latest OLMKit release is:: + + pod 'OLMKit' + +Development +----------- +Run `pod install` and open `OLMKit.xcworkspace`. + +The project contains only tests files. The libolm and the Objective-C wrapper source files are loaded via the OLMKit CocoaPods pod. + +To add a new source file, add it to the file system and run `pod update` to make CocoaPods insert into OLMKit.xcworkspace. + diff --git a/xcode/olm.xcodeproj/project.pbxproj b/xcode/olm.xcodeproj/project.pbxproj deleted file mode 100644 index 6c6fa32..0000000 --- a/xcode/olm.xcodeproj/project.pbxproj +++ /dev/null @@ -1,561 +0,0 @@ -// !$*UTF8*$! -{ - archiveVersion = 1; - classes = { - }; - objectVersion = 46; - objects = { - -/* Begin PBXBuildFile section */ - D9401CDC1CBF10BD003DD078 /* OLMSession_Private.h in Headers */ = {isa = PBXBuildFile; fileRef = D9401CDB1CBF10BD003DD078 /* OLMSession_Private.h */; }; - D976E4411CB852E000F5C124 /* OLMKit.h in Headers */ = {isa = PBXBuildFile; fileRef = D976E4401CB852E000F5C124 /* OLMKit.h */; settings = {ATTRIBUTES = (Public, ); }; }; - D976E4481CB852E000F5C124 /* OLMKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D976E43E1CB852E000F5C124 /* OLMKit.framework */; }; - D976E44D1CB852E000F5C124 /* OLMKitTests.m in Sources */ = {isa = PBXBuildFile; fileRef = D976E44C1CB852E000F5C124 /* OLMKitTests.m */; }; - D976E4571CB8536500F5C124 /* OLMAccount.h in Headers */ = {isa = PBXBuildFile; fileRef = D976E4551CB8536500F5C124 /* OLMAccount.h */; settings = {ATTRIBUTES = (Public, ); }; }; - D976E4581CB8536500F5C124 /* OLMAccount.m in Sources */ = {isa = PBXBuildFile; fileRef = D976E4561CB8536500F5C124 /* OLMAccount.m */; }; - D976E45B1CB8538300F5C124 /* OLMSession.h in Headers */ = {isa = PBXBuildFile; fileRef = D976E4591CB8538300F5C124 /* OLMSession.h */; settings = {ATTRIBUTES = (Public, ); }; }; - D976E45C1CB8538300F5C124 /* OLMSession.m in Sources */ = {isa = PBXBuildFile; fileRef = D976E45A1CB8538300F5C124 /* OLMSession.m */; }; - D976E45F1CB8538E00F5C124 /* OLMUtility.h in Headers */ = {isa = PBXBuildFile; fileRef = D976E45D1CB8538E00F5C124 /* OLMUtility.h */; settings = {ATTRIBUTES = (Public, ); }; }; - D976E4601CB8538E00F5C124 /* OLMUtility.m in Sources */ = {isa = PBXBuildFile; fileRef = D976E45E1CB8538E00F5C124 /* OLMUtility.m */; }; - D976E4621CB860E200F5C124 /* OLMSerializable.h in Headers */ = {isa = PBXBuildFile; fileRef = D976E4611CB860E200F5C124 /* OLMSerializable.h */; settings = {ATTRIBUTES = (Public, ); }; }; - D976E4651CB8674900F5C124 /* OLMMessage.h in Headers */ = {isa = PBXBuildFile; fileRef = D976E4631CB8674900F5C124 /* OLMMessage.h */; settings = {ATTRIBUTES = (Public, ); }; }; - D976E4661CB8674900F5C124 /* OLMMessage.m in Sources */ = {isa = PBXBuildFile; fileRef = D976E4641CB8674900F5C124 /* OLMMessage.m */; }; - D976E4681CB8787D00F5C124 /* OLMAccount_Private.h in Headers */ = {isa = PBXBuildFile; fileRef = D976E4671CB8696100F5C124 /* OLMAccount_Private.h */; settings = {ATTRIBUTES = (Private, ); }; }; - DE4C8FA4266B10FC69A1C762 /* Pods.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 235C5A0B708438C11BCE552C /* Pods.framework */; }; -/* End PBXBuildFile section */ - -/* Begin PBXContainerItemProxy section */ - D976E4491CB852E000F5C124 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = D9679C4D1C87B53E007F67AA /* Project object */; - proxyType = 1; - remoteGlobalIDString = D976E43D1CB852E000F5C124; - remoteInfo = OLMKit; - }; -/* End PBXContainerItemProxy section */ - -/* Begin PBXFileReference section */ - 0A0809C67039D4BDCE9CE9AF /* Pods.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.debug.xcconfig; path = "Pods/Target Support Files/Pods/Pods.debug.xcconfig"; sourceTree = ""; }; - 235C5A0B708438C11BCE552C /* Pods.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods.framework; sourceTree = BUILT_PRODUCTS_DIR; }; - 81B8A7B31F3BA6548ACC45DE /* Pods.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.release.xcconfig; path = "Pods/Target Support Files/Pods/Pods.release.xcconfig"; sourceTree = ""; }; - D9401CDB1CBF10BD003DD078 /* OLMSession_Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OLMSession_Private.h; sourceTree = ""; }; - D976E43E1CB852E000F5C124 /* OLMKit.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = OLMKit.framework; sourceTree = BUILT_PRODUCTS_DIR; }; - D976E4401CB852E000F5C124 /* OLMKit.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = OLMKit.h; sourceTree = ""; }; - D976E4421CB852E000F5C124 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; - D976E4471CB852E000F5C124 /* OLMKitTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = OLMKitTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; - D976E44C1CB852E000F5C124 /* OLMKitTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = OLMKitTests.m; sourceTree = ""; }; - D976E44E1CB852E000F5C124 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; - D976E4551CB8536500F5C124 /* OLMAccount.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OLMAccount.h; sourceTree = ""; }; - D976E4561CB8536500F5C124 /* OLMAccount.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OLMAccount.m; sourceTree = ""; }; - D976E4591CB8538300F5C124 /* OLMSession.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OLMSession.h; sourceTree = ""; }; - D976E45A1CB8538300F5C124 /* OLMSession.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OLMSession.m; sourceTree = ""; }; - D976E45D1CB8538E00F5C124 /* OLMUtility.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OLMUtility.h; sourceTree = ""; }; - D976E45E1CB8538E00F5C124 /* OLMUtility.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OLMUtility.m; sourceTree = ""; }; - D976E4611CB860E200F5C124 /* OLMSerializable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OLMSerializable.h; sourceTree = ""; }; - D976E4631CB8674900F5C124 /* OLMMessage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OLMMessage.h; sourceTree = ""; }; - D976E4641CB8674900F5C124 /* OLMMessage.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OLMMessage.m; sourceTree = ""; }; - D976E4671CB8696100F5C124 /* OLMAccount_Private.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = OLMAccount_Private.h; sourceTree = ""; }; -/* End PBXFileReference section */ - -/* Begin PBXFrameworksBuildPhase section */ - D976E43A1CB852E000F5C124 /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - DE4C8FA4266B10FC69A1C762 /* Pods.framework in Frameworks */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - D976E4441CB852E000F5C124 /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - D976E4481CB852E000F5C124 /* OLMKit.framework in Frameworks */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXFrameworksBuildPhase section */ - -/* Begin PBXGroup section */ - C125031A628591D7E1C25FD8 /* Frameworks */ = { - isa = PBXGroup; - children = ( - 235C5A0B708438C11BCE552C /* Pods.framework */, - ); - name = Frameworks; - sourceTree = ""; - }; - D9679C4C1C87B53E007F67AA = { - isa = PBXGroup; - children = ( - D96991B7CDE3F0F8C3A52C54 /* Pods */, - D976E43F1CB852E000F5C124 /* OLMKit */, - D976E44B1CB852E000F5C124 /* OLMKitTests */, - C125031A628591D7E1C25FD8 /* Frameworks */, - D976E43E1CB852E000F5C124 /* OLMKit.framework */, - D976E4471CB852E000F5C124 /* OLMKitTests.xctest */, - ); - sourceTree = ""; - }; - D96991B7CDE3F0F8C3A52C54 /* Pods */ = { - isa = PBXGroup; - children = ( - 0A0809C67039D4BDCE9CE9AF /* Pods.debug.xcconfig */, - 81B8A7B31F3BA6548ACC45DE /* Pods.release.xcconfig */, - ); - name = Pods; - sourceTree = ""; - }; - D976E43F1CB852E000F5C124 /* OLMKit */ = { - isa = PBXGroup; - children = ( - D976E4631CB8674900F5C124 /* OLMMessage.h */, - D976E4641CB8674900F5C124 /* OLMMessage.m */, - D976E4401CB852E000F5C124 /* OLMKit.h */, - D976E4611CB860E200F5C124 /* OLMSerializable.h */, - D976E4551CB8536500F5C124 /* OLMAccount.h */, - D976E4671CB8696100F5C124 /* OLMAccount_Private.h */, - D976E4561CB8536500F5C124 /* OLMAccount.m */, - D976E4591CB8538300F5C124 /* OLMSession.h */, - D9401CDB1CBF10BD003DD078 /* OLMSession_Private.h */, - D976E45A1CB8538300F5C124 /* OLMSession.m */, - D976E45D1CB8538E00F5C124 /* OLMUtility.h */, - D976E45E1CB8538E00F5C124 /* OLMUtility.m */, - D976E4421CB852E000F5C124 /* Info.plist */, - ); - path = OLMKit; - sourceTree = ""; - }; - D976E44B1CB852E000F5C124 /* OLMKitTests */ = { - isa = PBXGroup; - children = ( - D976E44C1CB852E000F5C124 /* OLMKitTests.m */, - D976E44E1CB852E000F5C124 /* Info.plist */, - ); - path = OLMKitTests; - sourceTree = ""; - }; -/* End PBXGroup section */ - -/* Begin PBXHeadersBuildPhase section */ - D976E43B1CB852E000F5C124 /* Headers */ = { - isa = PBXHeadersBuildPhase; - buildActionMask = 2147483647; - files = ( - D9401CDC1CBF10BD003DD078 /* OLMSession_Private.h in Headers */, - D976E45B1CB8538300F5C124 /* OLMSession.h in Headers */, - D976E4681CB8787D00F5C124 /* OLMAccount_Private.h in Headers */, - D976E4651CB8674900F5C124 /* OLMMessage.h in Headers */, - D976E4621CB860E200F5C124 /* OLMSerializable.h in Headers */, - D976E45F1CB8538E00F5C124 /* OLMUtility.h in Headers */, - D976E4571CB8536500F5C124 /* OLMAccount.h in Headers */, - D976E4411CB852E000F5C124 /* OLMKit.h in Headers */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXHeadersBuildPhase section */ - -/* Begin PBXNativeTarget section */ - D976E43D1CB852E000F5C124 /* OLMKit */ = { - isa = PBXNativeTarget; - buildConfigurationList = D976E44F1CB852E000F5C124 /* Build configuration list for PBXNativeTarget "OLMKit" */; - buildPhases = ( - 5DFDEA7662CDB902F5544BBD /* Check Pods Manifest.lock */, - D976E4391CB852E000F5C124 /* Sources */, - D976E43A1CB852E000F5C124 /* Frameworks */, - D976E43B1CB852E000F5C124 /* Headers */, - D976E43C1CB852E000F5C124 /* Resources */, - DC41A6806320B8867B32F48B /* Copy Pods Resources */, - ); - buildRules = ( - ); - dependencies = ( - ); - name = OLMKit; - productName = OLMKit; - productReference = D976E43E1CB852E000F5C124 /* OLMKit.framework */; - productType = "com.apple.product-type.framework"; - }; - D976E4461CB852E000F5C124 /* OLMKitTests */ = { - isa = PBXNativeTarget; - buildConfigurationList = D976E4521CB852E000F5C124 /* Build configuration list for PBXNativeTarget "OLMKitTests" */; - buildPhases = ( - D976E4431CB852E000F5C124 /* Sources */, - D976E4441CB852E000F5C124 /* Frameworks */, - D976E4451CB852E000F5C124 /* Resources */, - ); - buildRules = ( - ); - dependencies = ( - D976E44A1CB852E000F5C124 /* PBXTargetDependency */, - ); - name = OLMKitTests; - productName = OLMKitTests; - productReference = D976E4471CB852E000F5C124 /* OLMKitTests.xctest */; - productType = "com.apple.product-type.bundle.unit-test"; - }; -/* End PBXNativeTarget section */ - -/* Begin PBXProject section */ - D9679C4D1C87B53E007F67AA /* Project object */ = { - isa = PBXProject; - attributes = { - LastUpgradeCheck = 0730; - TargetAttributes = { - D976E43D1CB852E000F5C124 = { - CreatedOnToolsVersion = 7.3; - }; - D976E4461CB852E000F5C124 = { - CreatedOnToolsVersion = 7.3; - }; - }; - }; - buildConfigurationList = D9679C501C87B53E007F67AA /* Build configuration list for PBXProject "olm" */; - compatibilityVersion = "Xcode 3.2"; - developmentRegion = English; - hasScannedForEncodings = 0; - knownRegions = ( - en, - ); - mainGroup = D9679C4C1C87B53E007F67AA; - productRefGroup = D9679C4C1C87B53E007F67AA; - projectDirPath = ""; - projectRoot = ""; - targets = ( - D976E43D1CB852E000F5C124 /* OLMKit */, - D976E4461CB852E000F5C124 /* OLMKitTests */, - ); - }; -/* End PBXProject section */ - -/* Begin PBXResourcesBuildPhase section */ - D976E43C1CB852E000F5C124 /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; - D976E4451CB852E000F5C124 /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXResourcesBuildPhase section */ - -/* Begin PBXShellScriptBuildPhase section */ - 5DFDEA7662CDB902F5544BBD /* Check Pods Manifest.lock */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - ); - name = "Check Pods Manifest.lock"; - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n"; - showEnvVarsInLog = 0; - }; - DC41A6806320B8867B32F48B /* Copy Pods Resources */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - ); - name = "Copy Pods Resources"; - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods/Pods-resources.sh\"\n"; - showEnvVarsInLog = 0; - }; -/* End PBXShellScriptBuildPhase section */ - -/* Begin PBXSourcesBuildPhase section */ - D976E4391CB852E000F5C124 /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - D976E4661CB8674900F5C124 /* OLMMessage.m in Sources */, - D976E4581CB8536500F5C124 /* OLMAccount.m in Sources */, - D976E45C1CB8538300F5C124 /* OLMSession.m in Sources */, - D976E4601CB8538E00F5C124 /* OLMUtility.m in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - D976E4431CB852E000F5C124 /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - D976E44D1CB852E000F5C124 /* OLMKitTests.m in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXSourcesBuildPhase section */ - -/* Begin PBXTargetDependency section */ - D976E44A1CB852E000F5C124 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = D976E43D1CB852E000F5C124 /* OLMKit */; - targetProxy = D976E4491CB852E000F5C124 /* PBXContainerItemProxy */; - }; -/* End PBXTargetDependency section */ - -/* Begin XCBuildConfiguration section */ - D9679C511C87B53E007F67AA /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ENABLE_TESTABILITY = YES; - ONLY_ACTIVE_ARCH = YES; - }; - name = Debug; - }; - D9679C521C87B53E007F67AA /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - }; - name = Release; - }; - D976E4501CB852E000F5C124 /* Debug */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = 0A0809C67039D4BDCE9CE9AF /* Pods.debug.xcconfig */; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_ANALYZER_NONNULL = YES; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_UNREACHABLE_CODE = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; - COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 1; - DEBUG_INFORMATION_FORMAT = dwarf; - DEFINES_MODULE = YES; - DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 1; - DYLIB_INSTALL_NAME_BASE = "@rpath"; - ENABLE_STRICT_OBJC_MSGSEND = YES; - ENABLE_TESTABILITY = YES; - GCC_C_LANGUAGE_STANDARD = gnu99; - GCC_DYNAMIC_NO_PIC = NO; - GCC_NO_COMMON_BLOCKS = YES; - GCC_OPTIMIZATION_LEVEL = 0; - GCC_PREPROCESSOR_DEFINITIONS = ( - "DEBUG=1", - "$(inherited)", - ); - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - INFOPLIST_FILE = OLMKit/Info.plist; - INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - IPHONEOS_DEPLOYMENT_TARGET = 9.3; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - MTL_ENABLE_DEBUG_INFO = YES; - ONLY_ACTIVE_ARCH = YES; - PRODUCT_BUNDLE_IDENTIFIER = io.ballinger.OLMKit; - PRODUCT_NAME = "$(TARGET_NAME)"; - SDKROOT = iphoneos; - SKIP_INSTALL = YES; - TARGETED_DEVICE_FAMILY = "1,2"; - VERSIONING_SYSTEM = "apple-generic"; - VERSION_INFO_PREFIX = ""; - }; - name = Debug; - }; - D976E4511CB852E000F5C124 /* Release */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = 81B8A7B31F3BA6548ACC45DE /* Pods.release.xcconfig */; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_ANALYZER_NONNULL = YES; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_UNREACHABLE_CODE = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; - COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 1; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - DEFINES_MODULE = YES; - DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 1; - DYLIB_INSTALL_NAME_BASE = "@rpath"; - ENABLE_NS_ASSERTIONS = NO; - ENABLE_STRICT_OBJC_MSGSEND = YES; - GCC_C_LANGUAGE_STANDARD = gnu99; - GCC_NO_COMMON_BLOCKS = YES; - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - INFOPLIST_FILE = OLMKit/Info.plist; - INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - IPHONEOS_DEPLOYMENT_TARGET = 9.3; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - MTL_ENABLE_DEBUG_INFO = NO; - PRODUCT_BUNDLE_IDENTIFIER = io.ballinger.OLMKit; - PRODUCT_NAME = "$(TARGET_NAME)"; - SDKROOT = iphoneos; - SKIP_INSTALL = YES; - TARGETED_DEVICE_FAMILY = "1,2"; - VALIDATE_PRODUCT = YES; - VERSIONING_SYSTEM = "apple-generic"; - VERSION_INFO_PREFIX = ""; - }; - name = Release; - }; - D976E4531CB852E000F5C124 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_ANALYZER_NONNULL = YES; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_UNREACHABLE_CODE = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; - COPY_PHASE_STRIP = NO; - DEBUG_INFORMATION_FORMAT = dwarf; - ENABLE_STRICT_OBJC_MSGSEND = YES; - ENABLE_TESTABILITY = YES; - GCC_C_LANGUAGE_STANDARD = gnu99; - GCC_DYNAMIC_NO_PIC = NO; - GCC_NO_COMMON_BLOCKS = YES; - GCC_OPTIMIZATION_LEVEL = 0; - GCC_PREPROCESSOR_DEFINITIONS = ( - "DEBUG=1", - "$(inherited)", - ); - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - INFOPLIST_FILE = OLMKitTests/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 9.3; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - MTL_ENABLE_DEBUG_INFO = YES; - ONLY_ACTIVE_ARCH = YES; - PRODUCT_BUNDLE_IDENTIFIER = io.ballinger.OLMKitTests; - PRODUCT_NAME = "$(TARGET_NAME)"; - SDKROOT = iphoneos; - }; - name = Debug; - }; - D976E4541CB852E000F5C124 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_ANALYZER_NONNULL = YES; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_UNREACHABLE_CODE = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; - COPY_PHASE_STRIP = NO; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - ENABLE_NS_ASSERTIONS = NO; - ENABLE_STRICT_OBJC_MSGSEND = YES; - GCC_C_LANGUAGE_STANDARD = gnu99; - GCC_NO_COMMON_BLOCKS = YES; - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - INFOPLIST_FILE = OLMKitTests/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 9.3; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - MTL_ENABLE_DEBUG_INFO = NO; - PRODUCT_BUNDLE_IDENTIFIER = io.ballinger.OLMKitTests; - PRODUCT_NAME = "$(TARGET_NAME)"; - SDKROOT = iphoneos; - VALIDATE_PRODUCT = YES; - }; - name = Release; - }; -/* End XCBuildConfiguration section */ - -/* Begin XCConfigurationList section */ - D9679C501C87B53E007F67AA /* Build configuration list for PBXProject "olm" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - D9679C511C87B53E007F67AA /* Debug */, - D9679C521C87B53E007F67AA /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - D976E44F1CB852E000F5C124 /* Build configuration list for PBXNativeTarget "OLMKit" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - D976E4501CB852E000F5C124 /* Debug */, - D976E4511CB852E000F5C124 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - D976E4521CB852E000F5C124 /* Build configuration list for PBXNativeTarget "OLMKitTests" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - D976E4531CB852E000F5C124 /* Debug */, - D976E4541CB852E000F5C124 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; -/* End XCConfigurationList section */ - }; - rootObject = D9679C4D1C87B53E007F67AA /* Project object */; -} diff --git a/xcode/olm.xcodeproj/xcshareddata/xcschemes/OLMKit.xcscheme b/xcode/olm.xcodeproj/xcshareddata/xcschemes/OLMKit.xcscheme deleted file mode 100644 index eee8c5e..0000000 --- a/xcode/olm.xcodeproj/xcshareddata/xcschemes/OLMKit.xcscheme +++ /dev/null @@ -1,99 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/xcode/olm.xcodeproj/xcshareddata/xcschemes/OLMKitTests.xcscheme b/xcode/olm.xcodeproj/xcshareddata/xcschemes/OLMKitTests.xcscheme deleted file mode 100644 index 300e62c..0000000 --- a/xcode/olm.xcodeproj/xcshareddata/xcschemes/OLMKitTests.xcscheme +++ /dev/null @@ -1,90 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/xcode/olm.xcworkspace/contents.xcworkspacedata b/xcode/olm.xcworkspace/contents.xcworkspacedata deleted file mode 100644 index 3c8fe35..0000000 --- a/xcode/olm.xcworkspace/contents.xcworkspacedata +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - -- cgit v1.2.3 From 103de505182e569bc811eac1e8ded216e5ae0908 Mon Sep 17 00:00:00 2001 From: manuroe Date: Wed, 28 Sep 2016 16:06:11 +0200 Subject: OLMKit: Implement missing [OLMAccount signMessage:] --- xcode/OLMKit/OLMAccount.m | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'xcode') diff --git a/xcode/OLMKit/OLMAccount.m b/xcode/OLMKit/OLMAccount.m index 4561a37..77fddac 100644 --- a/xcode/OLMKit/OLMAccount.m +++ b/xcode/OLMKit/OLMAccount.m @@ -92,6 +92,25 @@ return keysDictionary; } +- (NSString *)signMessage:(NSData *)messageData { + size_t signatureLength = olm_account_signature_length(_account); + uint8_t *signatureBytes = malloc(signatureLength); + if (!signatureBytes) { + return nil; + } + + size_t result = olm_account_sign(_account, messageData.bytes, messageData.length, signatureBytes, signatureLength); + if (result == olm_error()) { + const char *error = olm_account_last_error(_account); + NSLog(@"error signing message: %s", error); + free(signatureBytes); + return nil; + } + + NSData *signatureData = [NSData dataWithBytesNoCopy:signatureBytes length:signatureLength freeWhenDone:YES]; + return [[NSString alloc] initWithData:signatureData encoding:NSUTF8StringEncoding]; +} + - (NSDictionary*) oneTimeKeys { size_t otkLength = olm_account_one_time_keys_length(_account); uint8_t *otkBytes = malloc(otkLength); -- cgit v1.2.3 From f29eabde8b42cde1d5054df8977dd719099575ae Mon Sep 17 00:00:00 2001 From: manuroe Date: Wed, 28 Sep 2016 16:06:45 +0200 Subject: OLMKit: Use the same version as libolm --- xcode/OLMKit/OLMKit.h | 8 ++------ xcode/OLMKit/OLMKit.m | 28 ++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 6 deletions(-) create mode 100644 xcode/OLMKit/OLMKit.m (limited to 'xcode') diff --git a/xcode/OLMKit/OLMKit.h b/xcode/OLMKit/OLMKit.h index 954d6db..65fedc8 100644 --- a/xcode/OLMKit/OLMKit.h +++ b/xcode/OLMKit/OLMKit.h @@ -8,15 +8,11 @@ #import -//! Project version number for OLMKit. -FOUNDATION_EXPORT double OLMKitVersionNumber; - -//! Project version string for OLMKit. -FOUNDATION_EXPORT const unsigned char OLMKitVersionString[]; +//! Project version string for OLMKit, the same as libolm. +NSString *OLMKitVersionString(); // In this header, you should import all the public headers of your framework using statements like #import - #import #import #import diff --git a/xcode/OLMKit/OLMKit.m b/xcode/OLMKit/OLMKit.m new file mode 100644 index 0000000..0cd4ed5 --- /dev/null +++ b/xcode/OLMKit/OLMKit.m @@ -0,0 +1,28 @@ +/* + Copyright 2016 OpenMarket Ltd + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + +#import "OLMKit.h" + +#include "olm/olm.h" + +NSString *OLMKitVersionString() +{ + uint8_t major, minor, patch; + + olm_get_library_version(&major, &minor, &patch); + + return [NSString stringWithFormat:@"%tu.%tu.%tu", major, minor, patch]; +} -- cgit v1.2.3 From 45ecaaedd1eab582965f2cca8d2a04e6c906491b Mon Sep 17 00:00:00 2001 From: manuroe Date: Wed, 28 Sep 2016 16:07:39 +0200 Subject: OLMKit: Add [OLMUtility ed25519Verify] --- xcode/OLMKit/OLMUtility.h | 14 ++++++++++ xcode/OLMKit/OLMUtility.m | 66 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 80 insertions(+) (limited to 'xcode') diff --git a/xcode/OLMKit/OLMUtility.h b/xcode/OLMKit/OLMUtility.h index 8acbf40..eca9d3a 100644 --- a/xcode/OLMKit/OLMUtility.h +++ b/xcode/OLMKit/OLMUtility.h @@ -10,6 +10,20 @@ @interface OLMUtility : NSObject +/** + Verify an ed25519 signature. + + @param key the ed25519 key. + @param message the message which was signed. + @param signature the base64-encoded signature to be checked. + @param the result error if there is a problem with the verification. + If the key was too small then the message will be "OLM.INVALID_BASE64". + If the signature was invalid then the message will be "OLM.BAD_MESSAGE_MAC". + + @return YES if valid. + */ +- (BOOL)ed25519Verify:(NSString*)key message:(NSString*)message signature:(NSString*)signature error:(NSError**)error; + + (NSMutableData*) randomBytesOfLength:(NSUInteger)length; @end diff --git a/xcode/OLMKit/OLMUtility.m b/xcode/OLMKit/OLMUtility.m index 5dbe644..1553a81 100644 --- a/xcode/OLMKit/OLMUtility.m +++ b/xcode/OLMKit/OLMUtility.m @@ -8,8 +8,74 @@ #import "OLMUtility.h" +#include "olm/olm.h" + +@interface OLMUtility() + +@property (nonatomic) OlmUtility *utility; + +@end + @implementation OLMUtility +- (void) dealloc { + olm_clear_utility(_utility); + free(_utility); +} + +- (BOOL) initializeUtilityMemory { + size_t utilitySize = olm_utility_size(); + _utility = malloc(utilitySize); + NSParameterAssert(_utility != nil); + if (!_utility) { + return NO; + } + _utility = olm_utility(_utility); + NSParameterAssert(_utility != nil); + if (!_utility) { + return NO; + } + return YES; +} + +- (instancetype) init { + self = [super init]; + if (!self) { + return nil; + } + BOOL success = [self initializeUtilityMemory]; + if (!success) { + return nil; + } + return self; +} + +- (BOOL)ed25519Verify:(NSString *)key message:(NSString *)message signature:(NSString *)signature error:(NSError *__autoreleasing *)error { + + NSData *keyData = [key dataUsingEncoding:NSUTF8StringEncoding]; + NSData *messageData = [message dataUsingEncoding:NSUTF8StringEncoding]; + NSData *signatureData = [signature dataUsingEncoding:NSUTF8StringEncoding]; + + size_t result = olm_ed25519_verify(_utility, + keyData.bytes, keyData.length, + messageData.bytes, messageData.length, + signatureData.bytes, signatureData.length + ); + + if (result < 0) { + if (error) { + NSDictionary *userInfo = @{NSLocalizedFailureReasonErrorKey: [NSString stringWithUTF8String:olm_utility_last_error(_utility)]}; + + // @TODO + *error = [[NSError alloc] initWithDomain:@"OLMKitErrorDomain" code:0 userInfo:userInfo]; + } + return NO; + } + else { + return YES; + } +} + + (NSMutableData*) randomBytesOfLength:(NSUInteger)length { NSMutableData *randomData = [NSMutableData dataWithLength:length]; if (!randomData) { -- cgit v1.2.3 From 2ca67ace604962cb0d658d40515113ef99a51214 Mon Sep 17 00:00:00 2001 From: manuroe Date: Fri, 30 Sep 2016 08:16:58 +0200 Subject: OLMKit: OLMAccount: Replace a olm_session_last_error by olm_account_last_error --- xcode/OLMKit/OLMAccount.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'xcode') diff --git a/xcode/OLMKit/OLMAccount.m b/xcode/OLMKit/OLMAccount.m index 77fddac..d0f82a8 100644 --- a/xcode/OLMKit/OLMAccount.m +++ b/xcode/OLMKit/OLMAccount.m @@ -150,7 +150,7 @@ } size_t result = olm_remove_one_time_keys(self.account, session.session); if (result == olm_error()) { - const char *error = olm_session_last_error(session.session); + const char *error = olm_account_last_error(_account); NSAssert(NO, @"olm_remove_one_time_keys error: %s", error); return NO; } -- cgit v1.2.3 From 2bd912990fb82bf3cdd54a9268143d8b3a2889ef Mon Sep 17 00:00:00 2001 From: manuroe Date: Mon, 10 Oct 2016 17:10:51 +0200 Subject: OLMKit: Add megolm api: OLMInboundGroupSession and OLMOutboundGroupSession --- xcode/OLMKit/OLMInboundGroupSession.h | 29 +++++ xcode/OLMKit/OLMInboundGroupSession.m | 198 +++++++++++++++++++++++++++++++ xcode/OLMKit/OLMKit.h | 2 + xcode/OLMKit/OLMOutboundGroupSession.h | 31 +++++ xcode/OLMKit/OLMOutboundGroupSession.m | 205 +++++++++++++++++++++++++++++++++ xcode/OLMKitTests/OLMKitGroupTests.m | 39 +++++++ 6 files changed, 504 insertions(+) create mode 100644 xcode/OLMKit/OLMInboundGroupSession.h create mode 100644 xcode/OLMKit/OLMInboundGroupSession.m create mode 100644 xcode/OLMKit/OLMOutboundGroupSession.h create mode 100644 xcode/OLMKit/OLMOutboundGroupSession.m create mode 100644 xcode/OLMKitTests/OLMKitGroupTests.m (limited to 'xcode') diff --git a/xcode/OLMKit/OLMInboundGroupSession.h b/xcode/OLMKit/OLMInboundGroupSession.h new file mode 100644 index 0000000..a507490 --- /dev/null +++ b/xcode/OLMKit/OLMInboundGroupSession.h @@ -0,0 +1,29 @@ +/* + Copyright 2016 OpenMarket Ltd + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + +#import +#import "OLMSerializable.h" + +@interface OLMInboundGroupSession : NSObject + +- (instancetype) initInboundGroupSessionWithSessionKey:(NSString*)sessionKey; + +- (NSString*)sessionIdentifier; + +/** base64 ciphertext -> UTF-8 plaintext */ +- (NSString*)decryptMessage:(NSString*)message; + +@end diff --git a/xcode/OLMKit/OLMInboundGroupSession.m b/xcode/OLMKit/OLMInboundGroupSession.m new file mode 100644 index 0000000..d95d1ab --- /dev/null +++ b/xcode/OLMKit/OLMInboundGroupSession.m @@ -0,0 +1,198 @@ +/* + Copyright 2016 OpenMarket Ltd + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + +#import "OLMInboundGroupSession.h" + +#import "OLMUtility.h" +#include "olm/olm.h" + +@interface OLMInboundGroupSession () +{ + OlmInboundGroupSession *session; +} +@end + + +@implementation OLMInboundGroupSession + +- (void)dealloc { + olm_clear_inbound_group_session(session); + free(session); +} + +- (instancetype)init { + self = [super init]; + if (self) + { + session = malloc(olm_inbound_group_session_size()); + if (session) { + session = olm_inbound_group_session(session); + } + + if (!session) { + return nil; + } + } + return self; +} + +- (instancetype)initInboundGroupSessionWithSessionKey:(NSString *)sessionKey { + self = [self init]; + if (self) { + NSData *sessionKeyData = [sessionKey dataUsingEncoding:NSUTF8StringEncoding]; + size_t result = olm_init_inbound_group_session(session, sessionKeyData.bytes, sessionKeyData.length); + if (result == olm_error()) { + const char *error = olm_inbound_group_session_last_error(session); + NSAssert(NO, @"olm_init_inbound_group_session error: %s", error); + return nil; + } + } + return self; +} + +- (NSString *)sessionIdentifier { + size_t length = olm_inbound_group_session_id_length(session); + NSMutableData *idData = [NSMutableData dataWithLength:length]; + if (!idData) { + return nil; + } + size_t result = olm_inbound_group_session_id(session, idData.mutableBytes, idData.length); + if (result == olm_error()) { + const char *error = olm_inbound_group_session_last_error(session); + NSAssert(NO, @"olm_inbound_group_session_id error: %s", error); + return nil; + } + NSString *idString = [[NSString alloc] initWithData:idData encoding:NSUTF8StringEncoding]; + return idString; +} + +- (NSString *)decryptMessage:(NSString *)message +{ + NSParameterAssert(message != nil); + NSData *messageData = [message dataUsingEncoding:NSUTF8StringEncoding]; + if (!messageData) { + return nil; + } + NSMutableData *mutMessage = messageData.mutableCopy; + size_t maxPlaintextLength = olm_group_decrypt_max_plaintext_length(session, mutMessage.mutableBytes, mutMessage.length); + if (maxPlaintextLength == olm_error()) { + const char *error = olm_inbound_group_session_last_error(session); + NSAssert(NO, @"olm_group_decrypt_max_plaintext_length error: %s", error); + return nil; + } + // message buffer is destroyed by olm_group_decrypt_max_plaintext_length + mutMessage = messageData.mutableCopy; + NSMutableData *plaintextData = [NSMutableData dataWithLength:maxPlaintextLength]; + size_t plaintextLength = olm_group_decrypt(session, mutMessage.mutableBytes, mutMessage.length, plaintextData.mutableBytes, plaintextData.length); + if (plaintextLength == olm_error()) { + const char *error = olm_inbound_group_session_last_error(session); + NSAssert(NO, @"olm_group_decrypt error: %s", error); + return nil; + } + plaintextData.length = plaintextLength; + NSString *plaintext = [[NSString alloc] initWithData:plaintextData encoding:NSUTF8StringEncoding]; + return plaintext; +} + + +#pragma mark OLMSerializable + +/** Initializes from encrypted serialized data. Will throw error if invalid key or invalid base64. */ +- (instancetype) initWithSerializedData:(NSString *)serializedData key:(NSData *)key error:(NSError *__autoreleasing *)error { + self = [self init]; + if (!self) { + return nil; + } + NSParameterAssert(key.length > 0); + NSParameterAssert(serializedData.length > 0); + if (key.length == 0 || serializedData.length == 0) { + if (error) { + *error = [NSError errorWithDomain:@"org.matrix.olm" code:0 userInfo:@{NSLocalizedDescriptionKey: @"Bad length."}]; + } + return nil; + } + NSMutableData *pickle = [serializedData dataUsingEncoding:NSUTF8StringEncoding].mutableCopy; + size_t result = olm_unpickle_inbound_group_session(session, key.bytes, key.length, pickle.mutableBytes, pickle.length); + if (result == olm_error()) { + const char *olm_error = olm_inbound_group_session_last_error(session); + NSString *errorString = [NSString stringWithUTF8String:olm_error]; + if (error && errorString) { + *error = [NSError errorWithDomain:@"org.matrix.olm" code:0 userInfo:@{NSLocalizedDescriptionKey: errorString}]; + } + return nil; + } + return self; +} + +/** Serializes and encrypts object data, outputs base64 blob */ +- (NSString*) serializeDataWithKey:(NSData*)key error:(NSError**)error { + NSParameterAssert(key.length > 0); + size_t length = olm_pickle_inbound_group_session_length(session); + NSMutableData *pickled = [NSMutableData dataWithLength:length]; + size_t result = olm_pickle_inbound_group_session(session, key.bytes, key.length, pickled.mutableBytes, pickled.length); + if (result == olm_error()) { + const char *olm_error = olm_inbound_group_session_last_error(session); + NSString *errorString = [NSString stringWithUTF8String:olm_error]; + if (error && errorString) { + *error = [NSError errorWithDomain:@"org.matrix.olm" code:0 userInfo:@{NSLocalizedDescriptionKey: errorString}]; + } + return nil; + } + NSString *pickleString = [[NSString alloc] initWithData:pickled encoding:NSUTF8StringEncoding]; + return pickleString; +} + +#pragma mark NSSecureCoding + ++ (BOOL) supportsSecureCoding { + return YES; +} + +#pragma mark NSCoding + +- (id)initWithCoder:(NSCoder *)decoder { + NSString *version = [decoder decodeObjectOfClass:[NSString class] forKey:@"version"]; + + NSError *error = nil; + + if ([version isEqualToString:@"1"]) { + NSString *pickle = [decoder decodeObjectOfClass:[NSString class] forKey:@"pickle"]; + NSData *key = [decoder decodeObjectOfClass:[NSData class] forKey:@"key"]; + + self = [self initWithSerializedData:pickle key:key error:&error]; + } + + NSParameterAssert(error == nil); + NSParameterAssert(self != nil); + if (!self) { + return nil; + } + + return self; +} + +- (void)encodeWithCoder:(NSCoder *)encoder { + NSData *key = [OLMUtility randomBytesOfLength:32]; + NSError *error = nil; + NSString *pickle = [self serializeDataWithKey:key error:&error]; + NSParameterAssert(pickle.length > 0 && error == nil); + + [encoder encodeObject:pickle forKey:@"pickle"]; + [encoder encodeObject:key forKey:@"key"]; + [encoder encodeObject:@"1" forKey:@"version"]; +} + +@end diff --git a/xcode/OLMKit/OLMKit.h b/xcode/OLMKit/OLMKit.h index 65fedc8..3865e74 100644 --- a/xcode/OLMKit/OLMKit.h +++ b/xcode/OLMKit/OLMKit.h @@ -17,3 +17,5 @@ NSString *OLMKitVersionString(); #import #import #import +#import +#import diff --git a/xcode/OLMKit/OLMOutboundGroupSession.h b/xcode/OLMKit/OLMOutboundGroupSession.h new file mode 100644 index 0000000..e7a8a91 --- /dev/null +++ b/xcode/OLMKit/OLMOutboundGroupSession.h @@ -0,0 +1,31 @@ +/* + Copyright 2016 OpenMarket Ltd + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + +#import +#import "OLMSerializable.h" + +@interface OLMOutboundGroupSession : NSObject + +- (instancetype) initOutboundGroupSession; + +- (NSString*)sessionIdentifier; +- (NSUInteger)messageIndex; +- (NSString*)sessionKey; + +/** UTF-8 plaintext -> base64 ciphertext */ +- (NSString*)encryptMessage:(NSString*)message; + +@end diff --git a/xcode/OLMKit/OLMOutboundGroupSession.m b/xcode/OLMKit/OLMOutboundGroupSession.m new file mode 100644 index 0000000..c86fa9f --- /dev/null +++ b/xcode/OLMKit/OLMOutboundGroupSession.m @@ -0,0 +1,205 @@ +/* + Copyright 2016 OpenMarket Ltd + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + +#import "OLMOutboundGroupSession.h" + +#import "OLMUtility.h" +#include "olm/olm.h" + +@interface OLMOutboundGroupSession () +{ + OlmOutboundGroupSession *session; +} +@end + +@implementation OLMOutboundGroupSession + +- (void)dealloc { + olm_clear_outbound_group_session(session); + free(session); +} + +- (instancetype)init { + self = [super init]; + if (self) + { + session = malloc(olm_outbound_group_session_size()); + if (session) { + session = olm_outbound_group_session(session); + } + + if (!session) { + return nil; + } + } + return self; +} + +- (instancetype)initOutboundGroupSession { + self = [self init]; + if (self) { + NSMutableData *random = [OLMUtility randomBytesOfLength:olm_init_outbound_group_session_random_length(session)]; + + size_t result = olm_init_outbound_group_session(session, random.mutableBytes, random.length); + if (result == olm_error()) { + const char *error = olm_outbound_group_session_last_error(session); + NSAssert(NO, @"olm_init_outbound_group_session error: %s", error); + return nil; + } + } + return self; +} + +- (NSString *)sessionIdentifier { + size_t length = olm_outbound_group_session_id_length(session); + NSMutableData *idData = [NSMutableData dataWithLength:length]; + if (!idData) { + return nil; + } + size_t result = olm_outbound_group_session_id(session, idData.mutableBytes, idData.length); + if (result == olm_error()) { + const char *error = olm_outbound_group_session_last_error(session); + NSAssert(NO, @"olm_outbound_group_session_id error: %s", error); + return nil; + } + NSString *idString = [[NSString alloc] initWithData:idData encoding:NSUTF8StringEncoding]; + return idString; +} + +- (NSUInteger)messageIndex { + return olm_outbound_group_session_message_index(session); +} + +- (NSString *)sessionKey { + size_t length = olm_outbound_group_session_key_length(session); + NSMutableData *sessionKeyData = [NSMutableData dataWithLength:length]; + if (!sessionKeyData) { + return nil; + } + size_t result = olm_outbound_group_session_key(session, sessionKeyData.mutableBytes, sessionKeyData.length); + if (result == olm_error()) { + const char *error = olm_outbound_group_session_last_error(session); + NSAssert(NO, @"olm_outbound_group_session_key error: %s", error); + return nil; + } + NSString *sessionKey = [[NSString alloc] initWithData:sessionKeyData encoding:NSUTF8StringEncoding]; + return sessionKey; +} + +- (NSString *)encryptMessage:(NSString *)message { + NSData *plaintextData = [message dataUsingEncoding:NSUTF8StringEncoding]; + size_t ciphertextLength = olm_group_encrypt_message_length(session, plaintextData.length); + NSMutableData *ciphertext = [NSMutableData dataWithLength:ciphertextLength]; + if (!ciphertext) { + return nil; + } + size_t result = olm_group_encrypt(session, plaintextData.bytes, plaintextData.length, ciphertext.mutableBytes, ciphertext.length); + if (result == olm_error()) { + const char *error = olm_outbound_group_session_last_error(session); + NSAssert(NO, @"olm_group_encrypt error: %s", error); + return nil; + } + return [[NSString alloc] initWithData:ciphertext encoding:NSUTF8StringEncoding]; +} + +#pragma mark OLMSerializable + +/** Initializes from encrypted serialized data. Will throw error if invalid key or invalid base64. */ +- (instancetype) initWithSerializedData:(NSString *)serializedData key:(NSData *)key error:(NSError *__autoreleasing *)error { + self = [self init]; + if (!self) { + return nil; + } + NSParameterAssert(key.length > 0); + NSParameterAssert(serializedData.length > 0); + if (key.length == 0 || serializedData.length == 0) { + if (error) { + *error = [NSError errorWithDomain:@"org.matrix.olm" code:0 userInfo:@{NSLocalizedDescriptionKey: @"Bad length."}]; + } + return nil; + } + NSMutableData *pickle = [serializedData dataUsingEncoding:NSUTF8StringEncoding].mutableCopy; + size_t result = olm_unpickle_outbound_group_session(session, key.bytes, key.length, pickle.mutableBytes, pickle.length); + if (result == olm_error()) { + const char *olm_error = olm_outbound_group_session_last_error(session); + NSString *errorString = [NSString stringWithUTF8String:olm_error]; + if (error && errorString) { + *error = [NSError errorWithDomain:@"org.matrix.olm" code:0 userInfo:@{NSLocalizedDescriptionKey: errorString}]; + } + return nil; + } + return self; +} + +/** Serializes and encrypts object data, outputs base64 blob */ +- (NSString*) serializeDataWithKey:(NSData*)key error:(NSError**)error { + NSParameterAssert(key.length > 0); + size_t length = olm_pickle_outbound_group_session_length(session); + NSMutableData *pickled = [NSMutableData dataWithLength:length]; + size_t result = olm_pickle_outbound_group_session(session, key.bytes, key.length, pickled.mutableBytes, pickled.length); + if (result == olm_error()) { + const char *olm_error = olm_outbound_group_session_last_error(session); + NSString *errorString = [NSString stringWithUTF8String:olm_error]; + if (error && errorString) { + *error = [NSError errorWithDomain:@"org.matrix.olm" code:0 userInfo:@{NSLocalizedDescriptionKey: errorString}]; + } + return nil; + } + NSString *pickleString = [[NSString alloc] initWithData:pickled encoding:NSUTF8StringEncoding]; + return pickleString; +} + +#pragma mark NSSecureCoding + ++ (BOOL) supportsSecureCoding { + return YES; +} + +#pragma mark NSCoding + +- (id)initWithCoder:(NSCoder *)decoder { + NSString *version = [decoder decodeObjectOfClass:[NSString class] forKey:@"version"]; + + NSError *error = nil; + + if ([version isEqualToString:@"1"]) { + NSString *pickle = [decoder decodeObjectOfClass:[NSString class] forKey:@"pickle"]; + NSData *key = [decoder decodeObjectOfClass:[NSData class] forKey:@"key"]; + + self = [self initWithSerializedData:pickle key:key error:&error]; + } + + NSParameterAssert(error == nil); + NSParameterAssert(self != nil); + if (!self) { + return nil; + } + + return self; +} + +- (void)encodeWithCoder:(NSCoder *)encoder { + NSData *key = [OLMUtility randomBytesOfLength:32]; + NSError *error = nil; + NSString *pickle = [self serializeDataWithKey:key error:&error]; + NSParameterAssert(pickle.length > 0 && error == nil); + + [encoder encodeObject:pickle forKey:@"pickle"]; + [encoder encodeObject:key forKey:@"key"]; + [encoder encodeObject:@"1" forKey:@"version"]; +} + +@end diff --git a/xcode/OLMKitTests/OLMKitGroupTests.m b/xcode/OLMKitTests/OLMKitGroupTests.m new file mode 100644 index 0000000..bcf83ef --- /dev/null +++ b/xcode/OLMKitTests/OLMKitGroupTests.m @@ -0,0 +1,39 @@ +// +// OLMKitGroupTests.m +// OLMKit +// +// Created by Emmanuel ROHEE on 10/10/16. +// Copyright © 2016 matrix.org. All rights reserved. +// + +#import + +@interface OLMKitGroupTests : XCTestCase + +@end + +@implementation OLMKitGroupTests + +- (void)setUp { + [super setUp]; + // Put setup code here. This method is called before the invocation of each test method in the class. +} + +- (void)tearDown { + // Put teardown code here. This method is called after the invocation of each test method in the class. + [super tearDown]; +} + +- (void)testExample { + // This is an example of a functional test case. + // Use XCTAssert and related functions to verify your tests produce the correct results. +} + +- (void)testPerformanceExample { + // This is an example of a performance test case. + [self measureBlock:^{ + // Put the code you want to measure the time of here. + }]; +} + +@end -- cgit v1.2.3 From 7ae6410f3714cb56d337213fb47afddbb5935cf9 Mon Sep 17 00:00:00 2001 From: manuroe Date: Mon, 10 Oct 2016 18:00:54 +0200 Subject: OLMKit: Add tests for OLMInboundGroupSession and OLMOutboundGroupSession --- xcode/OLMKit.xcodeproj/project.pbxproj | 4 ++ xcode/OLMKitTests/OLMKitGroupTests.m | 76 +++++++++++++++++++++++++++------- 2 files changed, 65 insertions(+), 15 deletions(-) (limited to 'xcode') diff --git a/xcode/OLMKit.xcodeproj/project.pbxproj b/xcode/OLMKit.xcodeproj/project.pbxproj index b50341b..fa02539 100644 --- a/xcode/OLMKit.xcodeproj/project.pbxproj +++ b/xcode/OLMKit.xcodeproj/project.pbxproj @@ -10,6 +10,7 @@ 3274F6021D9A633A005282E4 /* OLMKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3274F5F81D9A633A005282E4 /* OLMKit.framework */; }; 3274F6071D9A633A005282E4 /* OLMKitTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 3274F6061D9A633A005282E4 /* OLMKitTests.m */; }; 3274F6131D9A698E005282E4 /* OLMKit.h in Headers */ = {isa = PBXBuildFile; fileRef = 3274F6121D9A698E005282E4 /* OLMKit.h */; }; + 32A151311DABDD4300400192 /* OLMKitGroupTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 32A151301DABDD4300400192 /* OLMKitGroupTests.m */; }; 7DBAD311AEA85CF6DB80DCFA /* libPods-OLMKitTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 7123FABE917D0FB140E036B7 /* libPods-OLMKitTests.a */; }; D667051A0BA47E17CCC4E5D7 /* libPods-OLMKit.a in Frameworks */ = {isa = PBXBuildFile; fileRef = F2F22FE8F173AF845B882805 /* libPods-OLMKit.a */; }; /* End PBXBuildFile section */ @@ -32,6 +33,7 @@ 3274F6061D9A633A005282E4 /* OLMKitTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = OLMKitTests.m; sourceTree = ""; }; 3274F6081D9A633A005282E4 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 3274F6121D9A698E005282E4 /* OLMKit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OLMKit.h; sourceTree = ""; }; + 32A151301DABDD4300400192 /* OLMKitGroupTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OLMKitGroupTests.m; sourceTree = ""; }; 7123FABE917D0FB140E036B7 /* libPods-OLMKitTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-OLMKitTests.a"; sourceTree = BUILT_PRODUCTS_DIR; }; 875BA7A520258EA15A31DD82 /* Pods-OLMKitTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-OLMKitTests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-OLMKitTests/Pods-OLMKitTests.debug.xcconfig"; sourceTree = ""; }; D48E486DAE1F59F4F7EA8C25 /* Pods-OLMKitTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-OLMKitTests.release.xcconfig"; path = "Pods/Target Support Files/Pods-OLMKitTests/Pods-OLMKitTests.release.xcconfig"; sourceTree = ""; }; @@ -104,6 +106,7 @@ isa = PBXGroup; children = ( 3274F6061D9A633A005282E4 /* OLMKitTests.m */, + 32A151301DABDD4300400192 /* OLMKitGroupTests.m */, 3274F6081D9A633A005282E4 /* Info.plist */, ); path = OLMKitTests; @@ -318,6 +321,7 @@ buildActionMask = 2147483647; files = ( 3274F6071D9A633A005282E4 /* OLMKitTests.m in Sources */, + 32A151311DABDD4300400192 /* OLMKitGroupTests.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/xcode/OLMKitTests/OLMKitGroupTests.m b/xcode/OLMKitTests/OLMKitGroupTests.m index bcf83ef..9f5ad10 100644 --- a/xcode/OLMKitTests/OLMKitGroupTests.m +++ b/xcode/OLMKitTests/OLMKitGroupTests.m @@ -1,13 +1,25 @@ -// -// OLMKitGroupTests.m -// OLMKit -// -// Created by Emmanuel ROHEE on 10/10/16. -// Copyright © 2016 matrix.org. All rights reserved. -// +/* + Copyright 2016 OpenMarket Ltd + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ #import +#import + +#include "olm/olm.h" + @interface OLMKitGroupTests : XCTestCase @end @@ -24,16 +36,50 @@ [super tearDown]; } -- (void)testExample { - // This is an example of a functional test case. - // Use XCTAssert and related functions to verify your tests produce the correct results. +- (void)testAliceAndBob { + + OLMOutboundGroupSession *aliceSession = [[OLMOutboundGroupSession alloc] initOutboundGroupSession]; + XCTAssertGreaterThan(aliceSession.sessionIdentifier.length, 0); + XCTAssertGreaterThan(aliceSession.sessionKey.length, 0); + XCTAssertEqual(aliceSession.messageIndex, 0); + + // Store the session key before starting encrypting + NSString *sessionKey = aliceSession.sessionKey; + + NSString *message = @"Hello!"; + NSString *aliceToBobMsg = [aliceSession encryptMessage:message]; + + XCTAssertEqual(aliceSession.messageIndex, 1); + XCTAssertGreaterThanOrEqual(aliceToBobMsg.length, 0); + + OLMInboundGroupSession *bobSession = [[OLMInboundGroupSession alloc] initInboundGroupSessionWithSessionKey:sessionKey]; + XCTAssertEqualObjects(aliceSession.sessionIdentifier, bobSession.sessionIdentifier); + + NSString *plaintext = [bobSession decryptMessage:aliceToBobMsg]; + XCTAssertEqualObjects(message, plaintext); +} + +- (void)testOutboundGroupSessionSerialization { + + OLMOutboundGroupSession *aliceSession = [[OLMOutboundGroupSession alloc] initOutboundGroupSession]; + + NSData *aliceData = [NSKeyedArchiver archivedDataWithRootObject:aliceSession]; + OLMOutboundGroupSession *aliceSession2 = [NSKeyedUnarchiver unarchiveObjectWithData:aliceData]; + + XCTAssertEqualObjects(aliceSession2.sessionKey, aliceSession.sessionKey); + XCTAssertEqualObjects(aliceSession2.sessionIdentifier, aliceSession.sessionIdentifier); } -- (void)testPerformanceExample { - // This is an example of a performance test case. - [self measureBlock:^{ - // Put the code you want to measure the time of here. - }]; +- (void)testInboundGroupSessionSerialization { + + OLMOutboundGroupSession *aliceSession = [[OLMOutboundGroupSession alloc] initOutboundGroupSession]; + + OLMInboundGroupSession *bobSession = [[OLMInboundGroupSession alloc] initInboundGroupSessionWithSessionKey:aliceSession.sessionKey]; + + NSData *bobData = [NSKeyedArchiver archivedDataWithRootObject:bobSession]; + OLMInboundGroupSession *bobSession2 = [NSKeyedUnarchiver unarchiveObjectWithData:bobData]; + + XCTAssertEqualObjects(bobSession2.sessionIdentifier, aliceSession.sessionIdentifier); } @end -- cgit v1.2.3 From 3cb01fd27971a6f8c5d76fddb8676ef76c636a23 Mon Sep 17 00:00:00 2001 From: manuroe Date: Tue, 11 Oct 2016 16:54:56 +0200 Subject: OLMKit: Fixed typo in test --- xcode/OLMKitTests/OLMKitTests.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'xcode') diff --git a/xcode/OLMKitTests/OLMKitTests.m b/xcode/OLMKitTests/OLMKitTests.m index a7280f8..5459c85 100644 --- a/xcode/OLMKitTests/OLMKitTests.m +++ b/xcode/OLMKitTests/OLMKitTests.m @@ -106,7 +106,7 @@ OLMAccount *bob2 = [NSKeyedUnarchiver unarchiveObjectWithData:bobData]; NSDictionary *bobIdKeys2 = bob2.identityKeys; - NSDictionary *bobOneTimeKeys2 = bob.oneTimeKeys; + NSDictionary *bobOneTimeKeys2 = bob2.oneTimeKeys; XCTAssertEqualObjects(bobIdKeys, bobIdKeys2); XCTAssertEqualObjects(bobOneTimeKeys, bobOneTimeKeys2); -- cgit v1.2.3 From d1060af8f0dec312447567cce0bc812c82b7343f Mon Sep 17 00:00:00 2001 From: manuroe Date: Thu, 13 Oct 2016 16:10:00 +0200 Subject: OLMKit: Renamed [OLMAccount markKeysAsPublished] into [OLMAccount markOneTimeKeysAsPublished] and implemented it --- xcode/OLMKit/OLMAccount.h | 2 +- xcode/OLMKit/OLMAccount.m | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) (limited to 'xcode') diff --git a/xcode/OLMKit/OLMAccount.h b/xcode/OLMKit/OLMAccount.h index a2923f9..382be31 100644 --- a/xcode/OLMKit/OLMAccount.h +++ b/xcode/OLMKit/OLMAccount.h @@ -28,7 +28,7 @@ - (BOOL) removeOneTimeKeysForSession:(OLMSession*)session; /** Marks the current set of one time keys as being published. */ -- (void) markKeysAsPublished; +- (void) markOneTimeKeysAsPublished; /** The largest number of one time keys this account can store. */ - (NSUInteger) maxOneTimeKeys; diff --git a/xcode/OLMKit/OLMAccount.m b/xcode/OLMKit/OLMAccount.m index d0f82a8..085b487 100644 --- a/xcode/OLMKit/OLMAccount.m +++ b/xcode/OLMKit/OLMAccount.m @@ -157,6 +157,11 @@ return YES; } +- (void)markOneTimeKeysAsPublished +{ + olm_account_mark_keys_as_published(self.account); +} + #pragma mark OLMSerializable /** Initializes from encrypted serialized data. Will throw error if invalid key or invalid base64. */ -- cgit v1.2.3 From 4a2aac5800dacb3de935f6594e4d213087cb7cb5 Mon Sep 17 00:00:00 2001 From: manuroe Date: Fri, 14 Oct 2016 15:57:12 +0200 Subject: OLMKit: Add signature tests --- xcode/OLMKit/OLMUtility.h | 4 ++-- xcode/OLMKit/OLMUtility.m | 7 +++---- xcode/OLMKitTests/OLMKitTests.m | 20 ++++++++++++++++++++ 3 files changed, 25 insertions(+), 6 deletions(-) (limited to 'xcode') diff --git a/xcode/OLMKit/OLMUtility.h b/xcode/OLMKit/OLMUtility.h index eca9d3a..a8a3743 100644 --- a/xcode/OLMKit/OLMUtility.h +++ b/xcode/OLMKit/OLMUtility.h @@ -13,16 +13,16 @@ /** Verify an ed25519 signature. + @param signature the base64-encoded signature to be checked. @param key the ed25519 key. @param message the message which was signed. - @param signature the base64-encoded signature to be checked. @param the result error if there is a problem with the verification. If the key was too small then the message will be "OLM.INVALID_BASE64". If the signature was invalid then the message will be "OLM.BAD_MESSAGE_MAC". @return YES if valid. */ -- (BOOL)ed25519Verify:(NSString*)key message:(NSString*)message signature:(NSString*)signature error:(NSError**)error; +- (BOOL)verifyEd25519Signature:(NSString*)signature key:(NSString*)key message:(NSData*)message error:(NSError**)error; + (NSMutableData*) randomBytesOfLength:(NSUInteger)length; diff --git a/xcode/OLMKit/OLMUtility.m b/xcode/OLMKit/OLMUtility.m index 1553a81..041da2f 100644 --- a/xcode/OLMKit/OLMUtility.m +++ b/xcode/OLMKit/OLMUtility.m @@ -50,19 +50,18 @@ return self; } -- (BOOL)ed25519Verify:(NSString *)key message:(NSString *)message signature:(NSString *)signature error:(NSError *__autoreleasing *)error { +- (BOOL)verifyEd25519Signature:(NSString*)signature key:(NSString*)key message:(NSData*)message error:(NSError**)error { NSData *keyData = [key dataUsingEncoding:NSUTF8StringEncoding]; - NSData *messageData = [message dataUsingEncoding:NSUTF8StringEncoding]; NSData *signatureData = [signature dataUsingEncoding:NSUTF8StringEncoding]; size_t result = olm_ed25519_verify(_utility, keyData.bytes, keyData.length, - messageData.bytes, messageData.length, + message.bytes, message.length, signatureData.bytes, signatureData.length ); - if (result < 0) { + if (result < 0 || result == (size_t)-1) { if (error) { NSDictionary *userInfo = @{NSLocalizedFailureReasonErrorKey: [NSString stringWithUTF8String:olm_utility_last_error(_utility)]}; diff --git a/xcode/OLMKitTests/OLMKitTests.m b/xcode/OLMKitTests/OLMKitTests.m index 5459c85..7edc062 100644 --- a/xcode/OLMKitTests/OLMKitTests.m +++ b/xcode/OLMKitTests/OLMKitTests.m @@ -157,5 +157,25 @@ XCTAssertEqualObjects(msg3, dMsg3); } +- (void)testEd25519Signing { + + OLMUtility *olmUtility = [[OLMUtility alloc] init]; + OLMAccount *alice = [[OLMAccount alloc] initNewAccount]; + + NSDictionary *aJSON = @{ + @"key1": @"value1", + @"key2": @"value2" + }; + NSData *message = [NSKeyedArchiver archivedDataWithRootObject:aJSON]; + NSString *signature = [alice signMessage:message]; + + + NSString *aliceEd25519Key = alice.identityKeys[@"ed25519"]; + + NSError *error; + BOOL result = [olmUtility verifyEd25519Signature:signature key:aliceEd25519Key message:message error:&error]; + XCTAssert(result); + XCTAssertNil(error); +} @end -- cgit v1.2.3 From a9be04fa4b53e7012406a9a89596e94b65947c20 Mon Sep 17 00:00:00 2001 From: manuroe Date: Mon, 17 Oct 2016 15:47:52 +0200 Subject: OLMKit: Add [OLMUtility sha256:] --- xcode/OLMKit/OLMUtility.h | 8 ++++++++ xcode/OLMKit/OLMUtility.m | 21 ++++++++++++++++++++- 2 files changed, 28 insertions(+), 1 deletion(-) (limited to 'xcode') diff --git a/xcode/OLMKit/OLMUtility.h b/xcode/OLMKit/OLMUtility.h index a8a3743..1952b8e 100644 --- a/xcode/OLMKit/OLMUtility.h +++ b/xcode/OLMKit/OLMUtility.h @@ -10,6 +10,14 @@ @interface OLMUtility : NSObject +/** + Calculate the SHA-256 hash of the input and encodes it as base64. + + @param message the message to hash. + @return the base64-encoded hash value. + */ +- (NSString*)sha256:(NSData*)message; + /** Verify an ed25519 signature. diff --git a/xcode/OLMKit/OLMUtility.m b/xcode/OLMKit/OLMUtility.m index 041da2f..292fc21 100644 --- a/xcode/OLMKit/OLMUtility.m +++ b/xcode/OLMKit/OLMUtility.m @@ -50,6 +50,25 @@ return self; } +- (NSString *)sha256:(NSData *)message { + size_t length = olm_sha256_length(_utility); + + NSMutableData *shaData = [NSMutableData dataWithLength:length]; + if (!shaData) { + return nil; + } + + size_t result = olm_sha256(_utility, message.bytes, message.length, shaData.mutableBytes, shaData.length); + if (result == olm_error()) { + const char *error = olm_utility_last_error(_utility); + NSAssert(NO, @"olm_sha256 error: %s", error); + return nil; + } + + NSString *sha = [[NSString alloc] initWithData:shaData encoding:NSUTF8StringEncoding]; + return sha; +} + - (BOOL)verifyEd25519Signature:(NSString*)signature key:(NSString*)key message:(NSData*)message error:(NSError**)error { NSData *keyData = [key dataUsingEncoding:NSUTF8StringEncoding]; @@ -61,7 +80,7 @@ signatureData.bytes, signatureData.length ); - if (result < 0 || result == (size_t)-1) { + if (result == olm_error()) { if (error) { NSDictionary *userInfo = @{NSLocalizedFailureReasonErrorKey: [NSString stringWithUTF8String:olm_utility_last_error(_utility)]}; -- cgit v1.2.3 From 27a8c28da4e5c62d8863ee3d30642109d713c4d6 Mon Sep 17 00:00:00 2001 From: manuroe Date: Mon, 7 Nov 2016 17:27:09 +0100 Subject: OLMKit: Update obj-c wrapper to 2.0.0 --- xcode/OLMKit.xcodeproj/project.pbxproj | 4 ++-- xcode/OLMKit/OLMInboundGroupSession.h | 2 +- xcode/OLMKit/OLMInboundGroupSession.m | 4 ++-- xcode/OLMKitTests/OLMKitGroupTests.m | 4 +++- xcode/Podfile.lock | 14 +++++++------- 5 files changed, 15 insertions(+), 13 deletions(-) (limited to 'xcode') diff --git a/xcode/OLMKit.xcodeproj/project.pbxproj b/xcode/OLMKit.xcodeproj/project.pbxproj index fa02539..0ec7587 100644 --- a/xcode/OLMKit.xcodeproj/project.pbxproj +++ b/xcode/OLMKit.xcodeproj/project.pbxproj @@ -273,7 +273,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n"; + shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run \'pod install\' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n"; showEnvVarsInLog = 0; }; 793D0533290528B7C0E17CAD /* [CP] Copy Pods Resources */ = { @@ -303,7 +303,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n"; + shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run \'pod install\' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n"; showEnvVarsInLog = 0; }; /* End PBXShellScriptBuildPhase section */ diff --git a/xcode/OLMKit/OLMInboundGroupSession.h b/xcode/OLMKit/OLMInboundGroupSession.h index a507490..46de3a0 100644 --- a/xcode/OLMKit/OLMInboundGroupSession.h +++ b/xcode/OLMKit/OLMInboundGroupSession.h @@ -24,6 +24,6 @@ - (NSString*)sessionIdentifier; /** base64 ciphertext -> UTF-8 plaintext */ -- (NSString*)decryptMessage:(NSString*)message; +- (NSString*)decryptMessage:(NSString*)message messageIndex:(NSUInteger*)messageIndex; @end diff --git a/xcode/OLMKit/OLMInboundGroupSession.m b/xcode/OLMKit/OLMInboundGroupSession.m index d95d1ab..ea79e14 100644 --- a/xcode/OLMKit/OLMInboundGroupSession.m +++ b/xcode/OLMKit/OLMInboundGroupSession.m @@ -79,7 +79,7 @@ return idString; } -- (NSString *)decryptMessage:(NSString *)message +- (NSString *)decryptMessage:(NSString *)message messageIndex:(NSUInteger*)messageIndex { NSParameterAssert(message != nil); NSData *messageData = [message dataUsingEncoding:NSUTF8StringEncoding]; @@ -96,7 +96,7 @@ // message buffer is destroyed by olm_group_decrypt_max_plaintext_length mutMessage = messageData.mutableCopy; NSMutableData *plaintextData = [NSMutableData dataWithLength:maxPlaintextLength]; - size_t plaintextLength = olm_group_decrypt(session, mutMessage.mutableBytes, mutMessage.length, plaintextData.mutableBytes, plaintextData.length); + size_t plaintextLength = olm_group_decrypt(session, mutMessage.mutableBytes, mutMessage.length, plaintextData.mutableBytes, plaintextData.length, messageIndex); if (plaintextLength == olm_error()) { const char *error = olm_inbound_group_session_last_error(session); NSAssert(NO, @"olm_group_decrypt error: %s", error); diff --git a/xcode/OLMKitTests/OLMKitGroupTests.m b/xcode/OLMKitTests/OLMKitGroupTests.m index 9f5ad10..cdfb704 100644 --- a/xcode/OLMKitTests/OLMKitGroupTests.m +++ b/xcode/OLMKitTests/OLMKitGroupTests.m @@ -55,8 +55,10 @@ OLMInboundGroupSession *bobSession = [[OLMInboundGroupSession alloc] initInboundGroupSessionWithSessionKey:sessionKey]; XCTAssertEqualObjects(aliceSession.sessionIdentifier, bobSession.sessionIdentifier); - NSString *plaintext = [bobSession decryptMessage:aliceToBobMsg]; + NSUInteger messageIndex; + NSString *plaintext = [bobSession decryptMessage:aliceToBobMsg messageIndex:&messageIndex]; XCTAssertEqualObjects(message, plaintext); + XCTAssertEqual(messageIndex, 0); } - (void)testOutboundGroupSessionSerialization { diff --git a/xcode/Podfile.lock b/xcode/Podfile.lock index b091109..3ac110a 100644 --- a/xcode/Podfile.lock +++ b/xcode/Podfile.lock @@ -1,9 +1,9 @@ PODS: - - OLMKit (1.3.0): - - OLMKit/olmc (= 1.3.0) - - OLMKit/olmcpp (= 1.3.0) - - OLMKit/olmc (1.3.0) - - OLMKit/olmcpp (1.3.0) + - OLMKit (2.0.0): + - OLMKit/olmc (= 2.0.0) + - OLMKit/olmcpp (= 2.0.0) + - OLMKit/olmc (2.0.0) + - OLMKit/olmcpp (2.0.0) DEPENDENCIES: - OLMKit (from `../OLMKit.podspec`) @@ -13,8 +13,8 @@ EXTERNAL SOURCES: :path: ../OLMKit.podspec SPEC CHECKSUMS: - OLMKit: 49b73677a77988cc25e51d023f39a8a3e451cb23 + OLMKit: ed17cdf7695bc0de1e2bf98243eb65f5b9ddebc1 PODFILE CHECKSUM: 4e261dae61d833ec5585ced2473023b98909fd35 -COCOAPODS: 1.0.1 +COCOAPODS: 1.1.1 -- cgit v1.2.3 From cf66af6f2e7c69a3e0712317f8473ab09711d426 Mon Sep 17 00:00:00 2001 From: manuroe Date: Mon, 14 Nov 2016 16:54:51 +0100 Subject: OLMKit: Replaced NSAsserts by NSErrors --- xcode/OLMKit/OLMAccount.m | 8 +-- xcode/OLMKit/OLMInboundGroupSession.h | 4 +- xcode/OLMKit/OLMInboundGroupSession.m | 57 +++++++++++++---- xcode/OLMKit/OLMOutboundGroupSession.h | 2 +- xcode/OLMKit/OLMOutboundGroupSession.m | 29 ++++++--- xcode/OLMKit/OLMSession.h | 10 +-- xcode/OLMKit/OLMSession.m | 108 ++++++++++++++++++++++++++------- xcode/OLMKit/OLMUtility.h | 2 + xcode/OLMKit/OLMUtility.m | 4 +- xcode/OLMKitTests/OLMKitGroupTests.m | 14 +++-- xcode/OLMKitTests/OLMKitTests.m | 56 +++++++++-------- 11 files changed, 211 insertions(+), 83 deletions(-) (limited to 'xcode') diff --git a/xcode/OLMKit/OLMAccount.m b/xcode/OLMKit/OLMAccount.m index 085b487..4830995 100644 --- a/xcode/OLMKit/OLMAccount.m +++ b/xcode/OLMKit/OLMAccount.m @@ -151,7 +151,7 @@ size_t result = olm_remove_one_time_keys(self.account, session.session); if (result == olm_error()) { const char *error = olm_account_last_error(_account); - NSAssert(NO, @"olm_remove_one_time_keys error: %s", error); + NSLog(@"olm_remove_one_time_keys error: %s", error); return NO; } return YES; @@ -174,7 +174,7 @@ NSParameterAssert(serializedData.length > 0); if (key.length == 0 || serializedData.length == 0) { if (error) { - *error = [NSError errorWithDomain:@"org.matrix.olm" code:0 userInfo:@{NSLocalizedDescriptionKey: @"Bad length."}]; + *error = [NSError errorWithDomain:OLMErrorDomain code:0 userInfo:@{NSLocalizedDescriptionKey: @"Bad length."}]; } return nil; } @@ -184,7 +184,7 @@ const char *olm_error = olm_account_last_error(_account); NSString *errorString = [NSString stringWithUTF8String:olm_error]; if (error && errorString) { - *error = [NSError errorWithDomain:@"org.matrix.olm" code:0 userInfo:@{NSLocalizedDescriptionKey: errorString}]; + *error = [NSError errorWithDomain:OLMErrorDomain code:0 userInfo:@{NSLocalizedDescriptionKey: errorString}]; } return nil; } @@ -201,7 +201,7 @@ const char *olm_error = olm_account_last_error(_account); NSString *errorString = [NSString stringWithUTF8String:olm_error]; if (error && errorString) { - *error = [NSError errorWithDomain:@"org.matrix.olm" code:0 userInfo:@{NSLocalizedDescriptionKey: errorString}]; + *error = [NSError errorWithDomain:OLMErrorDomain code:0 userInfo:@{NSLocalizedDescriptionKey: errorString}]; } return nil; } diff --git a/xcode/OLMKit/OLMInboundGroupSession.h b/xcode/OLMKit/OLMInboundGroupSession.h index 46de3a0..40dfce7 100644 --- a/xcode/OLMKit/OLMInboundGroupSession.h +++ b/xcode/OLMKit/OLMInboundGroupSession.h @@ -19,11 +19,11 @@ @interface OLMInboundGroupSession : NSObject -- (instancetype) initInboundGroupSessionWithSessionKey:(NSString*)sessionKey; +- (instancetype) initInboundGroupSessionWithSessionKey:(NSString*)sessionKey error:(NSError**)error; - (NSString*)sessionIdentifier; /** base64 ciphertext -> UTF-8 plaintext */ -- (NSString*)decryptMessage:(NSString*)message messageIndex:(NSUInteger*)messageIndex; +- (NSString*)decryptMessage:(NSString*)message messageIndex:(NSUInteger*)messageIndex error:(NSError**)error; @end diff --git a/xcode/OLMKit/OLMInboundGroupSession.m b/xcode/OLMKit/OLMInboundGroupSession.m index ea79e14..5e108a1 100644 --- a/xcode/OLMKit/OLMInboundGroupSession.m +++ b/xcode/OLMKit/OLMInboundGroupSession.m @@ -49,14 +49,25 @@ return self; } -- (instancetype)initInboundGroupSessionWithSessionKey:(NSString *)sessionKey { +- (instancetype)initInboundGroupSessionWithSessionKey:(NSString *)sessionKey error:(NSError**)error { self = [self init]; if (self) { NSData *sessionKeyData = [sessionKey dataUsingEncoding:NSUTF8StringEncoding]; size_t result = olm_init_inbound_group_session(session, sessionKeyData.bytes, sessionKeyData.length); if (result == olm_error()) { - const char *error = olm_inbound_group_session_last_error(session); - NSAssert(NO, @"olm_init_inbound_group_session error: %s", error); + const char *olm_error = olm_inbound_group_session_last_error(session); + + NSString *errorString = [NSString stringWithUTF8String:olm_error]; + NSLog(@"olm_init_inbound_group_session error: %@", errorString); + + if (error && olm_error && errorString) { + *error = [NSError errorWithDomain:OLMErrorDomain + code:0 + userInfo:@{ + NSLocalizedDescriptionKey: [NSString stringWithFormat:@"olm_init_inbound_group_session error: %@", errorString] + }]; + } + return nil; } } @@ -72,14 +83,14 @@ size_t result = olm_inbound_group_session_id(session, idData.mutableBytes, idData.length); if (result == olm_error()) { const char *error = olm_inbound_group_session_last_error(session); - NSAssert(NO, @"olm_inbound_group_session_id error: %s", error); + NSLog(@"olm_inbound_group_session_id error: %s", error); return nil; } NSString *idString = [[NSString alloc] initWithData:idData encoding:NSUTF8StringEncoding]; return idString; } -- (NSString *)decryptMessage:(NSString *)message messageIndex:(NSUInteger*)messageIndex +- (NSString *)decryptMessage:(NSString *)message messageIndex:(NSUInteger*)messageIndex error:(NSError**)error { NSParameterAssert(message != nil); NSData *messageData = [message dataUsingEncoding:NSUTF8StringEncoding]; @@ -89,8 +100,19 @@ NSMutableData *mutMessage = messageData.mutableCopy; size_t maxPlaintextLength = olm_group_decrypt_max_plaintext_length(session, mutMessage.mutableBytes, mutMessage.length); if (maxPlaintextLength == olm_error()) { - const char *error = olm_inbound_group_session_last_error(session); - NSAssert(NO, @"olm_group_decrypt_max_plaintext_length error: %s", error); + const char *olm_error = olm_inbound_group_session_last_error(session); + + NSString *errorString = [NSString stringWithUTF8String:olm_error]; + NSLog(@"olm_group_decrypt_max_plaintext_length error: %@", errorString); + + if (error && olm_error && errorString) { + *error = [NSError errorWithDomain:OLMErrorDomain + code:0 + userInfo:@{ + NSLocalizedDescriptionKey: [NSString stringWithFormat:@"olm_group_decrypt_max_plaintext_length error: %@", errorString] + }]; + } + return nil; } // message buffer is destroyed by olm_group_decrypt_max_plaintext_length @@ -98,8 +120,19 @@ NSMutableData *plaintextData = [NSMutableData dataWithLength:maxPlaintextLength]; size_t plaintextLength = olm_group_decrypt(session, mutMessage.mutableBytes, mutMessage.length, plaintextData.mutableBytes, plaintextData.length, messageIndex); if (plaintextLength == olm_error()) { - const char *error = olm_inbound_group_session_last_error(session); - NSAssert(NO, @"olm_group_decrypt error: %s", error); + const char *olm_error = olm_inbound_group_session_last_error(session); + + NSString *errorString = [NSString stringWithUTF8String:olm_error]; + NSLog(@"olm_group_decrypt error: %@", errorString); + + if (error && olm_error && errorString) { + *error = [NSError errorWithDomain:OLMErrorDomain + code:0 + userInfo:@{ + NSLocalizedDescriptionKey: [NSString stringWithFormat:@"olm_group_decrypt error: %@", errorString] + }]; + } + return nil; } plaintextData.length = plaintextLength; @@ -120,7 +153,7 @@ NSParameterAssert(serializedData.length > 0); if (key.length == 0 || serializedData.length == 0) { if (error) { - *error = [NSError errorWithDomain:@"org.matrix.olm" code:0 userInfo:@{NSLocalizedDescriptionKey: @"Bad length."}]; + *error = [NSError errorWithDomain:OLMErrorDomain code:0 userInfo:@{NSLocalizedDescriptionKey: @"Bad length."}]; } return nil; } @@ -130,7 +163,7 @@ const char *olm_error = olm_inbound_group_session_last_error(session); NSString *errorString = [NSString stringWithUTF8String:olm_error]; if (error && errorString) { - *error = [NSError errorWithDomain:@"org.matrix.olm" code:0 userInfo:@{NSLocalizedDescriptionKey: errorString}]; + *error = [NSError errorWithDomain:OLMErrorDomain code:0 userInfo:@{NSLocalizedDescriptionKey: errorString}]; } return nil; } @@ -147,7 +180,7 @@ const char *olm_error = olm_inbound_group_session_last_error(session); NSString *errorString = [NSString stringWithUTF8String:olm_error]; if (error && errorString) { - *error = [NSError errorWithDomain:@"org.matrix.olm" code:0 userInfo:@{NSLocalizedDescriptionKey: errorString}]; + *error = [NSError errorWithDomain:OLMErrorDomain code:0 userInfo:@{NSLocalizedDescriptionKey: errorString}]; } return nil; } diff --git a/xcode/OLMKit/OLMOutboundGroupSession.h b/xcode/OLMKit/OLMOutboundGroupSession.h index e7a8a91..4586a25 100644 --- a/xcode/OLMKit/OLMOutboundGroupSession.h +++ b/xcode/OLMKit/OLMOutboundGroupSession.h @@ -26,6 +26,6 @@ - (NSString*)sessionKey; /** UTF-8 plaintext -> base64 ciphertext */ -- (NSString*)encryptMessage:(NSString*)message; +- (NSString*)encryptMessage:(NSString*)message error:(NSError**)error; @end diff --git a/xcode/OLMKit/OLMOutboundGroupSession.m b/xcode/OLMKit/OLMOutboundGroupSession.m index c86fa9f..9741db1 100644 --- a/xcode/OLMKit/OLMOutboundGroupSession.m +++ b/xcode/OLMKit/OLMOutboundGroupSession.m @@ -56,7 +56,7 @@ size_t result = olm_init_outbound_group_session(session, random.mutableBytes, random.length); if (result == olm_error()) { const char *error = olm_outbound_group_session_last_error(session); - NSAssert(NO, @"olm_init_outbound_group_session error: %s", error); + NSLog(@"olm_init_outbound_group_session error: %s", error); return nil; } } @@ -72,7 +72,7 @@ size_t result = olm_outbound_group_session_id(session, idData.mutableBytes, idData.length); if (result == olm_error()) { const char *error = olm_outbound_group_session_last_error(session); - NSAssert(NO, @"olm_outbound_group_session_id error: %s", error); + NSLog(@"olm_outbound_group_session_id error: %s", error); return nil; } NSString *idString = [[NSString alloc] initWithData:idData encoding:NSUTF8StringEncoding]; @@ -92,14 +92,14 @@ size_t result = olm_outbound_group_session_key(session, sessionKeyData.mutableBytes, sessionKeyData.length); if (result == olm_error()) { const char *error = olm_outbound_group_session_last_error(session); - NSAssert(NO, @"olm_outbound_group_session_key error: %s", error); + NSLog(@"olm_outbound_group_session_key error: %s", error); return nil; } NSString *sessionKey = [[NSString alloc] initWithData:sessionKeyData encoding:NSUTF8StringEncoding]; return sessionKey; } -- (NSString *)encryptMessage:(NSString *)message { +- (NSString *)encryptMessage:(NSString *)message error:(NSError**)error { NSData *plaintextData = [message dataUsingEncoding:NSUTF8StringEncoding]; size_t ciphertextLength = olm_group_encrypt_message_length(session, plaintextData.length); NSMutableData *ciphertext = [NSMutableData dataWithLength:ciphertextLength]; @@ -108,8 +108,19 @@ } size_t result = olm_group_encrypt(session, plaintextData.bytes, plaintextData.length, ciphertext.mutableBytes, ciphertext.length); if (result == olm_error()) { - const char *error = olm_outbound_group_session_last_error(session); - NSAssert(NO, @"olm_group_encrypt error: %s", error); + const char *olm_error = olm_outbound_group_session_last_error(session); + + NSString *errorString = [NSString stringWithUTF8String:olm_error]; + NSLog(@"olm_group_encrypt error: %@", errorString); + + if (error && olm_error && errorString) { + *error = [NSError errorWithDomain:OLMErrorDomain + code:0 + userInfo:@{ + NSLocalizedDescriptionKey: [NSString stringWithFormat:@"olm_group_encrypt error: %@", errorString] + }]; + } + return nil; } return [[NSString alloc] initWithData:ciphertext encoding:NSUTF8StringEncoding]; @@ -127,7 +138,7 @@ NSParameterAssert(serializedData.length > 0); if (key.length == 0 || serializedData.length == 0) { if (error) { - *error = [NSError errorWithDomain:@"org.matrix.olm" code:0 userInfo:@{NSLocalizedDescriptionKey: @"Bad length."}]; + *error = [NSError errorWithDomain:OLMErrorDomain code:0 userInfo:@{NSLocalizedDescriptionKey: @"Bad length."}]; } return nil; } @@ -137,7 +148,7 @@ const char *olm_error = olm_outbound_group_session_last_error(session); NSString *errorString = [NSString stringWithUTF8String:olm_error]; if (error && errorString) { - *error = [NSError errorWithDomain:@"org.matrix.olm" code:0 userInfo:@{NSLocalizedDescriptionKey: errorString}]; + *error = [NSError errorWithDomain:OLMErrorDomain code:0 userInfo:@{NSLocalizedDescriptionKey: errorString}]; } return nil; } @@ -154,7 +165,7 @@ const char *olm_error = olm_outbound_group_session_last_error(session); NSString *errorString = [NSString stringWithUTF8String:olm_error]; if (error && errorString) { - *error = [NSError errorWithDomain:@"org.matrix.olm" code:0 userInfo:@{NSLocalizedDescriptionKey: errorString}]; + *error = [NSError errorWithDomain:OLMErrorDomain code:0 userInfo:@{NSLocalizedDescriptionKey: errorString}]; } return nil; } diff --git a/xcode/OLMKit/OLMSession.h b/xcode/OLMKit/OLMSession.h index c209564..b10e481 100644 --- a/xcode/OLMKit/OLMSession.h +++ b/xcode/OLMKit/OLMSession.h @@ -13,11 +13,11 @@ @interface OLMSession : NSObject -- (instancetype) initOutboundSessionWithAccount:(OLMAccount*)account theirIdentityKey:(NSString*)theirIdentityKey theirOneTimeKey:(NSString*)theirOneTimeKey; +- (instancetype) initOutboundSessionWithAccount:(OLMAccount*)account theirIdentityKey:(NSString*)theirIdentityKey theirOneTimeKey:(NSString*)theirOneTimeKey error:(NSError**)error; -- (instancetype) initInboundSessionWithAccount:(OLMAccount*)account oneTimeKeyMessage:(NSString*)oneTimeKeyMessage; +- (instancetype) initInboundSessionWithAccount:(OLMAccount*)account oneTimeKeyMessage:(NSString*)oneTimeKeyMessage error:(NSError**)error; -- (instancetype) initInboundSessionWithAccount:(OLMAccount*)account theirIdentityKey:(NSString*)theirIdentityKey oneTimeKeyMessage:(NSString*)oneTimeKeyMessage; +- (instancetype) initInboundSessionWithAccount:(OLMAccount*)account theirIdentityKey:(NSString*)theirIdentityKey oneTimeKeyMessage:(NSString*)oneTimeKeyMessage error:(NSError**)error; - (NSString*) sessionIdentifier; @@ -26,9 +26,9 @@ - (BOOL) matchesInboundSessionFrom:(NSString*)theirIdentityKey oneTimeKeyMessage:(NSString *)oneTimeKeyMessage; /** UTF-8 plaintext -> base64 ciphertext */ -- (OLMMessage*) encryptMessage:(NSString*)message; +- (OLMMessage*) encryptMessage:(NSString*)message error:(NSError**)error; /** base64 ciphertext -> UTF-8 plaintext */ -- (NSString*) decryptMessage:(OLMMessage*)message; +- (NSString*) decryptMessage:(OLMMessage*)message error:(NSError**)error; @end diff --git a/xcode/OLMKit/OLMSession.m b/xcode/OLMKit/OLMSession.m index 41aef7e..a47deb1 100644 --- a/xcode/OLMKit/OLMSession.m +++ b/xcode/OLMKit/OLMSession.m @@ -59,7 +59,7 @@ return self; } -- (instancetype) initOutboundSessionWithAccount:(OLMAccount*)account theirIdentityKey:(NSString*)theirIdentityKey theirOneTimeKey:(NSString*)theirOneTimeKey { +- (instancetype) initOutboundSessionWithAccount:(OLMAccount*)account theirIdentityKey:(NSString*)theirIdentityKey theirOneTimeKey:(NSString*)theirOneTimeKey error:(NSError**)error { self = [self initWithAccount:account]; if (!self) { return nil; @@ -69,14 +69,25 @@ NSData *otKey = [theirOneTimeKey dataUsingEncoding:NSUTF8StringEncoding]; size_t result = olm_create_outbound_session(_session, account.account, idKey.bytes, idKey.length, otKey.bytes, otKey.length, random.mutableBytes, random.length); if (result == olm_error()) { - const char *error = olm_session_last_error(_session); - NSAssert(NO, @"olm_create_outbound_session error: %s", error); + const char *olm_error = olm_session_last_error(_session); + + NSString *errorString = [NSString stringWithUTF8String:olm_error]; + NSLog(@"olm_create_outbound_session error: %@", errorString); + + if (error && olm_error && errorString) { + *error = [NSError errorWithDomain:OLMErrorDomain + code:0 + userInfo:@{ + NSLocalizedDescriptionKey: [NSString stringWithFormat:@"olm_create_outbound_session error: %@", errorString] + }]; + } + return nil; } return self; } -- (instancetype) initInboundSessionWithAccount:(OLMAccount*)account oneTimeKeyMessage:(NSString*)oneTimeKeyMessage { +- (instancetype) initInboundSessionWithAccount:(OLMAccount*)account oneTimeKeyMessage:(NSString*)oneTimeKeyMessage error:(NSError**)error { self = [self initWithAccount:account]; if (!self) { return nil; @@ -84,14 +95,25 @@ NSMutableData *otk = [NSMutableData dataWithData:[oneTimeKeyMessage dataUsingEncoding:NSUTF8StringEncoding]]; size_t result = olm_create_inbound_session(_session, account.account, otk.mutableBytes, oneTimeKeyMessage.length); if (result == olm_error()) { - const char *error = olm_session_last_error(_session); - NSAssert(NO, @"olm_create_inbound_session error: %s", error); + const char *olm_error = olm_session_last_error(_session); + + NSString *errorString = [NSString stringWithUTF8String:olm_error]; + NSLog(@"olm_create_inbound_session error: %@", errorString); + + if (error && olm_error && errorString) { + *error = [NSError errorWithDomain:OLMErrorDomain + code:0 + userInfo:@{ + NSLocalizedDescriptionKey: [NSString stringWithFormat:@"olm_create_inbound_session error: %@", errorString] + }]; + } + return nil; } return self; } -- (instancetype) initInboundSessionWithAccount:(OLMAccount*)account theirIdentityKey:(NSString*)theirIdentityKey oneTimeKeyMessage:(NSString*)oneTimeKeyMessage { +- (instancetype) initInboundSessionWithAccount:(OLMAccount*)account theirIdentityKey:(NSString*)theirIdentityKey oneTimeKeyMessage:(NSString*)oneTimeKeyMessage error:(NSError**)error { self = [self initWithAccount:account]; if (!self) { return nil; @@ -100,8 +122,19 @@ NSMutableData *otk = [NSMutableData dataWithData:[oneTimeKeyMessage dataUsingEncoding:NSUTF8StringEncoding]]; size_t result = olm_create_inbound_session_from(_session, account.account, idKey.bytes, idKey.length, otk.mutableBytes, otk.length); if (result == olm_error()) { - const char *error = olm_session_last_error(_session); - NSAssert(NO, @"olm_create_inbound_session_from error: %s", error); + const char *olm_error = olm_session_last_error(_session); + + NSString *errorString = [NSString stringWithUTF8String:olm_error]; + NSLog(@"olm_create_inbound_session_from error: %@", errorString); + + if (error && olm_error && errorString) { + *error = [NSError errorWithDomain:OLMErrorDomain + code:0 + userInfo:@{ + NSLocalizedDescriptionKey: [NSString stringWithFormat:@"olm_create_inbound_session_from error: %@", errorString] + }]; + } + return nil; } return self; @@ -116,14 +149,14 @@ size_t result = olm_session_id(_session, idData.mutableBytes, idData.length); if (result == olm_error()) { const char *error = olm_session_last_error(_session); - NSAssert(NO, @"olm_session_id error: %s", error); + NSLog(@"olm_session_id error: %s", error); return nil; } NSString *idString = [[NSString alloc] initWithData:idData encoding:NSUTF8StringEncoding]; return idString; } -- (OLMMessage*) encryptMessage:(NSString*)message { +- (OLMMessage*) encryptMessage:(NSString*)message error:(NSError**)error { size_t messageType = olm_encrypt_message_type(_session); size_t randomLength = olm_encrypt_random_length(_session); NSMutableData *random = [OLMUtility randomBytesOfLength:randomLength]; @@ -135,8 +168,19 @@ } size_t result = olm_encrypt(_session, plaintextData.bytes, plaintextData.length, random.mutableBytes, random.length, ciphertext.mutableBytes, ciphertext.length); if (result == olm_error()) { - const char *error = olm_session_last_error(_session); - NSAssert(NO, @"olm_encrypt error: %s", error); + const char *olm_error = olm_session_last_error(_session); + + NSString *errorString = [NSString stringWithUTF8String:olm_error]; + NSLog(@"olm_encrypt error: %@", errorString); + + if (error && olm_error && errorString) { + *error = [NSError errorWithDomain:OLMErrorDomain + code:0 + userInfo:@{ + NSLocalizedDescriptionKey: [NSString stringWithFormat:@"olm_encrypt error: %@", errorString] + }]; + } + return nil; } NSString *ciphertextString = [[NSString alloc] initWithData:ciphertext encoding:NSUTF8StringEncoding]; @@ -144,7 +188,7 @@ return encryptedMessage; } -- (NSString*) decryptMessage:(OLMMessage*)message { +- (NSString*) decryptMessage:(OLMMessage*)message error:(NSError**)error { NSParameterAssert(message != nil); NSData *messageData = [message.ciphertext dataUsingEncoding:NSUTF8StringEncoding]; if (!messageData) { @@ -153,8 +197,19 @@ NSMutableData *mutMessage = messageData.mutableCopy; size_t maxPlaintextLength = olm_decrypt_max_plaintext_length(_session, message.type, mutMessage.mutableBytes, mutMessage.length); if (maxPlaintextLength == olm_error()) { - const char *error = olm_session_last_error(_session); - NSAssert(NO, @"olm_decrypt_max_plaintext_length error: %s", error); + const char *olm_error = olm_session_last_error(_session); + + NSString *errorString = [NSString stringWithUTF8String:olm_error]; + NSLog(@"olm_decrypt_max_plaintext_length error: %@", errorString); + + if (error && olm_error && errorString) { + *error = [NSError errorWithDomain:OLMErrorDomain + code:0 + userInfo:@{ + NSLocalizedDescriptionKey: [NSString stringWithFormat:@"olm_decrypt_max_plaintext_length error: %@", errorString] + }]; + } + return nil; } // message buffer is destroyed by olm_decrypt_max_plaintext_length @@ -162,8 +217,19 @@ NSMutableData *plaintextData = [NSMutableData dataWithLength:maxPlaintextLength]; size_t plaintextLength = olm_decrypt(_session, message.type, mutMessage.mutableBytes, mutMessage.length, plaintextData.mutableBytes, plaintextData.length); if (plaintextLength == olm_error()) { - const char *error = olm_session_last_error(_session); - NSAssert(NO, @"olm_decrypt error: %s", error); + const char *olm_error = olm_session_last_error(_session); + + NSString *errorString = [NSString stringWithUTF8String:olm_error]; + NSLog(@"olm_decrypt error: %@", errorString); + + if (error && olm_error && errorString) { + *error = [NSError errorWithDomain:OLMErrorDomain + code:0 + userInfo:@{ + NSLocalizedDescriptionKey: [NSString stringWithFormat:@"olm_decrypt error: %@", errorString] + }]; + } + return nil; } plaintextData.length = plaintextLength; @@ -183,7 +249,7 @@ NSParameterAssert(serializedData.length > 0); if (key.length == 0 || serializedData.length == 0) { if (error) { - *error = [NSError errorWithDomain:@"org.matrix.olm" code:0 userInfo:@{NSLocalizedDescriptionKey: @"Bad length."}]; + *error = [NSError errorWithDomain:OLMErrorDomain code:0 userInfo:@{NSLocalizedDescriptionKey: @"Bad length."}]; } return nil; } @@ -193,7 +259,7 @@ const char *olm_error = olm_session_last_error(_session); NSString *errorString = [NSString stringWithUTF8String:olm_error]; if (error && errorString) { - *error = [NSError errorWithDomain:@"org.matrix.olm" code:0 userInfo:@{NSLocalizedDescriptionKey: errorString}]; + *error = [NSError errorWithDomain:OLMErrorDomain code:0 userInfo:@{NSLocalizedDescriptionKey: errorString}]; } return nil; } @@ -210,7 +276,7 @@ const char *olm_error = olm_session_last_error(_session); NSString *errorString = [NSString stringWithUTF8String:olm_error]; if (error && errorString) { - *error = [NSError errorWithDomain:@"org.matrix.olm" code:0 userInfo:@{NSLocalizedDescriptionKey: errorString}]; + *error = [NSError errorWithDomain:OLMErrorDomain code:0 userInfo:@{NSLocalizedDescriptionKey: errorString}]; } return nil; } diff --git a/xcode/OLMKit/OLMUtility.h b/xcode/OLMKit/OLMUtility.h index 1952b8e..c316829 100644 --- a/xcode/OLMKit/OLMUtility.h +++ b/xcode/OLMKit/OLMUtility.h @@ -8,6 +8,8 @@ #import +FOUNDATION_EXPORT NSString *const OLMErrorDomain; + @interface OLMUtility : NSObject /** diff --git a/xcode/OLMKit/OLMUtility.m b/xcode/OLMKit/OLMUtility.m index 292fc21..3c6ce6e 100644 --- a/xcode/OLMKit/OLMUtility.m +++ b/xcode/OLMKit/OLMUtility.m @@ -10,6 +10,8 @@ #include "olm/olm.h" +NSString *const OLMErrorDomain = @"org.matrix.olm"; + @interface OLMUtility() @property (nonatomic) OlmUtility *utility; @@ -61,7 +63,7 @@ size_t result = olm_sha256(_utility, message.bytes, message.length, shaData.mutableBytes, shaData.length); if (result == olm_error()) { const char *error = olm_utility_last_error(_utility); - NSAssert(NO, @"olm_sha256 error: %s", error); + NSLog(@"olm_sha256 error: %s", error); return nil; } diff --git a/xcode/OLMKitTests/OLMKitGroupTests.m b/xcode/OLMKitTests/OLMKitGroupTests.m index cdfb704..43e2df8 100644 --- a/xcode/OLMKitTests/OLMKitGroupTests.m +++ b/xcode/OLMKitTests/OLMKitGroupTests.m @@ -37,6 +37,7 @@ } - (void)testAliceAndBob { + NSError *error; OLMOutboundGroupSession *aliceSession = [[OLMOutboundGroupSession alloc] initOutboundGroupSession]; XCTAssertGreaterThan(aliceSession.sessionIdentifier.length, 0); @@ -47,18 +48,23 @@ NSString *sessionKey = aliceSession.sessionKey; NSString *message = @"Hello!"; - NSString *aliceToBobMsg = [aliceSession encryptMessage:message]; + NSString *aliceToBobMsg = [aliceSession encryptMessage:message error:&error]; XCTAssertEqual(aliceSession.messageIndex, 1); XCTAssertGreaterThanOrEqual(aliceToBobMsg.length, 0); + XCTAssertNil(error); - OLMInboundGroupSession *bobSession = [[OLMInboundGroupSession alloc] initInboundGroupSessionWithSessionKey:sessionKey]; + OLMInboundGroupSession *bobSession = [[OLMInboundGroupSession alloc] initInboundGroupSessionWithSessionKey:sessionKey error:&error]; XCTAssertEqualObjects(aliceSession.sessionIdentifier, bobSession.sessionIdentifier); + XCTAssertNil(error); NSUInteger messageIndex; - NSString *plaintext = [bobSession decryptMessage:aliceToBobMsg messageIndex:&messageIndex]; + + NSString *plaintext = [bobSession decryptMessage:aliceToBobMsg messageIndex:&messageIndex error:&error]; XCTAssertEqualObjects(message, plaintext); + XCTAssertEqual(messageIndex, 0); + XCTAssertNil(error); } - (void)testOutboundGroupSessionSerialization { @@ -76,7 +82,7 @@ OLMOutboundGroupSession *aliceSession = [[OLMOutboundGroupSession alloc] initOutboundGroupSession]; - OLMInboundGroupSession *bobSession = [[OLMInboundGroupSession alloc] initInboundGroupSessionWithSessionKey:aliceSession.sessionKey]; + OLMInboundGroupSession *bobSession = [[OLMInboundGroupSession alloc] initInboundGroupSessionWithSessionKey:aliceSession.sessionKey error:nil]; NSData *bobData = [NSKeyedArchiver archivedDataWithRootObject:bobSession]; OLMInboundGroupSession *bobSession2 = [NSKeyedUnarchiver unarchiveObjectWithData:bobData]; diff --git a/xcode/OLMKitTests/OLMKitTests.m b/xcode/OLMKitTests/OLMKitTests.m index 7edc062..251c90e 100644 --- a/xcode/OLMKitTests/OLMKitTests.m +++ b/xcode/OLMKitTests/OLMKitTests.m @@ -26,6 +26,8 @@ } - (void)testAliceAndBob { + NSError *error; + OLMAccount *alice = [[OLMAccount alloc] initNewAccount]; OLMAccount *bob = [[OLMAccount alloc] initNewAccount]; [bob generateOneTimeKeys:5]; @@ -41,13 +43,15 @@ }]; XCTAssert([bobOneTimeKey isKindOfClass:[NSString class]]); - OLMSession *aliceSession = [[OLMSession alloc] initOutboundSessionWithAccount:alice theirIdentityKey:bobIdKey theirOneTimeKey:bobOneTimeKey]; + OLMSession *aliceSession = [[OLMSession alloc] initOutboundSessionWithAccount:alice theirIdentityKey:bobIdKey theirOneTimeKey:bobOneTimeKey error:nil]; NSString *message = @"Hello!"; - OLMMessage *aliceToBobMsg = [aliceSession encryptMessage:message]; + OLMMessage *aliceToBobMsg = [aliceSession encryptMessage:message error:&error]; + XCTAssertNil(error); - OLMSession *bobSession = [[OLMSession alloc] initInboundSessionWithAccount:bob oneTimeKeyMessage:aliceToBobMsg.ciphertext]; - NSString *plaintext = [bobSession decryptMessage:aliceToBobMsg]; + OLMSession *bobSession = [[OLMSession alloc] initInboundSessionWithAccount:bob oneTimeKeyMessage:aliceToBobMsg.ciphertext error:nil]; + NSString *plaintext = [bobSession decryptMessage:aliceToBobMsg error:&error]; XCTAssertEqualObjects(message, plaintext); + XCTAssertNil(error); BOOL success = [bob removeOneTimeKeysForSession:bobSession]; XCTAssertTrue(success); } @@ -68,12 +72,12 @@ }]; XCTAssert([bobOneTimeKey isKindOfClass:[NSString class]]); - OLMSession *aliceSession = [[OLMSession alloc] initOutboundSessionWithAccount:alice theirIdentityKey:bobIdKey theirOneTimeKey:bobOneTimeKey]; + OLMSession *aliceSession = [[OLMSession alloc] initOutboundSessionWithAccount:alice theirIdentityKey:bobIdKey theirOneTimeKey:bobOneTimeKey error:nil]; NSString *message = @"Hello I'm Alice!"; - OLMMessage *aliceToBobMsg = [aliceSession encryptMessage:message]; + OLMMessage *aliceToBobMsg = [aliceSession encryptMessage:message error:nil]; - OLMSession *bobSession = [[OLMSession alloc] initInboundSessionWithAccount:bob oneTimeKeyMessage:aliceToBobMsg.ciphertext]; - NSString *plaintext = [bobSession decryptMessage:aliceToBobMsg]; + OLMSession *bobSession = [[OLMSession alloc] initInboundSessionWithAccount:bob oneTimeKeyMessage:aliceToBobMsg.ciphertext error:nil]; + NSString *plaintext = [bobSession decryptMessage:aliceToBobMsg error:nil]; XCTAssertEqualObjects(message, plaintext); BOOL success = [bob removeOneTimeKeysForSession:bobSession]; XCTAssertTrue(success); @@ -82,13 +86,13 @@ NSString *msg2 = @"Isn't life grand?"; NSString *msg3 = @"Let's go to the opera."; - OLMMessage *eMsg1 = [bobSession encryptMessage:msg1]; - OLMMessage *eMsg2 = [bobSession encryptMessage:msg2]; - OLMMessage *eMsg3 = [bobSession encryptMessage:msg3]; + OLMMessage *eMsg1 = [bobSession encryptMessage:msg1 error:nil]; + OLMMessage *eMsg2 = [bobSession encryptMessage:msg2 error:nil]; + OLMMessage *eMsg3 = [bobSession encryptMessage:msg3 error:nil]; - NSString *dMsg1 = [aliceSession decryptMessage:eMsg1]; - NSString *dMsg2 = [aliceSession decryptMessage:eMsg2]; - NSString *dMsg3 = [aliceSession decryptMessage:eMsg3]; + NSString *dMsg1 = [aliceSession decryptMessage:eMsg1 error:nil]; + NSString *dMsg2 = [aliceSession decryptMessage:eMsg2 error:nil]; + NSString *dMsg3 = [aliceSession decryptMessage:eMsg3 error:nil]; XCTAssertEqualObjects(msg1, dMsg1); XCTAssertEqualObjects(msg2, dMsg2); XCTAssertEqualObjects(msg3, dMsg3); @@ -113,6 +117,8 @@ } - (void) testSessionSerialization { + NSError *error; + OLMAccount *alice = [[OLMAccount alloc] initNewAccount]; OLMAccount *bob = [[OLMAccount alloc] initNewAccount]; [bob generateOneTimeKeys:1]; @@ -128,12 +134,14 @@ }]; XCTAssert([bobOneTimeKey isKindOfClass:[NSString class]]); - OLMSession *aliceSession = [[OLMSession alloc] initOutboundSessionWithAccount:alice theirIdentityKey:bobIdKey theirOneTimeKey:bobOneTimeKey]; + OLMSession *aliceSession = [[OLMSession alloc] initOutboundSessionWithAccount:alice theirIdentityKey:bobIdKey theirOneTimeKey:bobOneTimeKey error:nil]; NSString *message = @"Hello I'm Alice!"; - OLMMessage *aliceToBobMsg = [aliceSession encryptMessage:message]; + OLMMessage *aliceToBobMsg = [aliceSession encryptMessage:message error:&error]; + XCTAssertNil(error); + - OLMSession *bobSession = [[OLMSession alloc] initInboundSessionWithAccount:bob oneTimeKeyMessage:aliceToBobMsg.ciphertext]; - NSString *plaintext = [bobSession decryptMessage:aliceToBobMsg]; + OLMSession *bobSession = [[OLMSession alloc] initInboundSessionWithAccount:bob oneTimeKeyMessage:aliceToBobMsg.ciphertext error:nil]; + NSString *plaintext = [bobSession decryptMessage:aliceToBobMsg error:nil]; XCTAssertEqualObjects(message, plaintext); BOOL success = [bob removeOneTimeKeysForSession:bobSession]; XCTAssertTrue(success); @@ -142,16 +150,16 @@ NSString *msg2 = @"Isn't life grand?"; NSString *msg3 = @"Let's go to the opera."; - OLMMessage *eMsg1 = [bobSession encryptMessage:msg1]; - OLMMessage *eMsg2 = [bobSession encryptMessage:msg2]; - OLMMessage *eMsg3 = [bobSession encryptMessage:msg3]; + OLMMessage *eMsg1 = [bobSession encryptMessage:msg1 error:nil]; + OLMMessage *eMsg2 = [bobSession encryptMessage:msg2 error:nil]; + OLMMessage *eMsg3 = [bobSession encryptMessage:msg3 error:nil]; NSData *aliceData = [NSKeyedArchiver archivedDataWithRootObject:aliceSession]; OLMSession *alice2 = [NSKeyedUnarchiver unarchiveObjectWithData:aliceData]; - NSString *dMsg1 = [alice2 decryptMessage:eMsg1]; - NSString *dMsg2 = [alice2 decryptMessage:eMsg2]; - NSString *dMsg3 = [alice2 decryptMessage:eMsg3]; + NSString *dMsg1 = [alice2 decryptMessage:eMsg1 error:nil]; + NSString *dMsg2 = [alice2 decryptMessage:eMsg2 error:nil]; + NSString *dMsg3 = [alice2 decryptMessage:eMsg3 error:nil]; XCTAssertEqualObjects(msg1, dMsg1); XCTAssertEqualObjects(msg2, dMsg2); XCTAssertEqualObjects(msg3, dMsg3); -- cgit v1.2.3 From bc697bf5e2ddbad947aec65533d41514592ca093 Mon Sep 17 00:00:00 2001 From: manuroe Date: Mon, 14 Nov 2016 17:02:56 +0100 Subject: OLMKit: Fixed type-cast of messageIndex of [OLMInboundGroupSession decryptMessage] for 32 and 64bits platforms --- xcode/OLMKit/OLMInboundGroupSession.m | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'xcode') diff --git a/xcode/OLMKit/OLMInboundGroupSession.m b/xcode/OLMKit/OLMInboundGroupSession.m index 5e108a1..32e1376 100644 --- a/xcode/OLMKit/OLMInboundGroupSession.m +++ b/xcode/OLMKit/OLMInboundGroupSession.m @@ -118,7 +118,9 @@ // message buffer is destroyed by olm_group_decrypt_max_plaintext_length mutMessage = messageData.mutableCopy; NSMutableData *plaintextData = [NSMutableData dataWithLength:maxPlaintextLength]; - size_t plaintextLength = olm_group_decrypt(session, mutMessage.mutableBytes, mutMessage.length, plaintextData.mutableBytes, plaintextData.length, messageIndex); + + uint32_t message_index; + size_t plaintextLength = olm_group_decrypt(session, mutMessage.mutableBytes, mutMessage.length, plaintextData.mutableBytes, plaintextData.length, &message_index); if (plaintextLength == olm_error()) { const char *olm_error = olm_inbound_group_session_last_error(session); @@ -137,6 +139,12 @@ } plaintextData.length = plaintextLength; NSString *plaintext = [[NSString alloc] initWithData:plaintextData encoding:NSUTF8StringEncoding]; + + if (messageIndex) + { + *messageIndex = message_index; + } + return plaintext; } -- cgit v1.2.3 From aa70c8afbccdccd289a69fb513dd3664aa8e3fc7 Mon Sep 17 00:00:00 2001 From: manuroe Date: Mon, 14 Nov 2016 17:06:34 +0100 Subject: OLMKit: Fix warning in OLMUtility --- xcode/OLMKit/OLMUtility.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'xcode') diff --git a/xcode/OLMKit/OLMUtility.m b/xcode/OLMKit/OLMUtility.m index 3c6ce6e..f9d47c0 100644 --- a/xcode/OLMKit/OLMUtility.m +++ b/xcode/OLMKit/OLMUtility.m @@ -79,7 +79,7 @@ NSString *const OLMErrorDomain = @"org.matrix.olm"; size_t result = olm_ed25519_verify(_utility, keyData.bytes, keyData.length, message.bytes, message.length, - signatureData.bytes, signatureData.length + (void*)signatureData.bytes, signatureData.length ); if (result == olm_error()) { -- cgit v1.2.3 From 7ee17a295738f0db8cab74cec2343a577f2ade45 Mon Sep 17 00:00:00 2001 From: manuroe Date: Mon, 14 Nov 2016 17:35:24 +0100 Subject: OLMKit: Add missing implementations for matchesInboundSession matchesInboundSessionFrom --- xcode/OLMKit.xcodeproj/project.pbxproj | 8 +++++--- xcode/OLMKit/OLMSession.m | 35 ++++++++++++++++++++++++++++++++++ xcode/OLMKitTests/OLMKitTests.m | 11 +++++++++-- xcode/Podfile.lock | 2 +- 4 files changed, 50 insertions(+), 6 deletions(-) (limited to 'xcode') diff --git a/xcode/OLMKit.xcodeproj/project.pbxproj b/xcode/OLMKit.xcodeproj/project.pbxproj index 0ec7587..a3b636f 100644 --- a/xcode/OLMKit.xcodeproj/project.pbxproj +++ b/xcode/OLMKit.xcodeproj/project.pbxproj @@ -182,7 +182,7 @@ 3274F5EF1D9A633A005282E4 /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 0800; + LastUpgradeCheck = 0810; ORGANIZATIONNAME = matrix.org; TargetAttributes = { 3274F5F71D9A633A005282E4 = { @@ -273,7 +273,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run \'pod install\' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n"; + shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n"; showEnvVarsInLog = 0; }; 793D0533290528B7C0E17CAD /* [CP] Copy Pods Resources */ = { @@ -303,7 +303,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run \'pod install\' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n"; + shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n"; showEnvVarsInLog = 0; }; /* End PBXShellScriptBuildPhase section */ @@ -354,6 +354,7 @@ CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_SUSPICIOUS_MOVES = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; @@ -405,6 +406,7 @@ CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_SUSPICIOUS_MOVES = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; diff --git a/xcode/OLMKit/OLMSession.m b/xcode/OLMKit/OLMSession.m index a47deb1..eee65a9 100644 --- a/xcode/OLMKit/OLMSession.m +++ b/xcode/OLMKit/OLMSession.m @@ -156,6 +156,41 @@ return idString; } +- (BOOL)matchesInboundSession:(NSString *)oneTimeKeyMessage { + NSData *otk = [oneTimeKeyMessage dataUsingEncoding:NSUTF8StringEncoding]; + + size_t result = olm_matches_inbound_session(_session, otk.bytes, otk.length); + if (result == 1) { + return YES; + } + else { + if (result == olm_error()) { + const char *error = olm_session_last_error(_session); + NSLog(@"olm_matches_inbound_session error: %s", error); + } + return NO; + } +} + +- (BOOL)matchesInboundSessionFrom:(NSString *)theirIdentityKey oneTimeKeyMessage:(NSString *)oneTimeKeyMessage { + NSData *idKey = [theirIdentityKey dataUsingEncoding:NSUTF8StringEncoding]; + NSData *otk = [oneTimeKeyMessage dataUsingEncoding:NSUTF8StringEncoding]; + + size_t result = olm_matches_inbound_session_from(_session, + idKey.bytes, idKey.length, + otk.bytes, otk.length); + if (result == 1) { + return YES; + } + else { + if (result == olm_error()) { + const char *error = olm_session_last_error(_session); + NSLog(@"olm_matches_inbound_session error: %s", error); + } + return NO; + } +} + - (OLMMessage*) encryptMessage:(NSString*)message error:(NSError**)error { size_t messageType = olm_encrypt_message_type(_session); size_t randomLength = olm_encrypt_random_length(_session); diff --git a/xcode/OLMKitTests/OLMKitTests.m b/xcode/OLMKitTests/OLMKitTests.m index 251c90e..1adbde2 100644 --- a/xcode/OLMKitTests/OLMKitTests.m +++ b/xcode/OLMKitTests/OLMKitTests.m @@ -52,6 +52,15 @@ NSString *plaintext = [bobSession decryptMessage:aliceToBobMsg error:&error]; XCTAssertEqualObjects(message, plaintext); XCTAssertNil(error); + + XCTAssert([bobSession matchesInboundSession:aliceToBobMsg.ciphertext]); + XCTAssertFalse([aliceSession matchesInboundSession:@"ARandomOtkMessage"]); + + NSString *aliceIdKey = alice.identityKeys[@"curve25519"]; + XCTAssert([bobSession matchesInboundSessionFrom:aliceIdKey oneTimeKeyMessage:aliceToBobMsg.ciphertext]); + XCTAssertFalse([bobSession matchesInboundSessionFrom:@"ARandomIdKey" oneTimeKeyMessage:aliceToBobMsg.ciphertext]); + XCTAssertFalse([bobSession matchesInboundSessionFrom:aliceIdKey oneTimeKeyMessage:@"ARandomOtkMessage"]); + BOOL success = [bob removeOneTimeKeysForSession:bobSession]; XCTAssertTrue(success); } @@ -96,8 +105,6 @@ XCTAssertEqualObjects(msg1, dMsg1); XCTAssertEqualObjects(msg2, dMsg2); XCTAssertEqualObjects(msg3, dMsg3); - - } - (void) testAccountSerialization { diff --git a/xcode/Podfile.lock b/xcode/Podfile.lock index 3ac110a..2d69849 100644 --- a/xcode/Podfile.lock +++ b/xcode/Podfile.lock @@ -13,7 +13,7 @@ EXTERNAL SOURCES: :path: ../OLMKit.podspec SPEC CHECKSUMS: - OLMKit: ed17cdf7695bc0de1e2bf98243eb65f5b9ddebc1 + OLMKit: 5f2894a210ca99ad17128af4fd3beeeeb0eca404 PODFILE CHECKSUM: 4e261dae61d833ec5585ced2473023b98909fd35 -- cgit v1.2.3 From 32a5424971a208cc5cd5eba14211eca5f0f07fd8 Mon Sep 17 00:00:00 2001 From: manuroe Date: Thu, 17 Nov 2016 14:33:41 +0100 Subject: OLMKit: Podfile.lock++ --- xcode/Podfile.lock | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'xcode') diff --git a/xcode/Podfile.lock b/xcode/Podfile.lock index 2d69849..ecafd79 100644 --- a/xcode/Podfile.lock +++ b/xcode/Podfile.lock @@ -1,9 +1,9 @@ PODS: - - OLMKit (2.0.0): - - OLMKit/olmc (= 2.0.0) - - OLMKit/olmcpp (= 2.0.0) - - OLMKit/olmc (2.0.0) - - OLMKit/olmcpp (2.0.0) + - OLMKit (2.0.1): + - OLMKit/olmc (= 2.0.1) + - OLMKit/olmcpp (= 2.0.1) + - OLMKit/olmc (2.0.1) + - OLMKit/olmcpp (2.0.1) DEPENDENCIES: - OLMKit (from `../OLMKit.podspec`) @@ -13,7 +13,7 @@ EXTERNAL SOURCES: :path: ../OLMKit.podspec SPEC CHECKSUMS: - OLMKit: 5f2894a210ca99ad17128af4fd3beeeeb0eca404 + OLMKit: 12a35a69f92c7facdd50b559128d1b4a17857ba7 PODFILE CHECKSUM: 4e261dae61d833ec5585ced2473023b98909fd35 -- cgit v1.2.3 From e19b7f54dc81dcaba6902a2d9202e1587ad5c1a1 Mon Sep 17 00:00:00 2001 From: manuroe Date: Thu, 17 Nov 2016 14:43:04 +0100 Subject: OLMKit: Improve wording --- xcode/README.rst | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'xcode') diff --git a/xcode/README.rst b/xcode/README.rst index db78e57..d56fa85 100644 --- a/xcode/README.rst +++ b/xcode/README.rst @@ -18,5 +18,9 @@ Run `pod install` and open `OLMKit.xcworkspace`. The project contains only tests files. The libolm and the Objective-C wrapper source files are loaded via the OLMKit CocoaPods pod. -To add a new source file, add it to the file system and run `pod update` to make CocoaPods insert into OLMKit.xcworkspace. +To add a new source file, add it to the file system and run `pod update` to make CocoaPods insert it into OLMKit.xcworkspace. + +Release +------- +See ../README.rst for the release of the CocoaPod. -- cgit v1.2.3 From 29de7825c9607955d061c5fe75c7f29d78dfaec5 Mon Sep 17 00:00:00 2001 From: manuroe Date: Thu, 17 Nov 2016 15:50:23 +0100 Subject: OLMKit: Update Copyrights --- xcode/OLMKit/OLMAccount.h | 24 +++++++++++++++++------- xcode/OLMKit/OLMAccount.m | 24 +++++++++++++++++------- xcode/OLMKit/OLMAccount_Private.h | 24 +++++++++++++++++------- xcode/OLMKit/OLMInboundGroupSession.h | 1 + xcode/OLMKit/OLMInboundGroupSession.m | 1 + xcode/OLMKit/OLMKit.h | 24 +++++++++++++++++------- xcode/OLMKit/OLMKit.m | 1 + xcode/OLMKit/OLMMessage.h | 24 +++++++++++++++++------- xcode/OLMKit/OLMMessage.m | 24 +++++++++++++++++------- xcode/OLMKit/OLMOutboundGroupSession.h | 1 + xcode/OLMKit/OLMOutboundGroupSession.m | 1 + xcode/OLMKit/OLMSerializable.h | 24 +++++++++++++++++------- xcode/OLMKit/OLMSession.h | 24 +++++++++++++++++------- xcode/OLMKit/OLMSession.m | 24 +++++++++++++++++------- xcode/OLMKit/OLMSession_Private.h | 24 +++++++++++++++++------- xcode/OLMKit/OLMUtility.h | 24 +++++++++++++++++------- xcode/OLMKit/OLMUtility.m | 24 +++++++++++++++++------- xcode/OLMKitTests/OLMKitGroupTests.m | 1 + xcode/OLMKitTests/OLMKitTests.m | 24 +++++++++++++++++------- 19 files changed, 227 insertions(+), 91 deletions(-) (limited to 'xcode') diff --git a/xcode/OLMKit/OLMAccount.h b/xcode/OLMKit/OLMAccount.h index 382be31..c8d65cd 100644 --- a/xcode/OLMKit/OLMAccount.h +++ b/xcode/OLMKit/OLMAccount.h @@ -1,10 +1,20 @@ -// -// OLMAccount.h -// olm -// -// Created by Chris Ballinger on 4/8/16. -// -// +/* + Copyright 2016 Chris Ballinger + Copyright 2016 OpenMarket Ltd + Copyright 2016 Vector Creations Ltd + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ #import #import "OLMSerializable.h" diff --git a/xcode/OLMKit/OLMAccount.m b/xcode/OLMKit/OLMAccount.m index 4830995..b194a74 100644 --- a/xcode/OLMKit/OLMAccount.m +++ b/xcode/OLMKit/OLMAccount.m @@ -1,10 +1,20 @@ -// -// OLMAccount.m -// olm -// -// Created by Chris Ballinger on 4/8/16. -// -// +/* + Copyright 2016 Chris Ballinger + Copyright 2016 OpenMarket Ltd + Copyright 2016 Vector Creations Ltd + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ #import "OLMAccount.h" #import "OLMAccount_Private.h" diff --git a/xcode/OLMKit/OLMAccount_Private.h b/xcode/OLMKit/OLMAccount_Private.h index b8cf506..313ab71 100644 --- a/xcode/OLMKit/OLMAccount_Private.h +++ b/xcode/OLMKit/OLMAccount_Private.h @@ -1,10 +1,20 @@ -// -// OLMAccount_Private.h -// olm -// -// Created by Chris Ballinger on 4/8/16. -// -// +/* + Copyright 2016 Chris Ballinger + Copyright 2016 OpenMarket Ltd + Copyright 2016 Vector Creations Ltd + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ #include "olm/olm.h" diff --git a/xcode/OLMKit/OLMInboundGroupSession.h b/xcode/OLMKit/OLMInboundGroupSession.h index 40dfce7..ede68e3 100644 --- a/xcode/OLMKit/OLMInboundGroupSession.h +++ b/xcode/OLMKit/OLMInboundGroupSession.h @@ -1,5 +1,6 @@ /* Copyright 2016 OpenMarket Ltd + Copyright 2016 Vector Creations Ltd Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/xcode/OLMKit/OLMInboundGroupSession.m b/xcode/OLMKit/OLMInboundGroupSession.m index 32e1376..eec2ffa 100644 --- a/xcode/OLMKit/OLMInboundGroupSession.m +++ b/xcode/OLMKit/OLMInboundGroupSession.m @@ -1,5 +1,6 @@ /* Copyright 2016 OpenMarket Ltd + Copyright 2016 Vector Creations Ltd Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/xcode/OLMKit/OLMKit.h b/xcode/OLMKit/OLMKit.h index 3865e74..34db111 100644 --- a/xcode/OLMKit/OLMKit.h +++ b/xcode/OLMKit/OLMKit.h @@ -1,10 +1,20 @@ -// -// OLMKit.h -// OLMKit -// -// Created by Chris Ballinger on 4/8/16. -// -// +/* + Copyright 2016 Chris Ballinger + Copyright 2016 OpenMarket Ltd + Copyright 2016 Vector Creations Ltd + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ #import diff --git a/xcode/OLMKit/OLMKit.m b/xcode/OLMKit/OLMKit.m index 0cd4ed5..e7bfd25 100644 --- a/xcode/OLMKit/OLMKit.m +++ b/xcode/OLMKit/OLMKit.m @@ -1,5 +1,6 @@ /* Copyright 2016 OpenMarket Ltd + Copyright 2016 Vector Creations Ltd Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/xcode/OLMKit/OLMMessage.h b/xcode/OLMKit/OLMMessage.h index 97c748f..b6e8c8f 100644 --- a/xcode/OLMKit/OLMMessage.h +++ b/xcode/OLMKit/OLMMessage.h @@ -1,10 +1,20 @@ -// -// OLMMessage.h -// olm -// -// Created by Chris Ballinger on 4/8/16. -// -// +/* + Copyright 2016 Chris Ballinger + Copyright 2016 OpenMarket Ltd + Copyright 2016 Vector Creations Ltd + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ #import diff --git a/xcode/OLMKit/OLMMessage.m b/xcode/OLMKit/OLMMessage.m index d0cfb41..949f834 100644 --- a/xcode/OLMKit/OLMMessage.m +++ b/xcode/OLMKit/OLMMessage.m @@ -1,10 +1,20 @@ -// -// OLMMessage.m -// olm -// -// Created by Chris Ballinger on 4/8/16. -// -// +/* + Copyright 2016 Chris Ballinger + Copyright 2016 OpenMarket Ltd + Copyright 2016 Vector Creations Ltd + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ #import "OLMMessage.h" diff --git a/xcode/OLMKit/OLMOutboundGroupSession.h b/xcode/OLMKit/OLMOutboundGroupSession.h index 4586a25..c979b61 100644 --- a/xcode/OLMKit/OLMOutboundGroupSession.h +++ b/xcode/OLMKit/OLMOutboundGroupSession.h @@ -1,5 +1,6 @@ /* Copyright 2016 OpenMarket Ltd + Copyright 2016 Vector Creations Ltd Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/xcode/OLMKit/OLMOutboundGroupSession.m b/xcode/OLMKit/OLMOutboundGroupSession.m index 9741db1..0046173 100644 --- a/xcode/OLMKit/OLMOutboundGroupSession.m +++ b/xcode/OLMKit/OLMOutboundGroupSession.m @@ -1,5 +1,6 @@ /* Copyright 2016 OpenMarket Ltd + Copyright 2016 Vector Creations Ltd Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/xcode/OLMKit/OLMSerializable.h b/xcode/OLMKit/OLMSerializable.h index b4b115a..e929903 100644 --- a/xcode/OLMKit/OLMSerializable.h +++ b/xcode/OLMKit/OLMSerializable.h @@ -1,10 +1,20 @@ -// -// OLMSerializable.h -// olm -// -// Created by Chris Ballinger on 4/8/16. -// -// +/* + Copyright 2016 Chris Ballinger + Copyright 2016 OpenMarket Ltd + Copyright 2016 Vector Creations Ltd + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ #import diff --git a/xcode/OLMKit/OLMSession.h b/xcode/OLMKit/OLMSession.h index b10e481..0446f98 100644 --- a/xcode/OLMKit/OLMSession.h +++ b/xcode/OLMKit/OLMSession.h @@ -1,10 +1,20 @@ -// -// OLMSession.h -// olm -// -// Created by Chris Ballinger on 4/8/16. -// -// +/* + Copyright 2016 Chris Ballinger + Copyright 2016 OpenMarket Ltd + Copyright 2016 Vector Creations Ltd + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ #import #import "OLMSerializable.h" diff --git a/xcode/OLMKit/OLMSession.m b/xcode/OLMKit/OLMSession.m index eee65a9..e50da75 100644 --- a/xcode/OLMKit/OLMSession.m +++ b/xcode/OLMKit/OLMSession.m @@ -1,10 +1,20 @@ -// -// OLMSession.m -// olm -// -// Created by Chris Ballinger on 4/8/16. -// -// +/* + Copyright 2016 Chris Ballinger + Copyright 2016 OpenMarket Ltd + Copyright 2016 Vector Creations Ltd + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ #import "OLMSession.h" #import "OLMUtility.h" diff --git a/xcode/OLMKit/OLMSession_Private.h b/xcode/OLMKit/OLMSession_Private.h index bd7d25d..28ba5e1 100644 --- a/xcode/OLMKit/OLMSession_Private.h +++ b/xcode/OLMKit/OLMSession_Private.h @@ -1,10 +1,20 @@ -// -// OLMSession_Private.h -// olm -// -// Created by Chris Ballinger on 4/13/16. -// -// +/* + Copyright 2016 Chris Ballinger + Copyright 2016 OpenMarket Ltd + Copyright 2016 Vector Creations Ltd + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ #include "olm/olm.h" diff --git a/xcode/OLMKit/OLMUtility.h b/xcode/OLMKit/OLMUtility.h index c316829..22e9724 100644 --- a/xcode/OLMKit/OLMUtility.h +++ b/xcode/OLMKit/OLMUtility.h @@ -1,10 +1,20 @@ -// -// OLMUtility.h -// olm -// -// Created by Chris Ballinger on 4/8/16. -// -// +/* + Copyright 2016 Chris Ballinger + Copyright 2016 OpenMarket Ltd + Copyright 2016 Vector Creations Ltd + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ #import diff --git a/xcode/OLMKit/OLMUtility.m b/xcode/OLMKit/OLMUtility.m index f9d47c0..936785a 100644 --- a/xcode/OLMKit/OLMUtility.m +++ b/xcode/OLMKit/OLMUtility.m @@ -1,10 +1,20 @@ -// -// OLMUtility.m -// olm -// -// Created by Chris Ballinger on 4/8/16. -// -// +/* + Copyright 2016 Chris Ballinger + Copyright 2016 OpenMarket Ltd + Copyright 2016 Vector Creations Ltd + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ #import "OLMUtility.h" diff --git a/xcode/OLMKitTests/OLMKitGroupTests.m b/xcode/OLMKitTests/OLMKitGroupTests.m index 43e2df8..ea82295 100644 --- a/xcode/OLMKitTests/OLMKitGroupTests.m +++ b/xcode/OLMKitTests/OLMKitGroupTests.m @@ -1,5 +1,6 @@ /* Copyright 2016 OpenMarket Ltd + Copyright 2016 Vector Creations Ltd Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/xcode/OLMKitTests/OLMKitTests.m b/xcode/OLMKitTests/OLMKitTests.m index 1adbde2..ee02420 100644 --- a/xcode/OLMKitTests/OLMKitTests.m +++ b/xcode/OLMKitTests/OLMKitTests.m @@ -1,10 +1,20 @@ -// -// OLMKitTests.m -// OLMKitTests -// -// Created by Chris Ballinger on 4/8/16. -// -// +/* +Copyright 2016 Chris Ballinger +Copyright 2016 OpenMarket Ltd +Copyright 2016 Vector Creations Ltd + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ #import #import -- cgit v1.2.3 From 93926e90477355c671b50704711a58889832b077 Mon Sep 17 00:00:00 2001 From: manuroe Date: Fri, 18 Nov 2016 11:39:39 +0100 Subject: OLMKit: Fixed warnings in objc wrapper --- xcode/OLMKit/OLMAccount.m | 4 ++-- xcode/OLMKit/OLMSession.m | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'xcode') diff --git a/xcode/OLMKit/OLMAccount.m b/xcode/OLMKit/OLMAccount.m index b194a74..2f30fb6 100644 --- a/xcode/OLMKit/OLMAccount.m +++ b/xcode/OLMKit/OLMAccount.m @@ -74,7 +74,7 @@ return self; } -- (size_t) maxOneTimeKeys { +- (NSUInteger) maxOneTimeKeys { return olm_account_max_number_of_one_time_keys(_account); } @@ -156,7 +156,7 @@ - (BOOL) removeOneTimeKeysForSession:(OLMSession *)session { NSParameterAssert(session != nil); if (!session) { - return nil; + return NO; } size_t result = olm_remove_one_time_keys(self.account, session.session); if (result == olm_error()) { diff --git a/xcode/OLMKit/OLMSession.m b/xcode/OLMKit/OLMSession.m index e50da75..3801e08 100644 --- a/xcode/OLMKit/OLMSession.m +++ b/xcode/OLMKit/OLMSession.m @@ -167,9 +167,9 @@ } - (BOOL)matchesInboundSession:(NSString *)oneTimeKeyMessage { - NSData *otk = [oneTimeKeyMessage dataUsingEncoding:NSUTF8StringEncoding]; + NSMutableData *otk = [NSMutableData dataWithData:[oneTimeKeyMessage dataUsingEncoding:NSUTF8StringEncoding]]; - size_t result = olm_matches_inbound_session(_session, otk.bytes, otk.length); + size_t result = olm_matches_inbound_session(_session, otk.mutableBytes, otk.length); if (result == 1) { return YES; } @@ -184,11 +184,11 @@ - (BOOL)matchesInboundSessionFrom:(NSString *)theirIdentityKey oneTimeKeyMessage:(NSString *)oneTimeKeyMessage { NSData *idKey = [theirIdentityKey dataUsingEncoding:NSUTF8StringEncoding]; - NSData *otk = [oneTimeKeyMessage dataUsingEncoding:NSUTF8StringEncoding]; + NSMutableData *otk = [NSMutableData dataWithData:[oneTimeKeyMessage dataUsingEncoding:NSUTF8StringEncoding]]; size_t result = olm_matches_inbound_session_from(_session, idKey.bytes, idKey.length, - otk.bytes, otk.length); + otk.mutableBytes, otk.length); if (result == 1) { return YES; } -- cgit v1.2.3 From aa12cbcac2d9f380847644febdf1f13f102cebb1 Mon Sep 17 00:00:00 2001 From: manuroe Date: Thu, 24 Nov 2016 11:45:59 +0100 Subject: OLMKit: Make returned NSError provide the raw olm error string (ex:"UNKNOWN_MESSAGE_INDEX") in their NSLocalizedDescriptionKey. NSLocalizedFailureReasonErrorKey can contain more contextual information. --- xcode/OLMKit/OLMInboundGroupSession.m | 9 ++++++--- xcode/OLMKit/OLMOutboundGroupSession.m | 3 ++- xcode/OLMKit/OLMSession.m | 18 ++++++++++++------ 3 files changed, 20 insertions(+), 10 deletions(-) (limited to 'xcode') diff --git a/xcode/OLMKit/OLMInboundGroupSession.m b/xcode/OLMKit/OLMInboundGroupSession.m index eec2ffa..4f7bdd7 100644 --- a/xcode/OLMKit/OLMInboundGroupSession.m +++ b/xcode/OLMKit/OLMInboundGroupSession.m @@ -65,7 +65,8 @@ *error = [NSError errorWithDomain:OLMErrorDomain code:0 userInfo:@{ - NSLocalizedDescriptionKey: [NSString stringWithFormat:@"olm_init_inbound_group_session error: %@", errorString] + NSLocalizedDescriptionKey: errorString, + NSLocalizedFailureReasonErrorKey: [NSString stringWithFormat:@"olm_init_inbound_group_session error: %@", errorString] }]; } @@ -110,7 +111,8 @@ *error = [NSError errorWithDomain:OLMErrorDomain code:0 userInfo:@{ - NSLocalizedDescriptionKey: [NSString stringWithFormat:@"olm_group_decrypt_max_plaintext_length error: %@", errorString] + NSLocalizedDescriptionKey: errorString, + NSLocalizedFailureReasonErrorKey: [NSString stringWithFormat:@"olm_group_decrypt_max_plaintext_length error: %@", errorString] }]; } @@ -132,7 +134,8 @@ *error = [NSError errorWithDomain:OLMErrorDomain code:0 userInfo:@{ - NSLocalizedDescriptionKey: [NSString stringWithFormat:@"olm_group_decrypt error: %@", errorString] + NSLocalizedDescriptionKey: errorString, + NSLocalizedFailureReasonErrorKey: [NSString stringWithFormat:@"olm_group_decrypt error: %@", errorString] }]; } diff --git a/xcode/OLMKit/OLMOutboundGroupSession.m b/xcode/OLMKit/OLMOutboundGroupSession.m index 0046173..d838ebc 100644 --- a/xcode/OLMKit/OLMOutboundGroupSession.m +++ b/xcode/OLMKit/OLMOutboundGroupSession.m @@ -118,7 +118,8 @@ *error = [NSError errorWithDomain:OLMErrorDomain code:0 userInfo:@{ - NSLocalizedDescriptionKey: [NSString stringWithFormat:@"olm_group_encrypt error: %@", errorString] + NSLocalizedDescriptionKey: errorString, + NSLocalizedFailureReasonErrorKey: [NSString stringWithFormat:@"olm_group_encrypt error: %@", errorString] }]; } diff --git a/xcode/OLMKit/OLMSession.m b/xcode/OLMKit/OLMSession.m index 3801e08..7cbd358 100644 --- a/xcode/OLMKit/OLMSession.m +++ b/xcode/OLMKit/OLMSession.m @@ -88,7 +88,8 @@ *error = [NSError errorWithDomain:OLMErrorDomain code:0 userInfo:@{ - NSLocalizedDescriptionKey: [NSString stringWithFormat:@"olm_create_outbound_session error: %@", errorString] + NSLocalizedDescriptionKey: errorString, + NSLocalizedFailureReasonErrorKey: [NSString stringWithFormat:@"olm_create_outbound_session error: %@", errorString] }]; } @@ -114,7 +115,8 @@ *error = [NSError errorWithDomain:OLMErrorDomain code:0 userInfo:@{ - NSLocalizedDescriptionKey: [NSString stringWithFormat:@"olm_create_inbound_session error: %@", errorString] + NSLocalizedDescriptionKey: errorString, + NSLocalizedFailureReasonErrorKey: [NSString stringWithFormat:@"olm_create_inbound_session error: %@", errorString] }]; } @@ -141,7 +143,8 @@ *error = [NSError errorWithDomain:OLMErrorDomain code:0 userInfo:@{ - NSLocalizedDescriptionKey: [NSString stringWithFormat:@"olm_create_inbound_session_from error: %@", errorString] + NSLocalizedDescriptionKey: errorString, + NSLocalizedFailureReasonErrorKey: [NSString stringWithFormat:@"olm_create_inbound_session_from error: %@", errorString] }]; } @@ -222,7 +225,8 @@ *error = [NSError errorWithDomain:OLMErrorDomain code:0 userInfo:@{ - NSLocalizedDescriptionKey: [NSString stringWithFormat:@"olm_encrypt error: %@", errorString] + NSLocalizedDescriptionKey: errorString, + NSLocalizedFailureReasonErrorKey: [NSString stringWithFormat:@"olm_encrypt error: %@", errorString] }]; } @@ -251,7 +255,8 @@ *error = [NSError errorWithDomain:OLMErrorDomain code:0 userInfo:@{ - NSLocalizedDescriptionKey: [NSString stringWithFormat:@"olm_decrypt_max_plaintext_length error: %@", errorString] + NSLocalizedDescriptionKey: errorString, + NSLocalizedFailureReasonErrorKey: [NSString stringWithFormat:@"olm_decrypt_max_plaintext_length error: %@", errorString] }]; } @@ -271,7 +276,8 @@ *error = [NSError errorWithDomain:OLMErrorDomain code:0 userInfo:@{ - NSLocalizedDescriptionKey: [NSString stringWithFormat:@"olm_decrypt error: %@", errorString] + NSLocalizedDescriptionKey: errorString, + NSLocalizedFailureReasonErrorKey: [NSString stringWithFormat:@"olm_decrypt error: %@", errorString] }]; } -- cgit v1.2.3 From 3540926b98813e5e5daed709f820f06f6f9ac2ae Mon Sep 17 00:00:00 2001 From: manuroe Date: Mon, 19 Dec 2016 18:10:37 +0100 Subject: OLMKit: Reset intermediate buffers to zeroes --- xcode/OLMKit/OLMAccount.m | 2 ++ xcode/OLMKit/OLMOutboundGroupSession.m | 2 ++ xcode/OLMKit/OLMSession.m | 2 ++ 3 files changed, 6 insertions(+) (limited to 'xcode') diff --git a/xcode/OLMKit/OLMAccount.m b/xcode/OLMKit/OLMAccount.m index 2f30fb6..af1e308 100644 --- a/xcode/OLMKit/OLMAccount.m +++ b/xcode/OLMKit/OLMAccount.m @@ -66,6 +66,7 @@ size_t randomLength = olm_create_account_random_length(_account); NSMutableData *random = [OLMUtility randomBytesOfLength:randomLength]; size_t accountResult = olm_create_account(_account, random.mutableBytes, random.length); + [random resetBytesInRange:NSMakeRange(0, random.length)]; if (accountResult == olm_error()) { const char *error = olm_account_last_error(_account); NSLog(@"error creating account: %s", error); @@ -147,6 +148,7 @@ size_t randomLength = olm_account_generate_one_time_keys_random_length(_account, numberOfKeys); NSMutableData *random = [OLMUtility randomBytesOfLength:randomLength]; size_t result = olm_account_generate_one_time_keys(_account, numberOfKeys, random.mutableBytes, random.length); + [random resetBytesInRange:NSMakeRange(0, random.length)]; if (result == olm_error()) { const char *error = olm_account_last_error(_account); NSLog(@"error generating keys: %s", error); diff --git a/xcode/OLMKit/OLMOutboundGroupSession.m b/xcode/OLMKit/OLMOutboundGroupSession.m index d838ebc..a3421fd 100644 --- a/xcode/OLMKit/OLMOutboundGroupSession.m +++ b/xcode/OLMKit/OLMOutboundGroupSession.m @@ -55,6 +55,7 @@ NSMutableData *random = [OLMUtility randomBytesOfLength:olm_init_outbound_group_session_random_length(session)]; size_t result = olm_init_outbound_group_session(session, random.mutableBytes, random.length); + [random resetBytesInRange:NSMakeRange(0, random.length)]; if (result == olm_error()) { const char *error = olm_outbound_group_session_last_error(session); NSLog(@"olm_init_outbound_group_session error: %s", error); @@ -97,6 +98,7 @@ return nil; } NSString *sessionKey = [[NSString alloc] initWithData:sessionKeyData encoding:NSUTF8StringEncoding]; + [sessionKeyData resetBytesInRange:NSMakeRange(0, sessionKeyData.length)]; return sessionKey; } diff --git a/xcode/OLMKit/OLMSession.m b/xcode/OLMKit/OLMSession.m index 7cbd358..2111c1c 100644 --- a/xcode/OLMKit/OLMSession.m +++ b/xcode/OLMKit/OLMSession.m @@ -78,6 +78,7 @@ NSData *idKey = [theirIdentityKey dataUsingEncoding:NSUTF8StringEncoding]; NSData *otKey = [theirOneTimeKey dataUsingEncoding:NSUTF8StringEncoding]; size_t result = olm_create_outbound_session(_session, account.account, idKey.bytes, idKey.length, otKey.bytes, otKey.length, random.mutableBytes, random.length); + [random resetBytesInRange:NSMakeRange(0, random.length)]; if (result == olm_error()) { const char *olm_error = olm_session_last_error(_session); @@ -215,6 +216,7 @@ return nil; } size_t result = olm_encrypt(_session, plaintextData.bytes, plaintextData.length, random.mutableBytes, random.length, ciphertext.mutableBytes, ciphertext.length); + [random resetBytesInRange:NSMakeRange(0, random.length)]; if (result == olm_error()) { const char *olm_error = olm_session_last_error(_session); -- cgit v1.2.3 From 46ad79517ec8e005bd2d1de767d3cd59ec038fe2 Mon Sep 17 00:00:00 2001 From: manuroe Date: Tue, 20 Dec 2016 11:46:57 +0100 Subject: OLMKit: More zeroing --- xcode/OLMKit/OLMInboundGroupSession.m | 1 + xcode/OLMKit/OLMSession.m | 1 + 2 files changed, 2 insertions(+) (limited to 'xcode') diff --git a/xcode/OLMKit/OLMInboundGroupSession.m b/xcode/OLMKit/OLMInboundGroupSession.m index 4f7bdd7..6ef51c3 100644 --- a/xcode/OLMKit/OLMInboundGroupSession.m +++ b/xcode/OLMKit/OLMInboundGroupSession.m @@ -143,6 +143,7 @@ } plaintextData.length = plaintextLength; NSString *plaintext = [[NSString alloc] initWithData:plaintextData encoding:NSUTF8StringEncoding]; + [plaintextData resetBytesInRange:NSMakeRange(0, plaintextData.length)]; if (messageIndex) { diff --git a/xcode/OLMKit/OLMSession.m b/xcode/OLMKit/OLMSession.m index 2111c1c..8c29113 100644 --- a/xcode/OLMKit/OLMSession.m +++ b/xcode/OLMKit/OLMSession.m @@ -287,6 +287,7 @@ } plaintextData.length = plaintextLength; NSString *plaintext = [[NSString alloc] initWithData:plaintextData encoding:NSUTF8StringEncoding]; + [plaintextData resetBytesInRange:NSMakeRange(0, plaintextData.length)]; return plaintext; } -- cgit v1.2.3