Cross-signing: Detect when cross-signing keys have been changed

This commit is contained in:
manuroe
2020-10-13 17:15:47 +02:00
parent 5a063cdec9
commit 2a008a375d
2 changed files with 28 additions and 1 deletions
@@ -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