2017-09-14 17:00:30 +02:00
|
|
|
//
|
2018-01-30 21:05:04 +01:00
|
|
|
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
2017-09-14 17:00:30 +02:00
|
|
|
//
|
|
|
|
|
|
|
|
#import "OWSMessageHandler.h"
|
|
|
|
|
|
|
|
NS_ASSUME_NONNULL_BEGIN
|
|
|
|
|
2018-10-02 15:34:34 +02:00
|
|
|
@class OWSPrimaryStorage;
|
2018-08-01 16:45:21 +02:00
|
|
|
@class SSKProtoEnvelope;
|
2018-01-30 21:05:04 +01:00
|
|
|
@class YapDatabaseReadWriteTransaction;
|
2017-09-14 17:00:30 +02:00
|
|
|
|
2018-10-02 17:25:58 +02:00
|
|
|
// Decryption result includes the envelope since the envelope
|
|
|
|
// may be altered by the decryption process.
|
|
|
|
typedef void (^DecryptSuccessBlock)(
|
|
|
|
NSData *envelopeData, NSData *_Nullable plaintextData, YapDatabaseReadWriteTransaction *transaction);
|
2017-12-01 01:57:56 +01:00
|
|
|
typedef void (^DecryptFailureBlock)(void);
|
2017-09-14 17:00:30 +02:00
|
|
|
|
|
|
|
@interface OWSMessageDecrypter : OWSMessageHandler
|
|
|
|
|
|
|
|
- (instancetype)init NS_UNAVAILABLE;
|
2018-10-02 15:34:34 +02:00
|
|
|
- (instancetype)initWithPrimaryStorage:(OWSPrimaryStorage *)primaryStorage NS_DESIGNATED_INITIALIZER;
|
2017-09-14 17:00:30 +02:00
|
|
|
|
|
|
|
// decryptEnvelope: can be called from any thread.
|
2017-09-21 20:42:05 +02:00
|
|
|
// successBlock & failureBlock will be called an arbitrary thread.
|
2017-09-14 17:00:30 +02:00
|
|
|
//
|
|
|
|
// Exactly one of successBlock & failureBlock will be called,
|
|
|
|
// once.
|
2018-08-01 16:45:21 +02:00
|
|
|
- (void)decryptEnvelope:(SSKProtoEnvelope *)envelope
|
2018-10-02 17:25:58 +02:00
|
|
|
envelopeData:(NSData *)envelopeData
|
2017-09-14 17:00:30 +02:00
|
|
|
successBlock:(DecryptSuccessBlock)successBlock
|
|
|
|
failureBlock:(DecryptFailureBlock)failureBlock;
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
NS_ASSUME_NONNULL_END
|