diff --git a/CHANGES.rst b/CHANGES.rst index ff1fc5797..f2fcbefee 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -5,7 +5,7 @@ Changes to be released in next version * 🙌 Improvements - * + * Cross-signing: Detect when cross-signing keys have been changed. 🐛 Bugfix * diff --git a/Riot/Modules/Application/LegacyAppDelegate.m b/Riot/Modules/Application/LegacyAppDelegate.m index 90073766c..540874f88 100644 --- a/Riot/Modules/Application/LegacyAppDelegate.m +++ b/Riot/Modules/Application/LegacyAppDelegate.m @@ -227,6 +227,8 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni @property (nonatomic, weak) id userDidSignInOnNewDeviceObserver; @property (weak, nonatomic) UIAlertController *userNewSignInAlertController; +@property (nonatomic, weak) id userDidChangeCrossSigningKeysObserver; + /** Related push notification service instance. Will be created when launch finished. */ @@ -1773,6 +1775,8 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni // Register to user new device sign in notification [self registerUserDidSignInOnNewDeviceNotificationForSession:mxSession]; + [self registerDidChangeCrossSigningKeysNotificationForSession:mxSession]; + // Register to new key verification request [self registerNewRequestNotificationForSession:mxSession]; @@ -4263,6 +4267,29 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni self.userNewSignInAlertController = alert; } + +#pragma mark - Cross-signing reset detection + +- (void)registerDidChangeCrossSigningKeysNotificationForSession:(MXSession*)session +{ + MXCrossSigning *crossSigning = session.crypto.crossSigning; + + if (!crossSigning) + { + return; + } + + self.userDidChangeCrossSigningKeysObserver = [NSNotificationCenter.defaultCenter addObserverForName:MXCrossSigningDidChangeCrossSigningKeysNotification + object:crossSigning + queue:[NSOperationQueue mainQueue] + usingBlock:^(NSNotification *notification) + { + NSLog(@"[AppDelegate] registerDidChangeCrossSigningKeysNotificationForSession"); + [self.masterTabBarController presentVerifyCurrentSessionAlertIfNeededWithSession:session]; + }]; +} + + #pragma mark - Complete security - (BOOL)presentCompleteSecurityForSession:(MXSession*)mxSession