mirror of https://github.com/oxen-io/session-ios
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
1.2 KiB
Objective-C
32 lines
1.2 KiB
Objective-C
// Created by Christine Corbett Moran on 3/26/13.
|
|
// Copyright (c) 2013 Open Whisper Systems. All rights reserved.
|
|
|
|
@interface Cryptography : NSObject
|
|
|
|
typedef NS_ENUM(NSInteger, TSMACType) {
|
|
TSHMACSHA1Truncated10Bytes = 1,
|
|
TSHMACSHA256Truncated10Bytes = 2,
|
|
TSHMACSHA256AttachementType = 3
|
|
};
|
|
|
|
+ (NSMutableData *)generateRandomBytes:(NSUInteger)numberBytes;
|
|
|
|
#pragma mark SHA and HMAC methods
|
|
|
|
+ (NSData *)computeSHA256:(NSData *)data truncatedToBytes:(NSUInteger)truncatedBytes;
|
|
+ (NSString *)truncatedSHA1Base64EncodedWithoutPadding:(NSString *)string;
|
|
+ (NSString *)computeSHA1DigestForString:(NSString *)input;
|
|
|
|
+ (NSData *)computeSHA256HMAC:(NSData *)dataToHMAC withHMACKey:(NSData *)HMACKey;
|
|
+ (NSData *)computeSHA1HMAC:(NSData *)dataToHMAC withHMACKey:(NSData *)HMACKey;
|
|
+ (NSData *)truncatedSHA1HMAC:(NSData *)dataToHMAC withHMACKey:(NSData *)HMACKey truncation:(NSUInteger)bytes;
|
|
|
|
+ (NSData *)decryptAppleMessagePayload:(NSData *)payload withSignalingKey:(NSString *)signalingKeyString;
|
|
|
|
#pragma mark encrypt and decrypt attachment data
|
|
+ (NSData *)decryptAttachment:(NSData *)dataToDecrypt withKey:(NSData *)key;
|
|
|
|
+ (NSData *)encryptAttachmentData:(NSData *)attachmentData outKey:(NSData **)outKey;
|
|
|
|
@end
|