Skip to content

Commit

Permalink
Merge branch 'release/1.10.0/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
pixlwave committed Feb 2, 2023
2 parents 8bc7134 + 1237142 commit e045905
Show file tree
Hide file tree
Showing 20 changed files with 207 additions and 61 deletions.
12 changes: 12 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
## Changes in 1.10.0 (2023-02-02)

🙌 Improvements

- CryptoV2: Generate Crypto SDK store key ([#7310](https://github.com/vector-im/element-ios/pull/7310))
- Backup: Display backup import progress ([#7319](https://github.com/vector-im/element-ios/pull/7319))
- CryptoV2: Reset Crypto SDK on logout ([#7323](https://github.com/vector-im/element-ios/pull/7323))
- CryptoV2: Refresh notification service on crypto change ([#7332](https://github.com/vector-im/element-ios/pull/7332))
- CryptoV2: Enable Crypto SDK for production ([#7333](https://github.com/vector-im/element-ios/pull/7333))
- Upgrade MatrixSDK version ([v0.25.0](https://github.com/matrix-org/matrix-ios-sdk/releases/tag/v0.25.0)).


## Changes in 1.9.17 (2023-01-26)

🙌 Improvements
Expand Down
4 changes: 2 additions & 2 deletions Config/AppVersion.xcconfig
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@
//

// Version
MARKETING_VERSION = 1.9.17
CURRENT_PROJECT_VERSION = 1.9.17
MARKETING_VERSION = 1.10.0
CURRENT_PROJECT_VERSION = 1.10.0
9 changes: 6 additions & 3 deletions Config/CommonConfiguration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,14 @@ class CommonConfiguration: NSObject, Configurable {

sdkOptions.enableNewClientInformationFeature = RiotSettings.shared.enableClientInformationFeature

#if DEBUG
if sdkOptions.isCryptoSDKAvailable {
sdkOptions.enableCryptoSDK = RiotSettings.shared.enableCryptoSDK
let isEnabled = RiotSettings.shared.enableCryptoSDK
MXLog.debug("[CommonConfiguration] Crypto SDK is \(isEnabled ? "enabled" : "disabled")")
sdkOptions.enableCryptoSDK = isEnabled
sdkOptions.enableStartupProgress = isEnabled
} else {
MXLog.debug("[CommonConfiguration] Crypto SDK is not available)")
}
#endif
}

private func makeASCIIUserAgent() -> String? {
Expand Down
42 changes: 42 additions & 0 deletions Config/CryptoSDKConfiguration.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
//
// Copyright 2023 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

/// Configuration for enabling / disabling Matrix Crypto SDK
@objcMembers class CryptoSDKConfiguration: NSObject {
static let shared = CryptoSDKConfiguration()

func enable() {
guard MXSDKOptions.sharedInstance().isCryptoSDKAvailable else {
return
}

RiotSettings.shared.enableCryptoSDK = true
MXSDKOptions.sharedInstance().enableCryptoSDK = true
MXSDKOptions.sharedInstance().enableStartupProgress = true

MXLog.debug("[CryptoSDKConfiguration] enabling Crypto SDK")
}

func disable() {
RiotSettings.shared.enableCryptoSDK = false
MXSDKOptions.sharedInstance().enableCryptoSDK = false
MXSDKOptions.sharedInstance().enableStartupProgress = false

MXLog.debug("[CryptoSDKConfiguration] disabling Crypto SDK")
}
}
2 changes: 1 addition & 1 deletion Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use_frameworks!
# - `{ :specHash => {sdk spec hash}` to depend on specific pod options (:git => …, :podspec => …) for MatrixSDK repo. Used by Fastfile during CI
#
# Warning: our internal tooling depends on the name of this variable name, so be sure not to change it
$matrixSDKVersion = '= 0.24.8'
$matrixSDKVersion = '= 0.25.0'
# $matrixSDKVersion = :local
# $matrixSDKVersion = { :branch => 'develop'}
# $matrixSDKVersion = { :specHash => { git: 'https://git.io/fork123', branch: 'fix' } }
Expand Down
24 changes: 11 additions & 13 deletions Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -55,22 +55,20 @@ PODS:
- LoggerAPI (1.9.200):
- Logging (~> 1.1)
- Logging (1.4.0)
- MatrixSDK (0.24.8):
- MatrixSDK/Core (= 0.24.8)
- MatrixSDK/Core (0.24.8):
- MatrixSDK (0.25.0):
- MatrixSDK/Core (= 0.25.0)
- MatrixSDK/Core (0.25.0):
- AFNetworking (~> 4.0.0)
- GZIP (~> 1.3.0)
- libbase58 (~> 0.1.4)
- MatrixSDK/CryptoSDK
- MatrixSDKCrypto (= 0.2.0)
- OLMKit (~> 3.2.5)
- Realm (= 10.27.0)
- SwiftyBeaver (= 1.9.5)
- MatrixSDK/CryptoSDK (0.24.8):
- MatrixSDKCrypto (= 0.1.8)
- MatrixSDK/JingleCallStack (0.24.8):
- MatrixSDK/JingleCallStack (0.25.0):
- JitsiMeetSDK (= 5.0.2)
- MatrixSDK/Core
- MatrixSDKCrypto (0.1.8)
- MatrixSDKCrypto (0.2.0)
- OLMKit (3.2.12):
- OLMKit/olmc (= 3.2.12)
- OLMKit/olmcpp (= 3.2.12)
Expand Down Expand Up @@ -122,8 +120,8 @@ DEPENDENCIES:
- KeychainAccess (~> 4.2.2)
- KTCenterFlowLayout (~> 1.3.1)
- libPhoneNumber-iOS (~> 0.9.13)
- MatrixSDK (= 0.24.8)
- MatrixSDK/JingleCallStack (= 0.24.8)
- MatrixSDK (= 0.25.0)
- MatrixSDK/JingleCallStack (= 0.25.0)
- OLMKit
- PostHog (~> 1.4.4)
- ReadMoreTextView (~> 3.0.1)
Expand Down Expand Up @@ -220,8 +218,8 @@ SPEC CHECKSUMS:
libPhoneNumber-iOS: 0a32a9525cf8744fe02c5206eb30d571e38f7d75
LoggerAPI: ad9c4a6f1e32f518fdb43a1347ac14d765ab5e3d
Logging: beeb016c9c80cf77042d62e83495816847ef108b
MatrixSDK: cf1c1b2a9742f7f4fad21e94bd94cd8f13c47369
MatrixSDKCrypto: 862d9b4dbb6861da030943f5a18c39258ed7345b
MatrixSDK: a9d05e760434eff941bbb35164cffb01b3f94b63
MatrixSDKCrypto: e1ef22aae76b5a6f030ace21a47be83864f4ff44
OLMKit: da115f16582e47626616874e20f7bb92222c7a51
PostHog: 4b6321b521569092d4ef3a02238d9435dbaeb99f
ReadMoreTextView: 19147adf93abce6d7271e14031a00303fe28720d
Expand All @@ -241,6 +239,6 @@ SPEC CHECKSUMS:
zxcvbn-ios: fef98b7c80f1512ff0eec47ac1fa399fc00f7e3c
ZXingObjC: fdbb269f25dd2032da343e06f10224d62f537bdb

PODFILE CHECKSUM: 079b57b800c666ad864e1f059ae69e150a98a4f0
PODFILE CHECKSUM: 916221b3e9512715d5e1e1e310a0aa0552e1f0f1

COCOAPODS: 1.11.3
7 changes: 4 additions & 3 deletions Riot/Assets/en.lproj/Vector.strings
Original file line number Diff line number Diff line change
Expand Up @@ -804,9 +804,9 @@ Tap the + to start adding people.";
"settings_labs_enable_new_app_layout" = "New Application Layout";
"settings_labs_enable_wysiwyg_composer" = "Try out the rich text editor";
"settings_labs_enable_voice_broadcast" = "Voice broadcast";
"settings_labs_enable_crypto_sdk" = "Enable new rust-based Crypto SDK";
"settings_labs_confirm_crypto_sdk" = "This action cannot be undone";
"settings_labs_disable_crypto_sdk" = "Crypto SDK is enabled. To disable please reinstall the app";
"settings_labs_enable_crypto_sdk" = "Rust end-to-end encryption";
"settings_labs_confirm_crypto_sdk" = "Please be advised that as this feature is still in its experimental stage, it may not function as expected and could potentially have unintended consequences. To revert the feature, simply log out and log back in. Use at your own discretion and with caution.";
"settings_labs_disable_crypto_sdk" = "Rust end-to-end encryption (log out to disable)";

"settings_version" = "Version %@";
"settings_olm_version" = "Olm Version %@";
Expand Down Expand Up @@ -1469,6 +1469,7 @@ Tap the + to start adding people.";

// Recover from private key
"key_backup_recover_from_private_key_info" = "Restoring backup…";
"key_backup_recover_from_private_key_progress" = "%@%% Complete";

// Recover from passphrase

Expand Down
26 changes: 26 additions & 0 deletions Riot/Categories/MatrixSDKCrypto+LocalizedError.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
//
// Copyright 2023 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
import MatrixSDKCrypto

extension CryptoStoreError: LocalizedError {
public var errorDescription: String? {
// We dont really care about the type of error here when showing to the user.
// Details about the error are tracked independently
return VectorL10n.e2eNeedLogInAgain
}
}
10 changes: 7 additions & 3 deletions Riot/Generated/Strings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2755,6 +2755,10 @@ public class VectorL10n: NSObject {
public static var keyBackupRecoverFromPrivateKeyInfo: String {
return VectorL10n.tr("Vector", "key_backup_recover_from_private_key_info")
}
/// %@%% Complete
public static func keyBackupRecoverFromPrivateKeyProgress(_ p1: String) -> String {
return VectorL10n.tr("Vector", "key_backup_recover_from_private_key_progress", p1)
}
/// Use your Security Key to unlock your secure message history
public static var keyBackupRecoverFromRecoveryKeyInfo: String {
return VectorL10n.tr("Vector", "key_backup_recover_from_recovery_key_info")
Expand Down Expand Up @@ -7583,15 +7587,15 @@ public class VectorL10n: NSObject {
public static var settingsLabs: String {
return VectorL10n.tr("Vector", "settings_labs")
}
/// This action cannot be undone
/// Please be advised that as this feature is still in its experimental stage, it may not function as expected and could potentially have unintended consequences. To revert the feature, simply log out and log back in. Use at your own discretion and with caution.
public static var settingsLabsConfirmCryptoSdk: String {
return VectorL10n.tr("Vector", "settings_labs_confirm_crypto_sdk")
}
/// Create conference calls with jitsi
public static var settingsLabsCreateConferenceWithJitsi: String {
return VectorL10n.tr("Vector", "settings_labs_create_conference_with_jitsi")
}
/// Crypto SDK is enabled. To disable please reinstall the app
/// Rust end-to-end encryption (log out to disable)
public static var settingsLabsDisableCryptoSdk: String {
return VectorL10n.tr("Vector", "settings_labs_disable_crypto_sdk")
}
Expand All @@ -7607,7 +7611,7 @@ public class VectorL10n: NSObject {
public static var settingsLabsEnableAutoReportDecryptionErrors: String {
return VectorL10n.tr("Vector", "settings_labs_enable_auto_report_decryption_errors")
}
/// Enable new rust-based Crypto SDK
/// Rust end-to-end encryption
public static var settingsLabsEnableCryptoSdk: String {
return VectorL10n.tr("Vector", "settings_labs_enable_crypto_sdk")
}
Expand Down
12 changes: 12 additions & 0 deletions Riot/Managers/EncryptionKeyManager/EncryptionKeyManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class EncryptionKeyManager: NSObject, MXKeyProviderDelegate {
private static let cryptoOlmPickleKey: KeyValueStoreKey = "cryptoOlmPickleKey"
private static let roomLastMessageIv: KeyValueStoreKey = "roomLastMessageIv"
private static let roomLastMessageAesKey: KeyValueStoreKey = "roomLastMessageAesKey"
private static let cryptoSDKStoreKey: KeyValueStoreKey = "cryptoSDKStoreKey"

private let keychainStore: KeyValueStore = KeychainStore(withKeychain: Keychain(service: keychainService, accessGroup: BuildSettings.keychainAccessGroup))

Expand All @@ -47,6 +48,7 @@ class EncryptionKeyManager: NSObject, MXKeyProviderDelegate {
generateKeyIfNotExists(forKey: EncryptionKeyManager.cryptoOlmPickleKey, size: 32)
generateIvIfNotExists(forKey: EncryptionKeyManager.roomLastMessageIv)
generateAesKeyIfNotExists(forKey: EncryptionKeyManager.roomLastMessageAesKey)
generateKeyIfNotExists(forKey: EncryptionKeyManager.cryptoSDKStoreKey, size: 32)

assert(keychainStore.containsObject(forKey: EncryptionKeyManager.contactsIv), "[EncryptionKeyManager] initKeys: Failed to generate IV for acount")
assert(keychainStore.containsObject(forKey: EncryptionKeyManager.contactsAesKey), "[EncryptionKeyManager] initKeys: Failed to generate AES Key for acount")
Expand All @@ -55,6 +57,7 @@ class EncryptionKeyManager: NSObject, MXKeyProviderDelegate {
assert(keychainStore.containsObject(forKey: EncryptionKeyManager.cryptoOlmPickleKey), "[EncryptionKeyManager] initKeys: Failed to generate Key for olm pickle key")
assert(keychainStore.containsObject(forKey: EncryptionKeyManager.roomLastMessageIv), "[EncryptionKeyManager] initKeys: Failed to generate IV for room last message")
assert(keychainStore.containsObject(forKey: EncryptionKeyManager.roomLastMessageAesKey), "[EncryptionKeyManager] initKeys: Failed to generate AES Key for room last message encryption")
assert(keychainStore.containsObject(forKey: EncryptionKeyManager.cryptoSDKStoreKey), "[EncryptionKeyManager] initKeys: Failed to generate Key for crypto sdk store")
}

// MARK: - MXKeyProviderDelegate
Expand All @@ -64,6 +67,7 @@ class EncryptionKeyManager: NSObject, MXKeyProviderDelegate {
|| dataType == MXKAccountManagerDataType
|| dataType == MXCryptoOlmPickleKeyDataType
|| dataType == MXRoomLastMessageDataType
|| dataType == MXCryptoSDKStoreKeyDataType
}

func hasKeyForData(ofType dataType: String) -> Bool {
Expand All @@ -77,7 +81,10 @@ class EncryptionKeyManager: NSObject, MXKeyProviderDelegate {
case MXRoomLastMessageDataType:
return keychainStore.containsObject(forKey: EncryptionKeyManager.roomLastMessageIv) &&
keychainStore.containsObject(forKey: EncryptionKeyManager.roomLastMessageAesKey)
case MXCryptoSDKStoreKeyDataType:
return keychainStore.containsObject(forKey: EncryptionKeyManager.cryptoSDKStoreKey)
default:
MXLog.warning("[EncryptionKeyManager] hasKeyForData: No key for \(dataType)")
return false
}
}
Expand All @@ -103,7 +110,12 @@ class EncryptionKeyManager: NSObject, MXKeyProviderDelegate {
let aesKey = try? keychainStore.data(forKey: EncryptionKeyManager.roomLastMessageAesKey) {
return MXAesKeyData(iv: ivKey, key: aesKey)
}
case MXCryptoSDKStoreKeyDataType:
if let key = try? keychainStore.data(forKey: EncryptionKeyManager.cryptoSDKStoreKey) {
return MXRawDataKey(key: key)
}
default:
MXLog.failure("[EncryptionKeyManager] keyDataForData: Attempting to get data for unknown type", dataType)
return nil
}
return nil
Expand Down
2 changes: 0 additions & 2 deletions Riot/Managers/Settings/RiotSettings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -192,11 +192,9 @@ final class RiotSettings: NSObject {
@UserDefault(key: "enableVoiceBroadcast", defaultValue: false, storage: defaults)
var enableVoiceBroadcast

#if DEBUG
/// Flag indicating if we are using rust-based `MatrixCryptoSDK` instead of `MatrixSDK`'s internal crypto module
@UserDefault(key: "enableCryptoSDK", defaultValue: false, storage: defaults)
var enableCryptoSDK
#endif

// MARK: Calls

Expand Down
16 changes: 16 additions & 0 deletions Riot/Modules/Analytics/Analytics.swift
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,11 @@ extension Analytics {
viewRoomTrigger = .unknown
capture(event: event)
}

func trackCryptoSDKEnabled() {
let event = AnalyticsEvent.CryptoSDKEnabled()
capture(event: event)
}
}

// MARK: - MXAnalyticsDelegate
Expand Down Expand Up @@ -393,3 +398,14 @@ extension Analytics: MXAnalyticsDelegate {
monitoringClient.trackNonFatalIssue(issue, details: details)
}
}

/// iOS-specific analytics event triggered when users select the Crypto SDK labs option
///
/// Due to this event being iOS only, and temporary during gradual rollout of Crypto SDK,
/// this event is not added into the shared analytics schema
extension AnalyticsEvent {
struct CryptoSDKEnabled: AnalyticsEventProtocol {
let eventName = "CryptoSDKEnabled"
let properties: [String: Any] = [:]
}
}
3 changes: 3 additions & 0 deletions Riot/Modules/Application/LegacyAppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -2183,6 +2183,9 @@ - (void)logoutSendingRequestServer:(BOOL)sendLogoutServerRequest
// Clear cache
[self clearCache];

// Reset Crypto SDK configuration (labs flag for which crypto module to use)
[CryptoSDKConfiguration.shared disable];

// Reset key backup banner preferences
[SecureBackupBannerPreferences.shared reset];

Expand Down
10 changes: 6 additions & 4 deletions Riot/Modules/Home/AllChats/AllChatsViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -885,10 +885,12 @@ extension AllChatsViewController: SplitViewMasterViewControllerProtocol {
return
}

let devices = mainSession.crypto.devices(forUser: mainSession.myUserId).values
let userHasOneUnverifiedDevice = devices.contains(where: {!$0.trustLevel.isCrossSigningVerified})
if userHasOneUnverifiedDevice {
presentReviewUnverifiedSessionsAlert(with: session)
if let userId = mainSession.myUserId, let crypto = mainSession.crypto {
let devices = crypto.devices(forUser: userId).values
let userHasOneUnverifiedDevice = devices.contains(where: {!$0.trustLevel.isCrossSigningVerified})
if userHasOneUnverifiedDevice {
presentReviewUnverifiedSessionsAlert(with: session)
}
}
}

Expand Down
Loading

0 comments on commit e045905

Please sign in to comment.