diff --git a/Sources/CryptoBoringWrapper/EC/EllipticCurvePoint.swift b/Sources/CryptoBoringWrapper/EC/EllipticCurvePoint.swift index b2c81383..dc593879 100644 --- a/Sources/CryptoBoringWrapper/EC/EllipticCurvePoint.swift +++ b/Sources/CryptoBoringWrapper/EC/EllipticCurvePoint.swift @@ -14,8 +14,13 @@ @_implementationOnly import CCryptoBoringSSL @_implementationOnly import CCryptoBoringSSLShims +#if canImport(FoundationEssentials) +import protocol FoundationEssentials.ContiguousBytes +import struct FoundationEssentials.Data +#else import protocol Foundation.ContiguousBytes import struct Foundation.Data +#endif /// A wrapper around BoringSSL's EC_POINT with some lifetime management and value semantics. @usableFromInline diff --git a/Sources/CryptoExtras/EC/Curve25519+PEM.swift b/Sources/CryptoExtras/EC/Curve25519+PEM.swift index 5e8071c8..9cbf92fa 100644 --- a/Sources/CryptoExtras/EC/Curve25519+PEM.swift +++ b/Sources/CryptoExtras/EC/Curve25519+PEM.swift @@ -13,9 +13,14 @@ //===----------------------------------------------------------------------===// import Crypto -import Foundation import SwiftASN1 +#if canImport(FoundationEssentials) +import FoundationEssentials +#else +import Foundation +#endif + @available(iOS 14.0, macOS 11.0, watchOS 7.0, tvOS 14.0, *) extension Curve25519.Signing.PrivateKey { /// A Distinguished Encoding Rules (DER) encoded representation of the private key. diff --git a/Sources/CryptoExtras/EC/PKCS8DERRepresentation.swift b/Sources/CryptoExtras/EC/PKCS8DERRepresentation.swift index bfaf11f4..d5ca84e9 100644 --- a/Sources/CryptoExtras/EC/PKCS8DERRepresentation.swift +++ b/Sources/CryptoExtras/EC/PKCS8DERRepresentation.swift @@ -13,9 +13,14 @@ //===----------------------------------------------------------------------===// import Crypto -import Foundation import SwiftASN1 +#if canImport(FoundationEssentials) +import FoundationEssentials +#else +import Foundation +#endif + @available(iOS 14.0, macOS 11.0, watchOS 7.0, tvOS 14.0, *) extension Curve25519.Signing.PrivateKey { /// A Distinguished Encoding Rules (DER) encoded representation of the private key in PKCS#8 format. diff --git a/Tests/CryptoExtrasTests/CMACTests.swift b/Tests/CryptoExtrasTests/CMACTests.swift index 386d906e..7f2c8abe 100644 --- a/Tests/CryptoExtrasTests/CMACTests.swift +++ b/Tests/CryptoExtrasTests/CMACTests.swift @@ -13,9 +13,14 @@ //===----------------------------------------------------------------------===// import Crypto import CryptoExtras -import Foundation import XCTest +#if canImport(FoundationEssentials) +import FoundationEssentials +#else +import Foundation +#endif + final class CMACTests: XCTestCase { // Borrowed from CryptoKit func testVector1() throws { diff --git a/Tests/CryptoExtrasTests/ECToolbox/BoringSSL/ECToolboxBoringSSLTests.swift b/Tests/CryptoExtrasTests/ECToolbox/BoringSSL/ECToolboxBoringSSLTests.swift index 4ce8552f..ce85cf1a 100644 --- a/Tests/CryptoExtrasTests/ECToolbox/BoringSSL/ECToolboxBoringSSLTests.swift +++ b/Tests/CryptoExtrasTests/ECToolbox/BoringSSL/ECToolboxBoringSSLTests.swift @@ -12,9 +12,14 @@ // //===----------------------------------------------------------------------===// import Crypto -import Foundation import XCTest +#if canImport(FoundationEssentials) +import FoundationEssentials +#else +import Foundation +#endif + #if !canImport(Darwin) || canImport(CryptoKit, _version: 241.100.42) // Corresponds to the CryptoKit in XCode 16.3, which has Sendable annotations import Crypto diff --git a/Tests/CryptoExtrasTests/PKCS8DERRepresentationTests.swift b/Tests/CryptoExtrasTests/PKCS8DERRepresentationTests.swift index f464e13b..41bf3271 100644 --- a/Tests/CryptoExtrasTests/PKCS8DERRepresentationTests.swift +++ b/Tests/CryptoExtrasTests/PKCS8DERRepresentationTests.swift @@ -13,11 +13,16 @@ //===----------------------------------------------------------------------===// import Crypto -import Foundation import XCTest @testable import CryptoExtras +#if canImport(FoundationEssentials) +import FoundationEssentials +#else +import Foundation +#endif + final class PKCS8DERRepresentationTests: XCTestCase { func test_RSA() { let rsaPrivateKeyPEM = """