mirror of
https://github.com/vector-im/element-ios.git
synced 2024-09-30 16:22:39 +00:00
Merge pull request #7012 from vector-im/andy/crypto_changes
CryptoV2 changes
This commit is contained in:
commit
979f41bb56
7 changed files with 42 additions and 27 deletions
|
@ -2288,7 +2288,7 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni
|
||||||
// Stay in launching during the first server sync if the store is empty.
|
// Stay in launching during the first server sync if the store is empty.
|
||||||
isLaunching = (mainSession.rooms.count == 0 && launchAnimationContainerView);
|
isLaunching = (mainSession.rooms.count == 0 && launchAnimationContainerView);
|
||||||
|
|
||||||
if (mainSession.crypto.crossSigning && mainSession.crypto.crossSigning.state == MXCrossSigningStateCrossSigningExists)
|
if (mainSession.crypto.crossSigning && mainSession.crypto.crossSigning.state == MXCrossSigningStateCrossSigningExists && [mainSession.crypto isKindOfClass:[MXLegacyCrypto class]])
|
||||||
{
|
{
|
||||||
[(MXLegacyCrypto *)mainSession.crypto setOutgoingKeyRequestsEnabled:NO onComplete:nil];
|
[(MXLegacyCrypto *)mainSession.crypto setOutgoingKeyRequestsEnabled:NO onComplete:nil];
|
||||||
}
|
}
|
||||||
|
@ -3767,7 +3767,7 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni
|
||||||
- (void)keyVerificationCoordinatorBridgePresenterDelegateDidComplete:(KeyVerificationCoordinatorBridgePresenter *)coordinatorBridgePresenter otherUserId:(NSString * _Nonnull)otherUserId otherDeviceId:(NSString * _Nonnull)otherDeviceId
|
- (void)keyVerificationCoordinatorBridgePresenterDelegateDidComplete:(KeyVerificationCoordinatorBridgePresenter *)coordinatorBridgePresenter otherUserId:(NSString * _Nonnull)otherUserId otherDeviceId:(NSString * _Nonnull)otherDeviceId
|
||||||
{
|
{
|
||||||
id<MXCrypto> crypto = coordinatorBridgePresenter.session.crypto;
|
id<MXCrypto> crypto = coordinatorBridgePresenter.session.crypto;
|
||||||
if (!crypto.backup.hasPrivateKeyInCryptoStore || !crypto.backup.enabled)
|
if ([crypto isKindOfClass:[MXLegacyCrypto class]] && (!crypto.backup.hasPrivateKeyInCryptoStore || !crypto.backup.enabled))
|
||||||
{
|
{
|
||||||
MXLogDebug(@"[AppDelegate][MXKeyVerification] requestAllPrivateKeys: Request key backup private keys");
|
MXLogDebug(@"[AppDelegate][MXKeyVerification] requestAllPrivateKeys: Request key backup private keys");
|
||||||
[(MXLegacyCrypto *)crypto setOutgoingKeyRequestsEnabled:YES onComplete:nil];
|
[(MXLegacyCrypto *)crypto setOutgoingKeyRequestsEnabled:YES onComplete:nil];
|
||||||
|
|
|
@ -78,7 +78,7 @@ class SessionVerificationListener {
|
||||||
} else if session.state == .running {
|
} else if session.state == .running {
|
||||||
unregisterSessionStateChangeNotification()
|
unregisterSessionStateChangeNotification()
|
||||||
|
|
||||||
if let crypto = session.crypto as? MXLegacyCrypto {
|
if let crypto = session.crypto {
|
||||||
let crossSigning = crypto.crossSigning
|
let crossSigning = crypto.crossSigning
|
||||||
crossSigning.refreshState { [weak self] stateUpdated in
|
crossSigning.refreshState { [weak self] stateUpdated in
|
||||||
guard let self = self else { return }
|
guard let self = self else { return }
|
||||||
|
@ -101,7 +101,7 @@ class SessionVerificationListener {
|
||||||
self.completion?(.authenticationIsComplete)
|
self.completion?(.authenticationIsComplete)
|
||||||
} failure: { error in
|
} failure: { error in
|
||||||
MXLog.error("[SessionVerificationListener] sessionStateDidChange: Bootstrap failed", context: error)
|
MXLog.error("[SessionVerificationListener] sessionStateDidChange: Bootstrap failed", context: error)
|
||||||
crypto.setOutgoingKeyRequestsEnabled(true, onComplete: nil)
|
(crypto as? MXLegacyCrypto)?.setOutgoingKeyRequestsEnabled(true, onComplete: nil)
|
||||||
self.completion?(.authenticationIsComplete)
|
self.completion?(.authenticationIsComplete)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -111,12 +111,12 @@ class SessionVerificationListener {
|
||||||
self.completion?(.authenticationIsComplete)
|
self.completion?(.authenticationIsComplete)
|
||||||
} failure: { error in
|
} failure: { error in
|
||||||
MXLog.error("[SessionVerificationListener] sessionStateDidChange: Do not know how to bootstrap cross-signing. Skip it.")
|
MXLog.error("[SessionVerificationListener] sessionStateDidChange: Do not know how to bootstrap cross-signing. Skip it.")
|
||||||
crypto.setOutgoingKeyRequestsEnabled(true, onComplete: nil)
|
(crypto as? MXLegacyCrypto)?.setOutgoingKeyRequestsEnabled(true, onComplete: nil)
|
||||||
self.completion?(.authenticationIsComplete)
|
self.completion?(.authenticationIsComplete)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
crypto.setOutgoingKeyRequestsEnabled(true, onComplete: nil)
|
(crypto as? MXLegacyCrypto)?.setOutgoingKeyRequestsEnabled(true, onComplete: nil)
|
||||||
self.completion?(.authenticationIsComplete)
|
self.completion?(.authenticationIsComplete)
|
||||||
}
|
}
|
||||||
case .crossSigningExists:
|
case .crossSigningExists:
|
||||||
|
@ -125,12 +125,12 @@ class SessionVerificationListener {
|
||||||
default:
|
default:
|
||||||
MXLog.debug("[SessionVerificationListener] sessionStateDidChange: Nothing to do")
|
MXLog.debug("[SessionVerificationListener] sessionStateDidChange: Nothing to do")
|
||||||
|
|
||||||
crypto.setOutgoingKeyRequestsEnabled(true, onComplete: nil)
|
(crypto as? MXLegacyCrypto)?.setOutgoingKeyRequestsEnabled(true, onComplete: nil)
|
||||||
self.completion?(.authenticationIsComplete)
|
self.completion?(.authenticationIsComplete)
|
||||||
}
|
}
|
||||||
} failure: { [weak self] error in
|
} failure: { [weak self] error in
|
||||||
MXLog.error("[SessionVerificationListener] sessionStateDidChange: Fail to refresh crypto state", context: error)
|
MXLog.error("[SessionVerificationListener] sessionStateDidChange: Fail to refresh crypto state", context: error)
|
||||||
crypto.setOutgoingKeyRequestsEnabled(true, onComplete: nil)
|
(crypto as? MXLegacyCrypto)?.setOutgoingKeyRequestsEnabled(true, onComplete: nil)
|
||||||
self?.completion?(.authenticationIsComplete)
|
self?.completion?(.authenticationIsComplete)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -92,21 +92,29 @@ final class KeyVerificationSelfVerifyWaitViewModel: KeyVerificationSelfVerifyWai
|
||||||
// be sure that session has completed its first sync
|
// be sure that session has completed its first sync
|
||||||
if session.state >= .running {
|
if session.state >= .running {
|
||||||
|
|
||||||
// Always send request instead of waiting for an incoming one as per recent EW changes
|
if let existingRequest = verificationManager.pendingRequests.first(where: { $0.isFromMyUser && !$0.isFromMyDevice && $0.state == MXKeyVerificationRequestStatePending }) {
|
||||||
MXLog.debug("[KeyVerificationSelfVerifyWaitViewModel] loadData: Send a verification request to all devices instead of waiting")
|
MXLog.debug("[KeyVerificationSelfVerifyWaitViewModel] loadData: Accepting an existing self-verification request instead of starting a new one")
|
||||||
|
|
||||||
let keyVerificationService = KeyVerificationService()
|
registerTransactionDidStateChangeNotification()
|
||||||
self.verificationManager.requestVerificationByToDevice(withUserId: self.session.myUserId, deviceIds: nil, methods: keyVerificationService.supportedKeyVerificationMethods(), success: { [weak self] (keyVerificationRequest) in
|
acceptKeyVerificationRequest(existingRequest)
|
||||||
guard let self = self else {
|
} else {
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
self.keyVerificationRequest = keyVerificationRequest
|
// Always send request instead of waiting for an incoming one as per recent EW changes
|
||||||
|
MXLog.debug("[KeyVerificationSelfVerifyWaitViewModel] loadData: Send a verification request to all devices instead of waiting")
|
||||||
|
|
||||||
}, failure: { [weak self] error in
|
let keyVerificationService = KeyVerificationService()
|
||||||
self?.update(viewState: .error(error))
|
self.verificationManager.requestVerificationByToDevice(withUserId: self.session.myUserId, deviceIds: nil, methods: keyVerificationService.supportedKeyVerificationMethods(), success: { [weak self] (keyVerificationRequest) in
|
||||||
})
|
guard let self = self else {
|
||||||
continueLoadData()
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
self.keyVerificationRequest = keyVerificationRequest
|
||||||
|
|
||||||
|
}, failure: { [weak self] error in
|
||||||
|
self?.update(viewState: .error(error))
|
||||||
|
})
|
||||||
|
continueLoadData()
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// show loader
|
// show loader
|
||||||
self.update(viewState: .secretsRecoveryCheckingAvailability(VectorL10n.deviceVerificationSelfVerifyWaitRecoverSecretsCheckingAvailability))
|
self.update(viewState: .secretsRecoveryCheckingAvailability(VectorL10n.deviceVerificationSelfVerifyWaitRecoverSecretsCheckingAvailability))
|
||||||
|
|
|
@ -952,7 +952,10 @@ static NSArray<NSNumber*> *initialSyncSilentErrorsHTTPStatusCodes;
|
||||||
{
|
{
|
||||||
// Force a reload of device keys at the next session start.
|
// Force a reload of device keys at the next session start.
|
||||||
// This will fix potential UISIs other peoples receive for our messages.
|
// This will fix potential UISIs other peoples receive for our messages.
|
||||||
[(MXLegacyCrypto *)mxSession.crypto resetDeviceKeys];
|
if ([mxSession.crypto isKindOfClass:[MXLegacyCrypto class]])
|
||||||
|
{
|
||||||
|
[(MXLegacyCrypto *)mxSession.crypto resetDeviceKeys];
|
||||||
|
}
|
||||||
|
|
||||||
// Clean other stores
|
// Clean other stores
|
||||||
[mxSession.scanManager deleteAllAntivirusScans];
|
[mxSession.scanManager deleteAllAntivirusScans];
|
||||||
|
|
|
@ -1445,13 +1445,11 @@ ChangePasswordCoordinatorBridgePresenterDelegate>
|
||||||
|
|
||||||
NSString *sdkVersionInfo = [NSString stringWithFormat:@"Matrix SDK %@", MatrixSDKVersion];
|
NSString *sdkVersionInfo = [NSString stringWithFormat:@"Matrix SDK %@", MatrixSDKVersion];
|
||||||
|
|
||||||
NSString *olmVersionInfo = [NSString stringWithFormat:@"OLM %@", [OLMKit versionString]];
|
|
||||||
|
|
||||||
[footerText appendFormat:@"%@\n", loggedUserInfo];
|
[footerText appendFormat:@"%@\n", loggedUserInfo];
|
||||||
[footerText appendFormat:@"%@\n", homeserverInfo];
|
[footerText appendFormat:@"%@\n", homeserverInfo];
|
||||||
[footerText appendFormat:@"%@\n", appVersionInfo];
|
[footerText appendFormat:@"%@\n", appVersionInfo];
|
||||||
[footerText appendFormat:@"%@\n", sdkVersionInfo];
|
[footerText appendFormat:@"%@\n", sdkVersionInfo];
|
||||||
[footerText appendFormat:@"%@", olmVersionInfo];
|
[footerText appendFormat:@"%@", self.mainSession.crypto.version];
|
||||||
|
|
||||||
return [footerText copy];
|
return [footerText copy];
|
||||||
}
|
}
|
||||||
|
|
|
@ -102,7 +102,10 @@ static MXSession *fakeSession;
|
||||||
[session setStore:self.fileStore success:^{
|
[session setStore:self.fileStore success:^{
|
||||||
MXStrongifyAndReturnIfNil(session);
|
MXStrongifyAndReturnIfNil(session);
|
||||||
|
|
||||||
((MXLegacyCrypto *)session.crypto).warnOnUnknowDevices = NO; // Do not warn for unknown devices. We have cross-signing now
|
if ([session.crypto isKindOfClass:[MXLegacyCrypto class]])
|
||||||
|
{
|
||||||
|
((MXLegacyCrypto *)session.crypto).warnOnUnknowDevices = NO; // Do not warn for unknown devices. We have cross-signing now
|
||||||
|
}
|
||||||
|
|
||||||
self.selectedRooms = [NSMutableArray array];
|
self.selectedRooms = [NSMutableArray array];
|
||||||
for (NSString *roomIdentifier in roomIdentifiers) {
|
for (NSString *roomIdentifier in roomIdentifiers) {
|
||||||
|
|
|
@ -118,7 +118,10 @@
|
||||||
self.selectedRoom = [MXRoom loadRoomFromStore:fileStore withRoomId:roomID matrixSession:session];
|
self.selectedRoom = [MXRoom loadRoomFromStore:fileStore withRoomId:roomID matrixSession:session];
|
||||||
|
|
||||||
// Do not warn for unknown devices. We have cross-signing now
|
// Do not warn for unknown devices. We have cross-signing now
|
||||||
((MXLegacyCrypto *)session.crypto).warnOnUnknowDevices = NO;
|
if ([session.crypto isKindOfClass:[MXLegacyCrypto class]])
|
||||||
|
{
|
||||||
|
((MXLegacyCrypto *)session.crypto).warnOnUnknowDevices = NO;
|
||||||
|
}
|
||||||
|
|
||||||
MXWeakify(self);
|
MXWeakify(self);
|
||||||
[self.selectedRoom sendTextMessage:intent.content
|
[self.selectedRoom sendTextMessage:intent.content
|
||||||
|
|
Loading…
Reference in a new issue