Remove KeyPreSharingStrategy support

This commit is contained in:
Arnaud Ringenbach 2022-03-16 14:17:46 +01:00
parent b6868465f2
commit 8c088b7ed5
6 changed files with 4 additions and 61 deletions

View file

@ -1,34 +0,0 @@
//
// Copyright 2022 New Vector Ltd
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
import Foundation
extension MXKKeyPreSharingStrategy {
init?(key: String?) {
guard let key = key else {
return nil
}
switch key {
case "on_typing":
self = .whenTyping
case "on_room_opening":
self = .whenEnteringRoom
default:
self = .none
}
}
}

View file

@ -41,8 +41,6 @@ final class HomeserverConfigurationBuilder: NSObject {
let isE2EEByDefaultEnabled = vectorWellKnownEncryptionConfiguration?.isE2EEByDefaultEnabled ?? true
// Disable mandatory secure backup when there is no value
let isSecureBackupRequired = vectorWellKnownEncryptionConfiguration?.isSecureBackupRequired ?? false
// Default to `MXKKeyPreSharingWhenTyping` when there is no value
let outboundKeysPreSharingMode = vectorWellKnownEncryptionConfiguration?.outboundKeysPreSharingMode ?? .whenTyping
// Defaults to all secure backup methods available when there is no value
let secureBackupSetupMethods: [VectorWellKnownBackupSetupMethod]
if let backupSetupMethods = vectorWellKnownEncryptionConfiguration?.secureBackupSetupMethods {
@ -53,8 +51,7 @@ final class HomeserverConfigurationBuilder: NSObject {
let encryptionConfiguration = HomeserverEncryptionConfiguration(isE2EEByDefaultEnabled: isE2EEByDefaultEnabled,
isSecureBackupRequired: isSecureBackupRequired,
secureBackupSetupMethods: secureBackupSetupMethods,
outboundKeysPreSharingMode: outboundKeysPreSharingMode)
secureBackupSetupMethods: secureBackupSetupMethods)
// Jitsi configuration
let jitsiPreferredDomain: String

View file

@ -22,15 +22,12 @@ final class HomeserverEncryptionConfiguration: NSObject {
let isE2EEByDefaultEnabled: Bool
let isSecureBackupRequired: Bool
let secureBackupSetupMethods: [VectorWellKnownBackupSetupMethod]
let outboundKeysPreSharingMode: MXKKeyPreSharingStrategy
init(isE2EEByDefaultEnabled: Bool,
isSecureBackupRequired: Bool,
secureBackupSetupMethods: [VectorWellKnownBackupSetupMethod],
outboundKeysPreSharingMode: MXKKeyPreSharingStrategy) {
secureBackupSetupMethods: [VectorWellKnownBackupSetupMethod]) {
self.isE2EEByDefaultEnabled = isE2EEByDefaultEnabled
self.isSecureBackupRequired = isSecureBackupRequired
self.outboundKeysPreSharingMode = outboundKeysPreSharingMode
self.secureBackupSetupMethods = secureBackupSetupMethods
super.init()

View file

@ -48,8 +48,6 @@ struct VectorWellKnownEncryptionConfiguration {
let isSecureBackupRequired: Bool?
/// Methods to use to setup secure backup (SSSS).
let secureBackupSetupMethods: [VectorWellKnownBackupSetupMethod]?
/// Outbound keys pre sharing strategy.
let outboundKeysPreSharingMode: MXKKeyPreSharingStrategy?
}
extension VectorWellKnownEncryptionConfiguration: Decodable {
@ -58,7 +56,6 @@ extension VectorWellKnownEncryptionConfiguration: Decodable {
case isE2EEByDefaultEnabled = "default"
case isSecureBackupRequired = "secure_backup_required"
case secureBackupSetupMethods = "secure_backup_setup_methods"
case outboundKeysPreSharingMode = "outbound_keys_pre_sharing_mode"
}
init(from decoder: Decoder) throws {
@ -67,8 +64,6 @@ extension VectorWellKnownEncryptionConfiguration: Decodable {
isSecureBackupRequired = try? container.decode(Bool.self, forKey: .isSecureBackupRequired)
let secureBackupSetupMethodsKeys = try? container.decode([String].self, forKey: .secureBackupSetupMethods)
secureBackupSetupMethods = secureBackupSetupMethodsKeys?.compactMap { VectorWellKnownBackupSetupMethod(key: $0) }
let outboundKeysPreSharingModeKey = try? container.decode(String.self, forKey: .outboundKeysPreSharingMode)
outboundKeysPreSharingMode = MXKKeyPreSharingStrategy(key: outboundKeysPreSharingModeKey)
}
}

View file

@ -2376,11 +2376,6 @@ NSString *const AppDelegateUniversalLinkDidChangeNotification = @"AppDelegateUni
{
BOOL isLaunching = NO;
if (mainSession.vc_homeserverConfiguration)
{
[MXKAppSettings standardAppSettings].outboundGroupSessionKeyPreSharingStrategy = mainSession.vc_homeserverConfiguration.encryption.outboundKeysPreSharingMode;
}
if (_masterTabBarController.isOnboardingInProgress)
{
MXLogDebug(@"[AppDelegate] handleAppState: Authentication still in progress");

View file

@ -41,8 +41,6 @@ class HomeserverConfigurationTests: XCTestCase {
let expectedSecureBackupRequired = true
let secureBackupSetupMethods = ["passphrase"]
let expectedSecureBackupSetupMethods: [VectorWellKnownBackupSetupMethod] = [.passphrase]
let outboundKeysPreSharingMode = "on_room_opening"
let expectedOutboundKeysPreSharingMode: MXKKeyPreSharingStrategy = .whenEnteringRoom
let wellKnownDictionary: [String: Any] = [
"m.homeserver": [
@ -63,8 +61,7 @@ class HomeserverConfigurationTests: XCTestCase {
"io.element.e2ee" : [
"default" : expectedE2EEEByDefaultEnabled,
"secure_backup_required": expectedSecureBackupRequired,
"secure_backup_setup_methods": secureBackupSetupMethods,
"outbound_keys_pre_sharing_mode": outboundKeysPreSharingMode
"secure_backup_setup_methods": secureBackupSetupMethods
],
"io.element.jitsi" : [
"preferredDomain" : expectedJitsiServer
@ -81,8 +78,6 @@ class HomeserverConfigurationTests: XCTestCase {
XCTAssertEqual(homeserverConfiguration.encryption.isE2EEByDefaultEnabled, expectedE2EEEByDefaultEnabled)
XCTAssertEqual(homeserverConfiguration.encryption.isSecureBackupRequired, expectedSecureBackupRequired)
XCTAssertEqual(homeserverConfiguration.encryption.secureBackupSetupMethods, expectedSecureBackupSetupMethods)
XCTAssertEqual(homeserverConfiguration.encryption.outboundKeysPreSharingMode, expectedOutboundKeysPreSharingMode)
XCTAssertEqual(homeserverConfiguration.tileServer.mapStyleURL.absoluteString, expectedMapStyleURLString)
}
@ -91,7 +86,6 @@ class HomeserverConfigurationTests: XCTestCase {
let expectedE2EEEByDefaultEnabled = true
let expectedSecureBackupRequired = false
let expectedSecureBackupSetupMethods: [VectorWellKnownBackupSetupMethod] = [.passphrase, .key]
let expectedOutboundKeysPreSharingMode: MXKKeyPreSharingStrategy = .whenTyping
let wellKnownDictionary: [String: Any] = [
"m.homeserver": [
@ -110,6 +104,5 @@ class HomeserverConfigurationTests: XCTestCase {
XCTAssertEqual(homeserverConfiguration.encryption.isE2EEByDefaultEnabled, expectedE2EEEByDefaultEnabled)
XCTAssertEqual(homeserverConfiguration.encryption.isSecureBackupRequired, expectedSecureBackupRequired)
XCTAssertEqual(homeserverConfiguration.encryption.secureBackupSetupMethods, expectedSecureBackupSetupMethods)
XCTAssertEqual(homeserverConfiguration.encryption.outboundKeysPreSharingMode, expectedOutboundKeysPreSharingMode)
}
}