Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .github/workflows/_reusable_run_tests_parallel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,6 @@ jobs:

- name: Setup test environment
uses: ./.github/actions/setup-test-environment
with:
scheme: ${{ matrix.scheme }}

- name: "Test ${{ matrix.scheme }}"
run: bundle exec fastlane select_framework scheme:${{ matrix.scheme }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +258,7 @@ final class NSEClientScope: Component<NSEClientScopeDependency> {
syncContext: coreDataStack.syncContext,
coreCryptoKeyMigrationManager: coreCryptoMigrationManager,
allowCreation: false,
localDomain: localDomain,
backgroundTaskManager: nil
localDomain: localDomain
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import Combine
import CoreData
import XCTest
@testable import WireDataModel
@testable import WireDataModelSupport
@testable import WireDomain
@testable import WireDomainSupport
Expand Down Expand Up @@ -62,10 +61,7 @@ final class IncrementalSyncV2Tests: XCTestCase {
coreCrypto = MockCoreCryptoProtocol()
coreCrypto.mockTransaction(context: coreCryptoContext)
coreCryptoProvider = MockCoreCryptoProviderProtocol()
coreCryptoProvider.coreCrypto_MockValue = SafeCoreCrypto(
backgroundTaskManager: nil,
coreCrypto: coreCrypto
)
coreCryptoProvider.coreCrypto_MockValue = coreCrypto
journal = Journal(
userID: UUID(),
storage: UserDefaults.temporary()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

import Combine
import GenericMessageProtocol
import WireDataModel
import WireDataModelSupport
import WireDomainSupport
import WireNetwork
Expand Down Expand Up @@ -67,10 +66,7 @@ class PullPendingUpdateEventsSyncV2Tests: XCTestCase {
)

// Setup mocks
coreCryptoProvider.coreCrypto_MockValue = SafeCoreCrypto(
backgroundTaskManager: nil,
coreCrypto: coreCrypto
)
coreCryptoProvider.coreCrypto_MockValue = coreCrypto
decryptor.decryptEventsInContext_MockMethod = { envelope, _ in
EventDecryptorResult(events: envelope.events, brokenMLSGroupIDs: [Scaffolding.mlsGroupID])
}
Expand Down
17 changes: 5 additions & 12 deletions wire-ios-data-model/Source/Core Crypto/CoreCryptoProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public protocol CoreCryptoProviderProtocol {
/// Retrieve the shared core crypto instance or create one if one does not yet exist.
///
/// This function is safe to be called concurrently from multiple Tasks
func coreCrypto() async throws -> SafeCoreCrypto
func coreCrypto() async throws -> CoreCryptoProtocol

/// Initialise a new MLS client with basic credentials
///
Expand Down Expand Up @@ -75,8 +75,6 @@ public actor CoreCryptoProvider: CoreCryptoProviderProtocol {
private var epochObserver: WireCoreCryptoUniffi.EpochObserver?
private let localDomain: String?

private let backgroundTaskManager: (any BackgroundTaskManager)?

public init(
selfUserID: UUID,
sharedContainerURL: URL,
Expand All @@ -85,8 +83,7 @@ public actor CoreCryptoProvider: CoreCryptoProviderProtocol {
syncContext: NSManagedObjectContext,
coreCryptoKeyMigrationManager: CoreCryptoKeyMigrationManagerProtocol,
allowCreation: Bool = true,
localDomain: String?,
backgroundTaskManager: (any BackgroundTaskManager)?
localDomain: String?
) {
self.selfUserID = selfUserID
self.sharedContainerURL = sharedContainerURL
Expand All @@ -97,16 +94,12 @@ public actor CoreCryptoProvider: CoreCryptoProviderProtocol {
self.coreCryptoKeyMigrationManager = coreCryptoKeyMigrationManager
self.featureRespository = LegacyFeatureRepository(context: syncContext)
self.localDomain = localDomain
self.backgroundTaskManager = backgroundTaskManager
}

public func coreCrypto() async throws -> SafeCoreCrypto {
public func coreCrypto() async throws -> CoreCryptoProtocol {
let coreCrypto = try await getCoreCrypto()
try await registerMlsTransportIfNecessary(with: coreCrypto)
return SafeCoreCrypto(
backgroundTaskManager: backgroundTaskManager,
coreCrypto: coreCrypto
)
return coreCrypto
}

public func initialiseMLSWithBasicCredentials(mlsClientID: MLSClientID) async throws {
Expand Down Expand Up @@ -150,7 +143,7 @@ public actor CoreCryptoProvider: CoreCryptoProviderProtocol {
}
}

private func registerEpochObserverIfNecessary(with coreCrypto: SafeCoreCrypto) async throws {
private func registerEpochObserverIfNecessary(with coreCrypto: CoreCryptoProtocol) async throws {
guard let epochObserver, !hasRegisteredEpochObserver else {
return
}
Expand Down
91 changes: 0 additions & 91 deletions wire-ios-data-model/Source/Core Crypto/SafeCoreCrypto.swift

This file was deleted.

2 changes: 1 addition & 1 deletion wire-ios-data-model/Source/E2EIdentity/E2EIService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public final class E2EIService: E2EIServiceInterface {
private let onNewCRLsDistributionPointsSubject: PassthroughSubject<CRLsDistributionPoints, Never>
private let defaultDPoPTokenExpiry: UInt32 = 30
private let coreCryptoProvider: CoreCryptoProviderProtocol
private var coreCrypto: SafeCoreCrypto {
private var coreCrypto: CoreCryptoProtocol {
get async throws {
try await coreCryptoProvider.coreCrypto()
}
Expand Down
8 changes: 4 additions & 4 deletions wire-ios-data-model/Source/E2EIdentity/E2EISetupService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public final class E2EISetupService: E2EISetupServiceInterface {

private let featureRepository: LegacyFeatureRepositoryInterface
private let coreCryptoProvider: CoreCryptoProviderProtocol
private var coreCrypto: SafeCoreCrypto {
private var coreCrypto: CoreCryptoProtocol {
get async throws {
try await coreCryptoProvider.coreCrypto()
}
Expand All @@ -71,19 +71,19 @@ public final class E2EISetupService: E2EISetupServiceInterface {
// MARK: - Public interface

public func isTrustAnchorRegistered() async throws -> Bool {
try await coreCrypto.transaction { context in
try await coreCryptoProvider.coreCrypto().transaction { context in
try await context.e2eiIsPkiEnvSetup()
}
}

public func registerTrustAnchor(_ trustAnchor: String) async throws {
try await coreCrypto.transaction { context in
try await coreCryptoProvider.coreCrypto().transaction { context in
try await context.e2eiRegisterAcmeCa(trustAnchorPem: trustAnchor)
}
}

public func registerFederationCertificate(_ certificate: String) async throws {
_ = try await coreCrypto.transaction { context in
try await coreCryptoProvider.coreCrypto().transaction { context in
try await context.e2eiRegisterIntermediateCa(certPem: certificate)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public final class E2EIVerificationStatusService: E2EIVerificationStatusServiceI
// MARK: - Properties

private let coreCryptoProvider: CoreCryptoProviderProtocol
private var coreCrypto: SafeCoreCrypto {
private var coreCrypto: CoreCryptoProtocol {
get async throws {
try await coreCryptoProvider.coreCrypto()
}
Expand Down
4 changes: 2 additions & 2 deletions wire-ios-data-model/Source/MLS/CreateMLSGroupUseCase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ struct CreateMLSGroupUseCase {
private let parentGroupID: MLSGroupID?
private let removalKeys: BackendMLSPublicKeys?
private let defaultCipherSuite: Feature.MLS.Config.MLSCipherSuite
private let coreCrypto: SafeCoreCrypto
private let coreCrypto: any CoreCryptoProtocol
private let staleKeyMaterialDetector: any StaleMLSKeyDetectorProtocol
private let actionsProvider: any MLSActionsProviderProtocol
private let notificationContext: NotificationContext
Expand All @@ -35,7 +35,7 @@ struct CreateMLSGroupUseCase {
parentGroupID: MLSGroupID?,
removalKeys: BackendMLSPublicKeys?,
defaultCipherSuite: Feature.MLS.Config.MLSCipherSuite,
coreCrypto: SafeCoreCrypto,
coreCrypto: any CoreCryptoProtocol,
staleKeyMaterialDetector: any StaleMLSKeyDetectorProtocol,
actionsProvider: any MLSActionsProviderProtocol,
notificationContext: NotificationContext
Expand Down
2 changes: 1 addition & 1 deletion wire-ios-data-model/Source/MLS/MLSActionExecutor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public actor MLSActionExecutor: MLSActionExecutorProtocol {
private let onNewCRLsDistributionPointsSubject = PassthroughSubject<CRLsDistributionPoints, Never>()
private let featureRepository: LegacyFeatureRepositoryInterface

private var coreCrypto: SafeCoreCrypto {
private var coreCrypto: CoreCryptoProtocol {
get async throws {
try await coreCryptoProvider.coreCrypto()
}
Expand Down
12 changes: 5 additions & 7 deletions wire-ios-data-model/Source/MLS/MLSEncryptionService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public final class MLSEncryptionService: MLSEncryptionServiceInterface {
self.coreCryptoProvider = coreCryptoProvider
}

var coreCrypto: SafeCoreCrypto {
var coreCrypto: CoreCryptoProtocol {
get async throws {
try await coreCryptoProvider.coreCrypto()
}
Expand All @@ -75,12 +75,10 @@ public final class MLSEncryptionService: MLSEncryptionServiceInterface {
) async throws -> Data {
do {
WireLogger.mls.debug("encrypting message (\(message.count) bytes) for group (\(groupID))")
return try await coreCrypto.transaction {
try await $0.encryptMessage(
conversationId: groupID.conversationId,
message: message
)
}
return try await coreCrypto.transaction { try await $0.encryptMessage(
conversationId: groupID.conversationId,
message: message
) }
} catch {
WireLogger.mls.error("failed to encrypt message for group (\(groupID)): \(String(describing: error))")
throw MLSMessageEncryptionError.failedToEncryptMessage
Expand Down
2 changes: 1 addition & 1 deletion wire-ios-data-model/Source/MLS/MLSService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public final class MLSService: MLSServiceInterface {
private let onEpochChangedSubject = PassthroughSubject<MLSGroupID, Never>()
public let localDomain: String

private var coreCrypto: SafeCoreCrypto {
private var coreCrypto: CoreCryptoProtocol {
get async throws {
try await coreCryptoProvider.coreCrypto()
}
Expand Down
Loading
Loading