Exception wrap PreKeyWhisperMessage for Swift

This commit is contained in:
Michael Kirk 2018-10-29 09:57:34 -06:00
parent 60769a3d17
commit 1482c600b4
2 changed files with 8 additions and 8 deletions

View file

@ -112,7 +112,7 @@ NS_ASSUME_NONNULL_BEGIN
}
}
- (nullable NSData *)newIdentityKey
- (nullable NSData *)try_newIdentityKey
{
if (!self.envelope) {
OWSLogError(@"Error message had no envelope data to extract key from");
@ -130,7 +130,7 @@ NS_ASSUME_NONNULL_BEGIN
return nil;
}
PreKeyWhisperMessage *message = [[PreKeyWhisperMessage alloc] initWithData:pkwmData];
PreKeyWhisperMessage *message = [[PreKeyWhisperMessage alloc] init_try_withData:pkwmData];
return [message.identityKey removeKeyType];
}

View file

@ -229,7 +229,7 @@ NSError *EnsureDecryptError(NSError *_Nullable error, NSString *fallbackErrorDes
return;
}
case SSKProtoEnvelopeTypePrekeyBundle: {
[self decryptPreKeyBundle:envelope
[self try_decryptPreKeyBundle:envelope
envelopeData:envelopeData
successBlock:^(OWSMessageDecryptResult *result, YapDatabaseReadWriteTransaction *transaction) {
OWSLogDebug(@"decrypted pre-key whisper message");
@ -318,10 +318,10 @@ NSError *EnsureDecryptError(NSError *_Nullable error, NSString *fallbackErrorDes
failureBlock:failureBlock];
}
- (void)decryptPreKeyBundle:(SSKProtoEnvelope *)envelope
envelopeData:(NSData *)envelopeData
successBlock:(DecryptSuccessBlock)successBlock
failureBlock:(void (^)(NSError *_Nullable error))failureBlock
- (void)try_decryptPreKeyBundle:(SSKProtoEnvelope *)envelope
envelopeData:(NSData *)envelopeData
successBlock:(DecryptSuccessBlock)successBlock
failureBlock:(void (^)(NSError *_Nullable error))failureBlock
{
OWSAssertDebug(envelope);
OWSAssertDebug(envelopeData);
@ -335,7 +335,7 @@ NSError *EnsureDecryptError(NSError *_Nullable error, NSString *fallbackErrorDes
envelopeData:envelopeData
cipherTypeName:@"PreKey Bundle"
cipherMessageBlock:^(NSData *encryptedData) {
return [[PreKeyWhisperMessage alloc] initWithData:encryptedData];
return [[PreKeyWhisperMessage alloc] init_try_withData:encryptedData];
}
successBlock:successBlock
failureBlock:failureBlock];