|
|
@ -28,6 +28,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
NS_ASSUME_NONNULL_BEGIN
|
|
|
|
NS_ASSUME_NONNULL_BEGIN
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
NSError *EnsureDecryptError(nullable NSError *error, NSString *fallbackErrorDescription)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (error) {
|
|
|
|
|
|
|
|
return error;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return OWSErrorWithCodeDescription(OWSErrorCodeFailedToDecryptUDMessage, fallbackErrorDescription);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@interface OWSMessageDecrypter ()
|
|
|
|
@interface OWSMessageDecrypter ()
|
|
|
|
|
|
|
|
|
|
|
|
@property (nonatomic, readonly) OWSPrimaryStorage *primaryStorage;
|
|
|
|
@property (nonatomic, readonly) OWSPrimaryStorage *primaryStorage;
|
|
|
@ -350,7 +358,8 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
|
identityStore:self.identityManager
|
|
|
|
identityStore:self.identityManager
|
|
|
|
error:&error];
|
|
|
|
error:&error];
|
|
|
|
if (error || !cipher) {
|
|
|
|
if (error || !cipher) {
|
|
|
|
OWSFailDebug(@"%@", @"Could not create secret session cipher: %@", error);
|
|
|
|
OWSFailDebug(@"Could not create secret session cipher: %@", error);
|
|
|
|
|
|
|
|
error = EnsureDecryptError(error, @"Could not create secret session cipher");
|
|
|
|
return failureBlock(error);
|
|
|
|
return failureBlock(error);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -361,7 +370,8 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
|
protocolContext:transaction
|
|
|
|
protocolContext:transaction
|
|
|
|
error:&error];
|
|
|
|
error:&error];
|
|
|
|
if (error || !decryptResult) {
|
|
|
|
if (error || !decryptResult) {
|
|
|
|
OWSFailDebug(@"%@", @"Could not decrypt UD message: %@", error);
|
|
|
|
OWSFailDebug(@"Could not decrypt UD message: %@", error);
|
|
|
|
|
|
|
|
error = EnsureDecryptError(error, @"Could not decrypt UD message");
|
|
|
|
return failureBlock(error);
|
|
|
|
return failureBlock(error);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -386,10 +396,8 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
|
[envelopeBuilder setSourceDevice:(uint32_t)sourceDeviceId];
|
|
|
|
[envelopeBuilder setSourceDevice:(uint32_t)sourceDeviceId];
|
|
|
|
NSData *_Nullable newEnvelopeData = [envelopeBuilder buildSerializedDataAndReturnError:&error];
|
|
|
|
NSData *_Nullable newEnvelopeData = [envelopeBuilder buildSerializedDataAndReturnError:&error];
|
|
|
|
if (error || !newEnvelopeData) {
|
|
|
|
if (error || !newEnvelopeData) {
|
|
|
|
NSString *errorDescription =
|
|
|
|
OWSFailDebug(@"Could not update UD envelope data: %@", error);
|
|
|
|
[NSString stringWithFormat:@"Could not update UD envelope data: %@", error];
|
|
|
|
error = EnsureDecryptError(error, @"Could not update UD envelope data");
|
|
|
|
OWSFailDebug(@"%@", errorDescription);
|
|
|
|
|
|
|
|
NSError *error = OWSErrorWithCodeDescription(OWSErrorCodeFailedToDecryptMessage, errorDescription);
|
|
|
|
|
|
|
|
return failureBlock(error);
|
|
|
|
return failureBlock(error);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|