Respond to CR.
This commit is contained in:
parent
78c4c00eac
commit
b64528e817
4
Podfile
4
Podfile
|
@ -9,9 +9,9 @@ def shared_pods
|
||||||
pod 'SQLCipher', :git => 'https://github.com/sqlcipher/sqlcipher.git', :commit => 'd5c2bec'
|
pod 'SQLCipher', :git => 'https://github.com/sqlcipher/sqlcipher.git', :commit => 'd5c2bec'
|
||||||
# pod 'YapDatabase/SQLCipher', path: '../YapDatabase'
|
# pod 'YapDatabase/SQLCipher', path: '../YapDatabase'
|
||||||
pod 'YapDatabase/SQLCipher', :git => 'https://github.com/WhisperSystems/YapDatabase.git', branch: 'release/unencryptedHeaders'
|
pod 'YapDatabase/SQLCipher', :git => 'https://github.com/WhisperSystems/YapDatabase.git', branch: 'release/unencryptedHeaders'
|
||||||
pod 'AxolotlKit', path: '../SignalProtocolKit'
|
# pod 'AxolotlKit', path: '../SignalProtocolKit'
|
||||||
pod 'SignalServiceKit', path: '.'
|
pod 'SignalServiceKit', path: '.'
|
||||||
# pod 'AxolotlKit', git: 'https://github.com/WhisperSystems/SignalProtocolKit.git', branch: 'mkirk/framework-friendly'
|
pod 'AxolotlKit', git: 'https://github.com/signalapp/SignalProtocolKit.git'
|
||||||
#pod 'AxolotlKit', path: '../SignalProtocolKit'
|
#pod 'AxolotlKit', path: '../SignalProtocolKit'
|
||||||
pod 'HKDFKit', git: 'https://github.com/WhisperSystems/HKDFKit.git', branch: 'mkirk/framework-friendly'
|
pod 'HKDFKit', git: 'https://github.com/WhisperSystems/HKDFKit.git', branch: 'mkirk/framework-friendly'
|
||||||
#pod 'HKDFKit', path: '../HKDFKit'
|
#pod 'HKDFKit', path: '../HKDFKit'
|
||||||
|
|
|
@ -129,7 +129,7 @@ PODS:
|
||||||
DEPENDENCIES:
|
DEPENDENCIES:
|
||||||
- AFNetworking
|
- AFNetworking
|
||||||
- ATAppUpdater
|
- ATAppUpdater
|
||||||
- AxolotlKit (from `../SignalProtocolKit`)
|
- AxolotlKit (from `https://github.com/signalapp/SignalProtocolKit.git`)
|
||||||
- Curve25519Kit (from `https://github.com/WhisperSystems/Curve25519Kit`, branch `mkirk/framework-friendly`)
|
- Curve25519Kit (from `https://github.com/WhisperSystems/Curve25519Kit`, branch `mkirk/framework-friendly`)
|
||||||
- GRKOpenSSLFramework (from `https://github.com/WhisperSystems/GRKOpenSSLFramework`)
|
- GRKOpenSSLFramework (from `https://github.com/WhisperSystems/GRKOpenSSLFramework`)
|
||||||
- HKDFKit (from `https://github.com/WhisperSystems/HKDFKit.git`, branch `mkirk/framework-friendly`)
|
- HKDFKit (from `https://github.com/WhisperSystems/HKDFKit.git`, branch `mkirk/framework-friendly`)
|
||||||
|
@ -146,7 +146,7 @@ DEPENDENCIES:
|
||||||
|
|
||||||
EXTERNAL SOURCES:
|
EXTERNAL SOURCES:
|
||||||
AxolotlKit:
|
AxolotlKit:
|
||||||
:path: ../SignalProtocolKit
|
:git: https://github.com/signalapp/SignalProtocolKit.git
|
||||||
Curve25519Kit:
|
Curve25519Kit:
|
||||||
:branch: mkirk/framework-friendly
|
:branch: mkirk/framework-friendly
|
||||||
:git: https://github.com/WhisperSystems/Curve25519Kit
|
:git: https://github.com/WhisperSystems/Curve25519Kit
|
||||||
|
@ -170,6 +170,9 @@ EXTERNAL SOURCES:
|
||||||
:git: https://github.com/WhisperSystems/YapDatabase.git
|
:git: https://github.com/WhisperSystems/YapDatabase.git
|
||||||
|
|
||||||
CHECKOUT OPTIONS:
|
CHECKOUT OPTIONS:
|
||||||
|
AxolotlKit:
|
||||||
|
:commit: b523c0b82e76295726ded8afec2715328d63213c
|
||||||
|
:git: https://github.com/signalapp/SignalProtocolKit.git
|
||||||
Curve25519Kit:
|
Curve25519Kit:
|
||||||
:commit: 03a19c80aafc10a3464f0c086b1eb38239c507ac
|
:commit: 03a19c80aafc10a3464f0c086b1eb38239c507ac
|
||||||
:git: https://github.com/WhisperSystems/Curve25519Kit
|
:git: https://github.com/WhisperSystems/Curve25519Kit
|
||||||
|
@ -217,6 +220,6 @@ SPEC CHECKSUMS:
|
||||||
YapDatabase: 299a32de9d350d37a9ac5b0532609d87d5d2a5de
|
YapDatabase: 299a32de9d350d37a9ac5b0532609d87d5d2a5de
|
||||||
YYImage: 1e1b62a9997399593e4b9c4ecfbbabbf1d3f3b54
|
YYImage: 1e1b62a9997399593e4b9c4ecfbbabbf1d3f3b54
|
||||||
|
|
||||||
PODFILE CHECKSUM: d1c081f5e8cda394caa2bfbb157d628f33352cff
|
PODFILE CHECKSUM: d424a8f153ae6e31631ed25ef5700e7e60234a79
|
||||||
|
|
||||||
COCOAPODS: 1.3.1
|
COCOAPODS: 1.3.1
|
||||||
|
|
|
@ -314,7 +314,6 @@ NSString *const kNSNotificationName_IdentityStateDidChange = @"kNSNotificationNa
|
||||||
OWSAssert(recipientId.length > 0);
|
OWSAssert(recipientId.length > 0);
|
||||||
OWSAssert(transaction);
|
OWSAssert(transaction);
|
||||||
|
|
||||||
// TODO: Remove all @synchronized
|
|
||||||
// Ensure a remote identity exists for this key. We may be learning about
|
// Ensure a remote identity exists for this key. We may be learning about
|
||||||
// it for the first time.
|
// it for the first time.
|
||||||
[self saveRemoteIdentity:identityKey recipientId:recipientId protocolContext:transaction];
|
[self saveRemoteIdentity:identityKey recipientId:recipientId protocolContext:transaction];
|
||||||
|
@ -449,36 +448,33 @@ NSString *const kNSNotificationName_IdentityStateDidChange = @"kNSNotificationNa
|
||||||
OWSAssert(direction != TSMessageDirectionUnknown);
|
OWSAssert(direction != TSMessageDirectionUnknown);
|
||||||
OWSAssert(transaction);
|
OWSAssert(transaction);
|
||||||
|
|
||||||
@synchronized(self)
|
if ([[TSAccountManager localNumber] isEqualToString:recipientId]) {
|
||||||
{
|
ECKeyPair *_Nullable localIdentityKeyPair = [self identityKeyPair:transaction];
|
||||||
if ([[TSAccountManager localNumber] isEqualToString:recipientId]) {
|
|
||||||
ECKeyPair *_Nullable localIdentityKeyPair = [self identityKeyPair:transaction];
|
|
||||||
|
|
||||||
if ([localIdentityKeyPair.publicKey isEqualToData:identityKey]) {
|
if ([localIdentityKeyPair.publicKey isEqualToData:identityKey]) {
|
||||||
return YES;
|
return YES;
|
||||||
} else {
|
} else {
|
||||||
OWSFail(@"%@ Wrong identity: %@ for local key: %@, recipientId: %@",
|
OWSFail(@"%@ Wrong identity: %@ for local key: %@, recipientId: %@",
|
||||||
self.logTag,
|
self.logTag,
|
||||||
identityKey,
|
identityKey,
|
||||||
localIdentityKeyPair.publicKey,
|
localIdentityKeyPair.publicKey,
|
||||||
recipientId);
|
recipientId);
|
||||||
return NO;
|
return NO;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
switch (direction) {
|
switch (direction) {
|
||||||
case TSMessageDirectionIncoming: {
|
case TSMessageDirectionIncoming: {
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
case TSMessageDirectionOutgoing: {
|
case TSMessageDirectionOutgoing: {
|
||||||
OWSRecipientIdentity *existingIdentity =
|
OWSRecipientIdentity *existingIdentity =
|
||||||
[OWSRecipientIdentity fetchObjectWithUniqueID:recipientId transaction:transaction];
|
[OWSRecipientIdentity fetchObjectWithUniqueID:recipientId transaction:transaction];
|
||||||
return [self isTrustedKey:identityKey forSendingToIdentity:existingIdentity];
|
return [self isTrustedKey:identityKey forSendingToIdentity:existingIdentity];
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
OWSFail(@"%@ unexpected message direction: %ld", self.logTag, (long)direction);
|
OWSFail(@"%@ unexpected message direction: %ld", self.logTag, (long)direction);
|
||||||
return NO;
|
return NO;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -577,56 +573,53 @@ NSString *const kNSNotificationName_IdentityStateDidChange = @"kNSNotificationNa
|
||||||
- (void)syncQueuedVerificationStates
|
- (void)syncQueuedVerificationStates
|
||||||
{
|
{
|
||||||
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
||||||
@synchronized(self)
|
NSMutableArray<NSString *> *recipientIds = [NSMutableArray new];
|
||||||
{
|
[self.dbConnection readWithBlock:^(YapDatabaseReadTransaction *transaction) {
|
||||||
NSMutableArray<NSString *> *recipientIds = [NSMutableArray new];
|
[transaction
|
||||||
[self.dbConnection readWithBlock:^(YapDatabaseReadTransaction *transaction) {
|
enumerateKeysAndObjectsInCollection:OWSIdentityManager_QueuedVerificationStateSyncMessages
|
||||||
[transaction enumerateKeysAndObjectsInCollection:OWSIdentityManager_QueuedVerificationStateSyncMessages
|
usingBlock:^(
|
||||||
usingBlock:^(NSString *_Nonnull recipientId,
|
NSString *_Nonnull recipientId, id _Nonnull object, BOOL *_Nonnull stop) {
|
||||||
id _Nonnull object,
|
[recipientIds addObject:recipientId];
|
||||||
BOOL *_Nonnull stop) {
|
}];
|
||||||
[recipientIds addObject:recipientId];
|
}];
|
||||||
}];
|
|
||||||
}];
|
|
||||||
|
|
||||||
NSMutableArray<OWSVerificationStateSyncMessage *> *messages = [NSMutableArray new];
|
NSMutableArray<OWSVerificationStateSyncMessage *> *messages = [NSMutableArray new];
|
||||||
for (NSString *recipientId in recipientIds) {
|
for (NSString *recipientId in recipientIds) {
|
||||||
OWSRecipientIdentity *recipientIdentity = [OWSRecipientIdentity fetchObjectWithUniqueID:recipientId];
|
OWSRecipientIdentity *recipientIdentity = [OWSRecipientIdentity fetchObjectWithUniqueID:recipientId];
|
||||||
if (!recipientIdentity) {
|
if (!recipientIdentity) {
|
||||||
OWSFail(@"Could not load recipient identity for recipientId: %@", recipientId);
|
OWSFail(@"Could not load recipient identity for recipientId: %@", recipientId);
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
if (recipientIdentity.recipientId.length < 1) {
|
|
||||||
OWSFail(@"Invalid recipient identity for recipientId: %@", recipientId);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Prepend key type for transit.
|
|
||||||
// TODO we should just be storing the key type so we don't have to juggle re-adding it.
|
|
||||||
NSData *identityKey = [recipientIdentity.identityKey prependKeyType];
|
|
||||||
if (identityKey.length != kIdentityKeyLength) {
|
|
||||||
OWSFail(@"Invalid recipient identitykey for recipientId: %@ key: %@", recipientId, identityKey);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (recipientIdentity.verificationState == OWSVerificationStateNoLongerVerified) {
|
|
||||||
// We don't want to sync "no longer verified" state. Other clients can
|
|
||||||
// figure this out from the /profile/ endpoint, and this can cause data
|
|
||||||
// loss as a user's devices overwrite each other's verification.
|
|
||||||
OWSFail(@"Queue verification state had unexpected value: %@ recipientId: %@",
|
|
||||||
OWSVerificationStateToString(recipientIdentity.verificationState),
|
|
||||||
recipientId);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
OWSVerificationStateSyncMessage *message = [[OWSVerificationStateSyncMessage alloc]
|
|
||||||
initWithVerificationState:recipientIdentity.verificationState
|
|
||||||
identityKey:identityKey
|
|
||||||
verificationForRecipientId:recipientIdentity.recipientId];
|
|
||||||
[messages addObject:message];
|
|
||||||
}
|
}
|
||||||
if (messages.count > 0) {
|
if (recipientIdentity.recipientId.length < 1) {
|
||||||
for (OWSVerificationStateSyncMessage *message in messages) {
|
OWSFail(@"Invalid recipient identity for recipientId: %@", recipientId);
|
||||||
[self sendSyncVerificationStateMessage:message];
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Prepend key type for transit.
|
||||||
|
// TODO we should just be storing the key type so we don't have to juggle re-adding it.
|
||||||
|
NSData *identityKey = [recipientIdentity.identityKey prependKeyType];
|
||||||
|
if (identityKey.length != kIdentityKeyLength) {
|
||||||
|
OWSFail(@"Invalid recipient identitykey for recipientId: %@ key: %@", recipientId, identityKey);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (recipientIdentity.verificationState == OWSVerificationStateNoLongerVerified) {
|
||||||
|
// We don't want to sync "no longer verified" state. Other clients can
|
||||||
|
// figure this out from the /profile/ endpoint, and this can cause data
|
||||||
|
// loss as a user's devices overwrite each other's verification.
|
||||||
|
OWSFail(@"Queue verification state had unexpected value: %@ recipientId: %@",
|
||||||
|
OWSVerificationStateToString(recipientIdentity.verificationState),
|
||||||
|
recipientId);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
OWSVerificationStateSyncMessage *message =
|
||||||
|
[[OWSVerificationStateSyncMessage alloc] initWithVerificationState:recipientIdentity.verificationState
|
||||||
|
identityKey:identityKey
|
||||||
|
verificationForRecipientId:recipientIdentity.recipientId];
|
||||||
|
[messages addObject:message];
|
||||||
|
}
|
||||||
|
if (messages.count > 0) {
|
||||||
|
for (OWSVerificationStateSyncMessage *message in messages) {
|
||||||
|
[self sendSyncVerificationStateMessage:message];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -109,7 +109,6 @@ OWSSignalServiceProtosVerifiedState OWSVerificationStateToProtoState(OWSVerifica
|
||||||
[latest saveWithTransaction:transaction];
|
[latest saveWithTransaction:transaction];
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Is this method obsolete?
|
|
||||||
- (void)updateWithChangeBlock:(void (^)(OWSRecipientIdentity *obj))changeBlock
|
- (void)updateWithChangeBlock:(void (^)(OWSRecipientIdentity *obj))changeBlock
|
||||||
{
|
{
|
||||||
changeBlock(self);
|
changeBlock(self);
|
||||||
|
|
|
@ -33,7 +33,6 @@ NSString *const kSessionStoreDBConnectionKey = @"kSessionStoreDBConnectionKey";
|
||||||
return sessionStoreDBConnection;
|
return sessionStoreDBConnection;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Audit usage of this connection.
|
|
||||||
- (YapDatabaseConnection *)sessionStoreDBConnection
|
- (YapDatabaseConnection *)sessionStoreDBConnection
|
||||||
{
|
{
|
||||||
return [[self class] sessionStoreDBConnection];
|
return [[self class] sessionStoreDBConnection];
|
||||||
|
|
Loading…
Reference in New Issue