Merge tag '2.31.0.38' into release/2.32.0
This commit is contained in:
commit
6935761ab9
|
@ -268,7 +268,7 @@ CHECKOUT OPTIONS:
|
||||||
:commit: b60dc7d58dfc93ca6eafbb3ea5300c6d67ebc69a
|
:commit: b60dc7d58dfc93ca6eafbb3ea5300c6d67ebc69a
|
||||||
:git: https://github.com/signalapp/SignalCoreKit.git
|
:git: https://github.com/signalapp/SignalCoreKit.git
|
||||||
SignalMetadataKit:
|
SignalMetadataKit:
|
||||||
:commit: 8a586363921b4546bea99b07c06bf5c93eab7973
|
:commit: a5473c8d33602775e00253afce78eef01a69260e
|
||||||
:git: https://github.com/signalapp/SignalMetadataKit
|
:git: https://github.com/signalapp/SignalMetadataKit
|
||||||
SocketRocket:
|
SocketRocket:
|
||||||
:commit: 9f9563a83cd8960503074aa8de72206f83fb7a69
|
:commit: 9f9563a83cd8960503074aa8de72206f83fb7a69
|
||||||
|
|
2
Pods
2
Pods
|
@ -1 +1 @@
|
||||||
Subproject commit f37c2be71311c32278846302dd312623f67254a3
|
Subproject commit 766456e3637a2e07d40c5a0a6bfd68d611ab7bd4
|
|
@ -37,6 +37,7 @@ NSError *EnsureDecryptError(NSError *_Nullable error, NSString *fallbackErrorDes
|
||||||
if (error) {
|
if (error) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
OWSCFailDebug(@"Caller should provide specific error");
|
||||||
return OWSErrorWithCodeDescription(OWSErrorCodeFailedToDecryptUDMessage, fallbackErrorDescription);
|
return OWSErrorWithCodeDescription(OWSErrorCodeFailedToDecryptUDMessage, fallbackErrorDescription);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -434,20 +435,20 @@ NSError *EnsureDecryptError(NSError *_Nullable error, NSString *fallbackErrorDes
|
||||||
uint32_t localDeviceId = OWSDevicePrimaryDeviceId;
|
uint32_t localDeviceId = OWSDevicePrimaryDeviceId;
|
||||||
|
|
||||||
[self.dbConnection asyncReadWriteWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
|
[self.dbConnection asyncReadWriteWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
|
||||||
@try {
|
NSError *cipherError;
|
||||||
NSError *error;
|
|
||||||
SMKSecretSessionCipher *_Nullable cipher =
|
SMKSecretSessionCipher *_Nullable cipher =
|
||||||
[[SMKSecretSessionCipher alloc] initWithSessionStore:self.primaryStorage
|
[[SMKSecretSessionCipher alloc] initWithSessionStore:self.primaryStorage
|
||||||
preKeyStore:self.primaryStorage
|
preKeyStore:self.primaryStorage
|
||||||
signedPreKeyStore:self.primaryStorage
|
signedPreKeyStore:self.primaryStorage
|
||||||
identityStore:self.identityManager
|
identityStore:self.identityManager
|
||||||
error:&error];
|
error:&cipherError];
|
||||||
if (error || !cipher) {
|
if (cipherError || !cipher) {
|
||||||
OWSFailDebug(@"Could not create secret session cipher: %@", error);
|
OWSFailDebug(@"Could not create secret session cipher: %@", cipherError);
|
||||||
error = EnsureDecryptError(error, @"Could not create secret session cipher");
|
cipherError = EnsureDecryptError(cipherError, @"Could not create secret session cipher");
|
||||||
return failureBlock(error);
|
return failureBlock(cipherError);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NSError *decryptError;
|
||||||
SMKDecryptResult *_Nullable decryptResult =
|
SMKDecryptResult *_Nullable decryptResult =
|
||||||
[cipher throwswrapped_decryptMessageWithCertificateValidator:certificateValidator
|
[cipher throwswrapped_decryptMessageWithCertificateValidator:certificateValidator
|
||||||
cipherTextData:encryptedData
|
cipherTextData:encryptedData
|
||||||
|
@ -455,19 +456,79 @@ NSError *EnsureDecryptError(NSError *_Nullable error, NSString *fallbackErrorDes
|
||||||
localRecipientId:localRecipientId
|
localRecipientId:localRecipientId
|
||||||
localDeviceId:localDeviceId
|
localDeviceId:localDeviceId
|
||||||
protocolContext:transaction
|
protocolContext:transaction
|
||||||
error:&error];
|
error:&decryptError];
|
||||||
SCKRaiseIfExceptionWrapperError(error);
|
|
||||||
|
|
||||||
if (error || !decryptResult) {
|
if (!decryptResult) {
|
||||||
if ([error.domain isEqualToString:@"SignalMetadataKit.SMKSecretSessionCipherError"]
|
if (!decryptError) {
|
||||||
&& error.code == SMKSecretSessionCipherErrorSelfSentMessage) {
|
OWSFailDebug(@"Caller should provide specific error");
|
||||||
// Self-sent messages can be safely discarded.
|
NSError *error = OWSErrorWithCodeDescription(
|
||||||
|
OWSErrorCodeFailedToDecryptUDMessage, @"Could not decrypt UD message");
|
||||||
return failureBlock(error);
|
return failureBlock(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
OWSFailDebug(@"Could not decrypt UD message: %@", error);
|
// Decrypt Failure Part 1: Unwrap failure details
|
||||||
error = EnsureDecryptError(error, @"Could not decrypt UD message");
|
|
||||||
return failureBlock(error);
|
NSError *_Nullable underlyingError;
|
||||||
|
SSKProtoEnvelope *_Nullable identifiedEnvelope;
|
||||||
|
|
||||||
|
if (![decryptError.domain isEqualToString:@"SignalMetadataKit.SecretSessionKnownSenderError"]) {
|
||||||
|
underlyingError = decryptError;
|
||||||
|
identifiedEnvelope = envelope;
|
||||||
|
} else {
|
||||||
|
underlyingError = decryptError.userInfo[NSUnderlyingErrorKey];
|
||||||
|
|
||||||
|
NSString *senderRecipientId
|
||||||
|
= decryptError.userInfo[SecretSessionKnownSenderError.kSenderRecipientIdKey];
|
||||||
|
OWSAssert(senderRecipientId);
|
||||||
|
|
||||||
|
NSNumber *senderDeviceId = decryptError.userInfo[SecretSessionKnownSenderError.kSenderDeviceIdKey];
|
||||||
|
OWSAssert(senderDeviceId);
|
||||||
|
|
||||||
|
SSKProtoEnvelopeBuilder *identifiedEnvelopeBuilder = envelope.asBuilder;
|
||||||
|
identifiedEnvelopeBuilder.source = senderRecipientId;
|
||||||
|
identifiedEnvelopeBuilder.sourceDevice = senderDeviceId.unsignedIntValue;
|
||||||
|
NSError *identifiedEnvelopeBuilderError;
|
||||||
|
|
||||||
|
identifiedEnvelope = [identifiedEnvelopeBuilder buildAndReturnError:&identifiedEnvelopeBuilderError];
|
||||||
|
if (identifiedEnvelopeBuilderError) {
|
||||||
|
OWSFailDebug(@"failure identifiedEnvelopeBuilderError: %@", identifiedEnvelopeBuilderError);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
OWSAssert(underlyingError);
|
||||||
|
OWSAssert(identifiedEnvelope);
|
||||||
|
|
||||||
|
NSException *_Nullable underlyingException;
|
||||||
|
if ([underlyingError.domain isEqualToString:SCKExceptionWrapperErrorDomain]
|
||||||
|
&& underlyingError.code == SCKExceptionWrapperErrorThrown) {
|
||||||
|
|
||||||
|
underlyingException = underlyingError.userInfo[SCKExceptionWrapperUnderlyingExceptionKey];
|
||||||
|
OWSAssert(underlyingException);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Decrypt Failure Part 2: Handle unwrapped failure details
|
||||||
|
|
||||||
|
if (underlyingException) {
|
||||||
|
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
||||||
|
[self processException:underlyingException envelope:identifiedEnvelope];
|
||||||
|
NSString *errorDescription = [NSString
|
||||||
|
stringWithFormat:@"Exception while decrypting ud message: %@", underlyingException.description];
|
||||||
|
OWSLogError(@"%@", errorDescription);
|
||||||
|
NSError *error = OWSErrorWithCodeDescription(OWSErrorCodeFailedToDecryptMessage, errorDescription);
|
||||||
|
failureBlock(error);
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ([underlyingError.domain isEqualToString:@"SignalMetadataKit.SMKSecretSessionCipherError"]
|
||||||
|
&& underlyingError.code == SMKSecretSessionCipherErrorSelfSentMessage) {
|
||||||
|
// Self-sent messages can be safely discarded.
|
||||||
|
failureBlock(underlyingError);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
OWSFailDebug(@"Could not decrypt UD message: %@", underlyingError);
|
||||||
|
failureBlock(underlyingError);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (decryptResult.messageType == SMKMessageTypePrekey) {
|
if (decryptResult.messageType == SMKMessageTypePrekey) {
|
||||||
|
@ -494,10 +555,11 @@ NSError *EnsureDecryptError(NSError *_Nullable error, NSString *fallbackErrorDes
|
||||||
SSKProtoEnvelopeBuilder *envelopeBuilder = [envelope asBuilder];
|
SSKProtoEnvelopeBuilder *envelopeBuilder = [envelope asBuilder];
|
||||||
[envelopeBuilder setSource:source];
|
[envelopeBuilder setSource:source];
|
||||||
[envelopeBuilder setSourceDevice:(uint32_t)sourceDeviceId];
|
[envelopeBuilder setSourceDevice:(uint32_t)sourceDeviceId];
|
||||||
NSData *_Nullable newEnvelopeData = [envelopeBuilder buildSerializedDataAndReturnError:&error];
|
NSError *envelopeBuilderError;
|
||||||
if (error || !newEnvelopeData) {
|
NSData *_Nullable newEnvelopeData = [envelopeBuilder buildSerializedDataAndReturnError:&envelopeBuilderError];
|
||||||
OWSFailDebug(@"Could not update UD envelope data: %@", error);
|
if (envelopeBuilderError || !newEnvelopeData) {
|
||||||
error = EnsureDecryptError(error, @"Could not update UD envelope data");
|
OWSFailDebug(@"Could not update UD envelope data: %@", envelopeBuilderError);
|
||||||
|
NSError *error = EnsureDecryptError(envelopeBuilderError, @"Could not update UD envelope data");
|
||||||
return failureBlock(error);
|
return failureBlock(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -507,16 +569,6 @@ NSError *EnsureDecryptError(NSError *_Nullable error, NSString *fallbackErrorDes
|
||||||
sourceDevice:(uint32_t)sourceDeviceId
|
sourceDevice:(uint32_t)sourceDeviceId
|
||||||
isUDMessage:YES];
|
isUDMessage:YES];
|
||||||
successBlock(result, transaction);
|
successBlock(result, transaction);
|
||||||
} @catch (NSException *exception) {
|
|
||||||
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
|
||||||
[self processException:exception envelope:envelope];
|
|
||||||
NSString *errorDescription =
|
|
||||||
[NSString stringWithFormat:@"Exception while decrypting ud message: %@", exception.description];
|
|
||||||
OWSLogError(@"%@", errorDescription);
|
|
||||||
NSError *error = OWSErrorWithCodeDescription(OWSErrorCodeFailedToDecryptMessage, errorDescription);
|
|
||||||
failureBlock(error);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -525,10 +577,16 @@ NSError *EnsureDecryptError(NSError *_Nullable error, NSString *fallbackErrorDes
|
||||||
OWSLogError(
|
OWSLogError(
|
||||||
@"Got exception: %@ of type: %@ with reason: %@", exception.description, exception.name, exception.reason);
|
@"Got exception: %@ of type: %@ with reason: %@", exception.description, exception.name, exception.reason);
|
||||||
|
|
||||||
|
|
||||||
[self.dbConnection readWriteWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
|
[self.dbConnection readWriteWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
|
||||||
TSErrorMessage *errorMessage;
|
TSErrorMessage *errorMessage;
|
||||||
|
|
||||||
|
if (envelope.source.length == 0) {
|
||||||
|
TSErrorMessage *errorMessage = [TSErrorMessage corruptedMessageInUnknownThread];
|
||||||
|
[SSKEnvironment.shared.notificationsManager notifyUserForThreadlessErrorMessage:errorMessage
|
||||||
|
transaction:transaction];
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if ([exception.name isEqualToString:NoSessionException]) {
|
if ([exception.name isEqualToString:NoSessionException]) {
|
||||||
OWSProdErrorWEnvelope([OWSAnalyticsEvents messageManagerErrorNoSession], envelope);
|
OWSProdErrorWEnvelope([OWSAnalyticsEvents messageManagerErrorNoSession], envelope);
|
||||||
errorMessage = [TSErrorMessage missingSessionWithEnvelope:envelope withTransaction:transaction];
|
errorMessage = [TSErrorMessage missingSessionWithEnvelope:envelope withTransaction:transaction];
|
||||||
|
@ -551,14 +609,7 @@ NSError *EnsureDecryptError(NSError *_Nullable error, NSString *fallbackErrorDes
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
OWSProdErrorWEnvelope([OWSAnalyticsEvents messageManagerErrorCorruptMessage], envelope);
|
OWSProdErrorWEnvelope([OWSAnalyticsEvents messageManagerErrorCorruptMessage], envelope);
|
||||||
if (envelope.source.length > 0) {
|
|
||||||
errorMessage = [TSErrorMessage corruptedMessageWithEnvelope:envelope withTransaction:transaction];
|
errorMessage = [TSErrorMessage corruptedMessageWithEnvelope:envelope withTransaction:transaction];
|
||||||
} else {
|
|
||||||
TSErrorMessage *errorMessage = [TSErrorMessage corruptedMessageInUnknownThread];
|
|
||||||
[SSKEnvironment.shared.notificationsManager notifyUserForThreadlessErrorMessage:errorMessage
|
|
||||||
transaction:transaction];
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
OWSAssertDebug(errorMessage);
|
OWSAssertDebug(errorMessage);
|
||||||
|
|
Loading…
Reference in New Issue