Unverified Commit b12fe0ae authored by Hubert Chathi's avatar Hubert Chathi Committed by GitHub
Browse files

Merge pull request #88 from matrix-org/manuroe/sas_pksigning

OLMKit: add Short Authentication String verification
parents 086133f3 5147349f
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -93,7 +93,7 @@ size_t olm_sas_get_pubkey(
 *
 *
 * @param[in] sas the SAS object.
 * @param[in] sas the SAS object.
 * @param[in] their_key the other user's public key.
 * @param[in] their_key the other user's public key.
 * @param[in] their_key_size the size of the `their_key` buffer.
 * @param[in] their_key_length the size of the `their_key` buffer.
 *
 *
 * @return `olm_error()` on failure.  If the `their_key` buffer is too small,
 * @return `olm_error()` on failure.  If the `their_key` buffer is too small,
 * then `olm_sas_last_error()` will be `INPUT_BUFFER_TOO_SMALL`.
 * then `olm_sas_last_error()` will be `INPUT_BUFFER_TOO_SMALL`.
+4 −0
Original line number Original line Diff line number Diff line
@@ -12,6 +12,7 @@
		3274F6071D9A633A005282E4 /* OLMKitTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 3274F6061D9A633A005282E4 /* OLMKitTests.m */; };
		3274F6071D9A633A005282E4 /* OLMKitTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 3274F6061D9A633A005282E4 /* OLMKitTests.m */; };
		3274F6131D9A698E005282E4 /* OLMKit.h in Headers */ = {isa = PBXBuildFile; fileRef = 3274F6121D9A698E005282E4 /* OLMKit.h */; };
		3274F6131D9A698E005282E4 /* OLMKit.h in Headers */ = {isa = PBXBuildFile; fileRef = 3274F6121D9A698E005282E4 /* OLMKit.h */; };
		32A151311DABDD4300400192 /* OLMKitGroupTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 32A151301DABDD4300400192 /* OLMKitGroupTests.m */; };
		32A151311DABDD4300400192 /* OLMKitGroupTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 32A151301DABDD4300400192 /* OLMKitGroupTests.m */; };
		32F143AF2236B4100077CF37 /* OLMKitSASTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 32F143AE2236B4100077CF37 /* OLMKitSASTests.m */; };
		7DBAD311AEA85CF6DB80DCFA /* libPods-OLMKitTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 7123FABE917D0FB140E036B7 /* libPods-OLMKitTests.a */; };
		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 */; };
		D667051A0BA47E17CCC4E5D7 /* libPods-OLMKit.a in Frameworks */ = {isa = PBXBuildFile; fileRef = F2F22FE8F173AF845B882805 /* libPods-OLMKit.a */; };
/* End PBXBuildFile section */
/* End PBXBuildFile section */
@@ -36,6 +37,7 @@
		3274F6081D9A633A005282E4 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
		3274F6081D9A633A005282E4 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
		3274F6121D9A698E005282E4 /* OLMKit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OLMKit.h; sourceTree = "<group>"; };
		3274F6121D9A698E005282E4 /* OLMKit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OLMKit.h; sourceTree = "<group>"; };
		32A151301DABDD4300400192 /* OLMKitGroupTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OLMKitGroupTests.m; sourceTree = "<group>"; };
		32A151301DABDD4300400192 /* OLMKitGroupTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OLMKitGroupTests.m; sourceTree = "<group>"; };
		32F143AE2236B4100077CF37 /* OLMKitSASTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = OLMKitSASTests.m; sourceTree = "<group>"; };
		7123FABE917D0FB140E036B7 /* libPods-OLMKitTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-OLMKitTests.a"; sourceTree = BUILT_PRODUCTS_DIR; };
		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 = "<group>"; };
		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 = "<group>"; };
		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 = "<group>"; };
		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 = "<group>"; };
@@ -107,6 +109,7 @@
		3274F6051D9A633A005282E4 /* OLMKitTests */ = {
		3274F6051D9A633A005282E4 /* OLMKitTests */ = {
			isa = PBXGroup;
			isa = PBXGroup;
			children = (
			children = (
				32F143AE2236B4100077CF37 /* OLMKitSASTests.m */,
				3244277C2175EF700023EDF1 /* OLMKitPkTests.m */,
				3244277C2175EF700023EDF1 /* OLMKitPkTests.m */,
				3274F6061D9A633A005282E4 /* OLMKitTests.m */,
				3274F6061D9A633A005282E4 /* OLMKitTests.m */,
				32A151301DABDD4300400192 /* OLMKitGroupTests.m */,
				32A151301DABDD4300400192 /* OLMKitGroupTests.m */,
@@ -282,6 +285,7 @@
			buildActionMask = 2147483647;
			buildActionMask = 2147483647;
			files = (
			files = (
				3274F6071D9A633A005282E4 /* OLMKitTests.m in Sources */,
				3274F6071D9A633A005282E4 /* OLMKitTests.m in Sources */,
				32F143AF2236B4100077CF37 /* OLMKitSASTests.m in Sources */,
				3244277D2175EF700023EDF1 /* OLMKitPkTests.m in Sources */,
				3244277D2175EF700023EDF1 /* OLMKitPkTests.m in Sources */,
				32A151311DABDD4300400192 /* OLMKitGroupTests.m in Sources */,
				32A151311DABDD4300400192 /* OLMKitGroupTests.m in Sources */,
			);
			);
+2 −0
Original line number Original line Diff line number Diff line
@@ -28,6 +28,8 @@
#import <OLMKit/OLMOutboundGroupSession.h>
#import <OLMKit/OLMOutboundGroupSession.h>
#import <OLMKit/OLMPkEncryption.h>
#import <OLMKit/OLMPkEncryption.h>
#import <OLMKit/OLMPkDecryption.h>
#import <OLMKit/OLMPkDecryption.h>
#import <OLMKit/OLMPkSigning.h>
#import <OLMKit/OLMSAS.h>


@interface OLMKit : NSObject
@interface OLMKit : NSObject


+2 −2
Original line number Original line Diff line number Diff line
@@ -65,13 +65,13 @@


    size_t macLength = olm_pk_mac_length(session);
    size_t macLength = olm_pk_mac_length(session);
    NSMutableData *macData = [NSMutableData dataWithLength:macLength];
    NSMutableData *macData = [NSMutableData dataWithLength:macLength];
    if (!ciphertext) {
    if (!macData) {
        return nil;
        return nil;
    }
    }


    size_t ephemeralKeyLength = olm_pk_key_length();
    size_t ephemeralKeyLength = olm_pk_key_length();
    NSMutableData *ephemeralKeyData = [NSMutableData dataWithLength:ephemeralKeyLength];
    NSMutableData *ephemeralKeyData = [NSMutableData dataWithLength:ephemeralKeyLength];
    if (!ciphertext) {
    if (!ephemeralKeyData) {
        return nil;
        return nil;
    }
    }


+49 −0
Original line number Original line Diff line number Diff line
/*
 Copyright 2019 New Vector 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 <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN

@interface OLMPkSigning : NSObject

/**
 Initialise the signing object with a public/private keypair from a seed.

 @param seed the seed.
 @param error the error if any.
 @return the public key
 */
- (NSString *)doInitWithSeed:(NSData*)seed error:(NSError* _Nullable *)error;

/**
 Sign a message.

 @param message the message to sign.
 @param error the error if any.
 @return the signature.
 */
- (NSString *)sign:(NSString*)message error:(NSError* _Nullable *)error;

/**
 Generate a seed.

 @return the generated seed.
 */
+ (NSData *)generateSeed;

@end

NS_ASSUME_NONNULL_END
Loading