diff --git a/MatrixSDK.xcodeproj/project.pbxproj b/MatrixSDK.xcodeproj/project.pbxproj index 65c73f261..a498bed52 100644 --- a/MatrixSDK.xcodeproj/project.pbxproj +++ b/MatrixSDK.xcodeproj/project.pbxproj @@ -675,6 +675,8 @@ A0A2397A295202930001F722 /* MXAggregatedPollsUpdater.swift in Sources */ = {isa = PBXBuildFile; fileRef = A0A23978295202930001F722 /* MXAggregatedPollsUpdater.swift */; }; A0B1217F295306F700E704C2 /* MXAggregatedPollsUpdaterTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A0B1217E295306F700E704C2 /* MXAggregatedPollsUpdaterTests.swift */; }; A0B12180295306F700E704C2 /* MXAggregatedPollsUpdaterTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A0B1217E295306F700E704C2 /* MXAggregatedPollsUpdaterTests.swift */; }; + A759E23D2C98EE7D002429A8 /* MXCrypto.m in Sources */ = {isa = PBXBuildFile; fileRef = A759E23C2C98EE7D002429A8 /* MXCrypto.m */; }; + A759E23E2C98EE7D002429A8 /* MXCrypto.m in Sources */ = {isa = PBXBuildFile; fileRef = A759E23C2C98EE7D002429A8 /* MXCrypto.m */; }; A75CAD692A9796DE00F06072 /* MXWellKnownAuthentication.m in Sources */ = {isa = PBXBuildFile; fileRef = A75CAD682A9796DE00F06072 /* MXWellKnownAuthentication.m */; }; A75CAD6A2A9796DE00F06072 /* MXWellKnownAuthentication.m in Sources */ = {isa = PBXBuildFile; fileRef = A75CAD682A9796DE00F06072 /* MXWellKnownAuthentication.m */; }; A75CAD6C2A979AC500F06072 /* MXWellKnownAuthentication.h in Headers */ = {isa = PBXBuildFile; fileRef = A75CAD6B2A97970500F06072 /* MXWellKnownAuthentication.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -2505,6 +2507,7 @@ 9274AFE71EE580240009BEB6 /* MXCallKitAdapter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MXCallKitAdapter.m; sourceTree = ""; }; A0A23978295202930001F722 /* MXAggregatedPollsUpdater.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MXAggregatedPollsUpdater.swift; sourceTree = ""; }; A0B1217E295306F700E704C2 /* MXAggregatedPollsUpdaterTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MXAggregatedPollsUpdaterTests.swift; sourceTree = ""; }; + A759E23C2C98EE7D002429A8 /* MXCrypto.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MXCrypto.m; sourceTree = ""; }; A75CAD682A9796DE00F06072 /* MXWellKnownAuthentication.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MXWellKnownAuthentication.m; sourceTree = ""; }; A75CAD6B2A97970500F06072 /* MXWellKnownAuthentication.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MXWellKnownAuthentication.h; sourceTree = ""; }; A777E5742C98D6F100B39397 /* MXKeyVerificationManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MXKeyVerificationManager.m; sourceTree = ""; }; @@ -3328,6 +3331,7 @@ 3252DCAB224BE59E0032264F /* Verification */, ED2DD110286C450600F06731 /* CryptoMachine */, 322A51B41D9AB15900C8536D /* MXCrypto.h */, + A759E23C2C98EE7D002429A8 /* MXCrypto.m */, ED47CB6C28523995004FD755 /* MXCryptoV2.swift */, ED5EF151297AB33E00A5ADDA /* MXCryptoV2Factory.swift */, ); @@ -6840,6 +6844,7 @@ 3A59A52B25A7B1B000DDA1FC /* MXOutboundSessionInfo.m in Sources */, 32A1515C1DB525DA00400192 /* NSObject+sortedKeys.m in Sources */, 32792BD52295A86600F4FC9D /* MXAggregatedReactionsUpdater.m in Sources */, + A759E23D2C98EE7D002429A8 /* MXCrypto.m in Sources */, 32618E7C20EFA45B00E1D2EA /* MXRoomMembers.m in Sources */, ED2DD118286C450600F06731 /* MXCryptoRequests.swift in Sources */, EDAAC41928E2FCFE00DD89B5 /* MXCryptoSecretStoreV2.swift in Sources */, @@ -7468,6 +7473,7 @@ EC1165C527107E330089FA56 /* MXRoomListDataFilterOptions.swift in Sources */, 3A858DE227528EEB006322C1 /* MXHomeserverCapabilitiesService.swift in Sources */, ECDA764F27BA963D000C48CF /* MXBooleanCapability.m in Sources */, + A759E23E2C98EE7D002429A8 /* MXCrypto.m in Sources */, B14EF24C2397E90400758AF0 /* MXCredentials.m in Sources */, ED6F4EFD2987F0FC007D1191 /* MXEncryptedKeyBackup.swift in Sources */, EC116590270F3ABF0089FA56 /* RLMRealm+MatrixSDK.m in Sources */, diff --git a/MatrixSDK/Crypto/MXCrypto.m b/MatrixSDK/Crypto/MXCrypto.m new file mode 100644 index 000000000..f9bea45fc --- /dev/null +++ b/MatrixSDK/Crypto/MXCrypto.m @@ -0,0 +1,74 @@ +/* + Copyright 2016 OpenMarket Ltd + Copyright 2017 Vector Creations Ltd + Copyright 2018 New Vector Ltd + Copyright 2020 The Matrix.org Foundation C.I.C + + 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 "MXCrypto.h" + +#import "MXCrypto_Private.h" + +#import "MXSession.h" +#import "MXTools.h" + +#import "MXOlmDevice.h" +#import "MXUsersDevicesMap.h" +#import "MXDeviceInfo.h" +#import "MXKey.h" + +#import "MXRealmCryptoStore.h" +#import "MXCryptoMigration.h" + +#import "MXMegolmSessionData.h" +#import "MXMegolmExportEncryption.h" + +#import "MXOutgoingRoomKeyRequestManager.h" +#import "MXIncomingRoomKeyRequestManager.h" + +#import "MXSecretStorage_Private.h" +#import "MXSecretShareManager_Private.h" +#import "MXRecoveryService_Private.h" + +#import "MXKeyVerificationManager_Private.h" +#import "MXDeviceInfo_Private.h" +#import "MXCrossSigningInfo_Private.h" +#import "MXCrossSigning_Private.h" + +#import "NSArray+MatrixSDK.h" + +#import "MXDeviceListResponse.h" + +#import "MatrixSDKSwiftHeader.h" +#import "MXSharedHistoryKeyService.h" +#import "MXNativeKeyBackupEngine.h" + +#warning File has not been annotated with nullability, see MX_ASSUME_MISSING_NULLABILITY_BEGIN + +/** + The store to use for crypto. + */ +#define MXCryptoStoreClass MXRealmCryptoStore + +NSString *const kMXCryptoRoomKeyRequestNotification = @"kMXCryptoRoomKeyRequestNotification"; +NSString *const kMXCryptoRoomKeyRequestNotificationRequestKey = @"kMXCryptoRoomKeyRequestNotificationRequestKey"; +NSString *const kMXCryptoRoomKeyRequestCancellationNotification = @"kMXCryptoRoomKeyRequestCancellationNotification"; +NSString *const kMXCryptoRoomKeyRequestCancellationNotificationRequestKey = @"kMXCryptoRoomKeyRequestCancellationNotificationRequestKey"; + +NSString *const MXDeviceListDidUpdateUsersDevicesNotification = @"MXDeviceListDidUpdateUsersDevicesNotification"; + +static NSString *const kMXCryptoOneTimeKeyClaimCompleteNotification = @"kMXCryptoOneTimeKeyClaimCompleteNotification"; +static NSString *const kMXCryptoOneTimeKeyClaimCompleteNotificationDevicesKey = @"kMXCryptoOneTimeKeyClaimCompleteNotificationDevicesKey"; +static NSString *const kMXCryptoOneTimeKeyClaimCompleteNotificationErrorKey = @"kMXCryptoOneTimeKeyClaimCompleteNotificationErrorKey";