Assert profile key length on sending/receiving

// FREEBIE
pull/1/head
Michael Kirk 7 years ago
parent 6235e7fe5c
commit 6cde79c568

@ -4,6 +4,7 @@
#import "OWSContactsOutputStream.h"
#import "Contact.h"
#import "Cryptography.h"
#import "MIMETypeUtil.h"
#import "NSData+keyVersionByte.h"
#import "OWSRecipientIdentity.h"
@ -21,6 +22,7 @@ NS_ASSUME_NONNULL_BEGIN
{
OWSAssert(signalAccount);
OWSAssert(signalAccount.contact);
OWSAssert(profileKeyData.length == kAES256_KeyByteLength);
OWSSignalServiceProtosContactDetailsBuilder *contactBuilder = [OWSSignalServiceProtosContactDetailsBuilder new];
[contactBuilder setName:signalAccount.contact.fullName];

@ -5,6 +5,7 @@
#import "TSMessagesManager.h"
#import "ContactsManagerProtocol.h"
#import "ContactsUpdater.h"
#import "Cryptography.h"
#import "MimeTypeUtil.h"
#import "NSData+messagePadding.h"
#import "NSDate+millisecondTimeStamp.h"
@ -515,7 +516,12 @@ NS_ASSUME_NONNULL_BEGIN
if ([dataMessage hasProfileKey]) {
NSData *profileKey = [dataMessage profileKey];
NSString *recipientId = incomingEnvelope.source;
[self.profileManager setProfileKeyData:profileKey forRecipientId:recipientId];
if (profileKey.length == kAES256_KeyByteLength) {
[self.profileManager setProfileKeyData:profileKey forRecipientId:recipientId];
} else {
OWSFail(
@"Unexpected profile key length:%lu on message from:%@", (unsigned long)profileKey.length, recipientId);
}
}
if (dataMessage.hasGroup) {
@ -1089,7 +1095,7 @@ NS_ASSUME_NONNULL_BEGIN
OWSFail(@"%@ Failed to trust identity on incoming message from: %@.%d",
self.tag,
envelope.source,
envelope.sourceDevice);
(unsigned int)envelope.sourceDevice);
return;
} else {
OWSProdErrorWEnvelope([OWSAnalyticsEvents messageManagerErrorCorruptMessage], envelope);

Loading…
Cancel
Save