olm/xcode/OLMKit/OLMUtility.h

40 lines
1000 B
C
Raw Normal View History

2016-04-09 02:24:41 +02:00
//
// OLMUtility.h
// olm
//
// Created by Chris Ballinger on 4/8/16.
//
//
#import <Foundation/Foundation.h>
2016-11-14 16:54:51 +01:00
FOUNDATION_EXPORT NSString *const OLMErrorDomain;
2016-04-09 02:24:41 +02:00
@interface OLMUtility : NSObject
2016-10-17 15:47:52 +02:00
/**
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;
2016-09-28 16:07:39 +02:00
/**
Verify an ed25519 signature.
2016-10-14 15:57:12 +02:00
@param signature the base64-encoded signature to be checked.
2016-09-28 16:07:39 +02:00
@param key the ed25519 key.
@param message the message which was signed.
@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.
*/
2016-10-14 15:57:12 +02:00
- (BOOL)verifyEd25519Signature:(NSString*)signature key:(NSString*)key message:(NSData*)message error:(NSError**)error;
2016-09-28 16:07:39 +02:00
2016-04-09 23:00:30 +02:00
+ (NSMutableData*) randomBytesOfLength:(NSUInteger)length;
2016-04-09 02:24:41 +02:00
@end