-
Notifications
You must be signed in to change notification settings - Fork 215
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
e2ee should not hinder verification #1598
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -93,7 +93,8 @@ - (MXHTTPOperation*)encryptEventContent:(NSDictionary*)eventContent eventType:(M | |
queuedEncryption.failure = failure; | ||
[pendingEncryptions addObject:queuedEncryption]; | ||
|
||
return [self ensureSessionForUsers:users success:^(NSObject *sessionInfo) { | ||
BOOL forceDistributeToUnverified = [self isVerificationEvent:eventType eventContent:eventContent]; | ||
return [self ensureSessionForUsers:users forceDistributeToUnverified:forceDistributeToUnverified success:^(NSObject *sessionInfo) { | ||
|
||
MXOutboundSessionInfo *session = (MXOutboundSessionInfo*)sessionInfo; | ||
[self processPendingEncryptionsInSession:session withError:nil]; | ||
|
@@ -103,14 +104,37 @@ - (MXHTTPOperation*)encryptEventContent:(NSDictionary*)eventContent eventType:(M | |
}]; | ||
} | ||
|
||
- (MXHTTPOperation*)ensureSessionForUsers:(NSArray<NSString*>*)users | ||
- (BOOL) isVerificationEvent:(MXEventTypeString) eventType eventContent:(NSDictionary*)eventContent | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Optionally this whole method could be moved into |
||
{ | ||
switch ([MXTools eventType:eventType]) | ||
{ | ||
case MXEventTypeKeyVerificationKey: | ||
case MXEventTypeKeyVerificationMac: | ||
case MXEventTypeKeyVerificationDone: | ||
case MXEventTypeKeyVerificationReady: | ||
case MXEventTypeKeyVerificationStart: | ||
case MXEventTypeKeyVerificationAccept: | ||
case MXEventTypeKeyVerificationCancel: { | ||
return YES; | ||
} | ||
case MXEventTypeRoomMessage: { | ||
NSString *msgType = eventContent[kMXMessageTypeKey]; | ||
return [msgType isEqualToString:kMXMessageTypeKeyVerificationRequest]; | ||
} | ||
default: { | ||
return NO; | ||
} | ||
} | ||
} | ||
|
||
- (MXHTTPOperation*)ensureSessionForUsers:(NSArray<NSString*>*)users forceDistributeToUnverified: (BOOL) forceDistributeToUnverified | ||
success:(void (^)(NSObject *sessionInfo))success | ||
failure:(void (^)(NSError *error))failure | ||
{ | ||
NSDate *startDate = [NSDate date]; | ||
|
||
MXHTTPOperation *operation; | ||
operation = [self getDevicesInRoom:users success:^(MXUsersDevicesMap<MXDeviceInfo *> *devicesInRoom) { | ||
operation = [self getDevicesInRoom:users forceDistributeToUnverified:forceDistributeToUnverified success:^(MXUsersDevicesMap<MXDeviceInfo *> *devicesInRoom) { | ||
|
||
MXHTTPOperation *operation2 = [self ensureOutboundSession:devicesInRoom success:^(MXOutboundSessionInfo *session) { | ||
|
||
|
@@ -166,6 +190,7 @@ - (BOOL)isSessionSharingHistory:(MXOutboundSessionInfo *)session | |
@param failure A block object called when the operation fails. | ||
*/ | ||
- (MXHTTPOperation *)getDevicesInRoom:(NSArray<NSString*>*)users | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This method includes documentation above so would be good to include the new parameter. Also perhaps just a matter of personal preference, but the method |
||
forceDistributeToUnverified: (BOOL) forceDistributeToUnverified | ||
success:(void (^)(MXUsersDevicesMap<MXDeviceInfo *> *devicesInRoom))success | ||
failure:(void (^)(NSError *))failure | ||
{ | ||
|
@@ -198,7 +223,7 @@ - (MXHTTPOperation *)getDevicesInRoom:(NSArray<NSString*>*)users | |
} | ||
|
||
if (deviceInfo.trustLevel.localVerificationStatus == MXDeviceBlocked | ||
|| (!deviceInfo.trustLevel.isVerified && encryptToVerifiedDevicesOnly)) | ||
|| (!deviceInfo.trustLevel.isVerified && encryptToVerifiedDevicesOnly && !forceDistributeToUnverified)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it would be better / cleaner to include this extra condition in the |
||
{ | ||
// Remove any blocked devices | ||
MXLogDebug(@"[MXMegolmEncryption] getDevicesInRoom: blocked device: %@", deviceInfo); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Can't verify user when option to send keys to verified devices only is selected |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sadly we don't have obj-c style checker / formatter to check this automatically, but to aligh the style:
forceDistributeToUnverified: (BOOL) forceDistributeToUnverified
=>forceDistributeToUnverified:(BOOL)forceDistributeToUnverified
(across the whole PR)success
andfailure
), then all should be, inclforceDistributeToUnverified
, and aligned vertically by the double colon