8000 Replace all Foundation imports with FoundationEssentials by Lukasa · Pull Request #363 · apple/swift-crypto · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Replace all Foundation imports with FoundationEssentials #363

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jun 18, 2025
Merged
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
< 8000 /details>
Diff view
Diff view
7 changes: 6 additions & 1 deletion Benchmarks/Benchmarks/Benchmarks.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,14 @@
//===----------------------------------------------------------------------===//
import Benchmark
import Crypto
import Foundation
import _CryptoExtras

#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif

let benchmarks = {
let defaultMetrics: [BenchmarkMetric] = [.mallocCountTotal, .cpuTotal]

Expand Down
4 changes: 4 additions & 0 deletions Sources/Crypto/AEADs/AES/GCM/AES-GCM.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,12 @@ typealias AESGCMImpl = OpenSSLAESGCMImpl
#if CRYPTOKIT_NO_ACCESS_TO_FOUNDATION
public import SwiftSystem
#else
#if canImport(FoundationEssentials)
Comment on lines 27 to +28
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason we shouldn't use #elseif to avoid the extra nesting?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really didn't want to think that hard about it, honestly, as we had to change a good 150 files.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair

public import FoundationEssentials
#else
public import Foundation
#endif
#endif

@available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, macCatalyst 13, visionOS 1.0, *)
extension AES {
Expand Down
4 changes: 4 additions & 0 deletions Sources/Crypto/AEADs/AES/GCM/BoringSSL/AES-GCM_boring.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@
#else
@_implementationOnly import CCryptoBoringSSL
import CryptoBoringWrapper
#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif

@available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, macCatalyst 13, visionOS 1.0, *)
enum OpenSSLAESGCMImpl {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@
@_implementationOnly import CCryptoBoringSSL
@_implementationOnly import CCryptoBoringSSLShims
import CryptoBoringWrapper
#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif

@available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, macCatalyst 13, visionOS 1.0, *)
extension BoringSSLAEAD {
Expand Down
4 changes: 4 additions & 0 deletions Sources/Crypto/AEADs/ChachaPoly/ChaChaPoly.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,12 @@ typealias ChaChaPolyImpl = OpenSSLChaChaPolyImpl
#if CRYPTOKIT_NO_ACCESS_TO_FOUNDATION
public import SwiftSystem
#else
#if canImport(FoundationEssentials)
public import FoundationEssentials
#else
public import Foundation
#endif
#endif


/// An implementation of the ChaCha20-Poly1305 cipher.
Expand Down
4 changes: 4 additions & 0 deletions Sources/Crypto/AEADs/Cipher.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,12 @@
#if CRYPTOKIT_NO_ACCESS_TO_FOUNDATION
import SwiftSystem
#else
#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif
#endif


@available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, macCatalyst 13, visionOS 1.0, *)
Expand Down
4 changes: 4 additions & 0 deletions Sources/Crypto/AEADs/Nonces.swift
10000
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,12 @@
#if CRYPTOKIT_NO_ACCESS_TO_FOUNDATION
public import SwiftSystem
#else
#if canImport(FoundationEssentials)
public import FoundationEssentials
#else
public import Foundation
#endif
#endif
// MARK: - Generated file, do NOT edit
// any edits of this file WILL be overwritten and thus discarded
// see section `gyb` in `README` for details.
Expand Down
4 changes: 4 additions & 0 deletions Sources/Crypto/AEADs/Nonces.swift.gyb
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,12 @@
#if CRYPTOKIT_NO_ACCESS_TO_FOUNDATION
public import SwiftSystem
#else
#if canImport(FoundationEssentials)
public import FoundationEssentials
#else
public import Foundation
#endif
#endif
// MARK: - Generated file, do NOT edit
// any edits of this file WILL be overwritten and thus discarded
// see section `gyb` in `README` for details.
Expand Down
4 changes: 4 additions & 0 deletions Sources/Crypto/ASN1/ASN1.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,12 @@
#if CRYPTOKIT_NO_ACCESS_TO_FOUNDATION
import SwiftSystem
#else
#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif
#endif

// This module implements "just enough" ASN.1. Specifically, we implement exactly enough ASN.1 DER parsing to handle
// the following use-cases:
Expand Down
4 changes: 4 additions & 0 deletions Sources/Crypto/ASN1/Basic ASN1 Types/ASN1Any.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,12 @@
#if CRYPTOKIT_NO_ACCESS_TO_FOUNDATION
import SwiftSystem
#else
#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif
#endif

@available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, macCatalyst 13, visionOS 1.0, *)
extension ASN1 {
Expand Down
4 changes: 4 additions & 0 deletions Sources/Crypto/ASN1/Basic ASN1 Types/ASN1BitString.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,12 @@
#if CRYPTOKIT_NO_ACCESS_TO_FOUNDATION
import SwiftSystem
#else
#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif
#endif

@available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, macCatalyst 13, visionOS 1.0, *)
extension ASN1 {
Expand Down
4 changes: 4 additions & 0 deletions Sources/Crypto/ASN1/Basic ASN1 Types/ASN1Boolean.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,12 @@
#if CRYPTOKIT_NO_ACCESS_TO_FOUNDATION
import SwiftSystem
#else
#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif
#endif

@available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, macCatalyst 13, visionOS 1.0, *)
extension Bool: ASN1ImplicitlyTaggable {
Expand Down
4 changes: 4 additions & 0 deletions Sources/Crypto/ASN1/Basic ASN1 Types/ASN1Identifier.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,12 @@
#if CRYPTOKIT_NO_ACCESS_TO_FOUNDATION
import SwiftSystem
#else
#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif
#endif

@available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, macCatalyst 13, visionOS 1.0, *)
extension ASN1 {
Expand Down
4 changes: 4 additions & 0 deletions Sources/Crypto/ASN1/Basic ASN1 Types/ASN1Integer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,12 @@
#if CRYPTOKIT_NO_ACCESS_TO_FOUNDATION
import SwiftSystem
#else
#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif
#endif

/// A protocol that represents any internal object that can present itself as a INTEGER, or be parsed from
/// a INTEGER.
Expand Down
4 changes: 4 additions & 0 deletions Sourc 10000 es/Crypto/ASN1/Basic ASN1 Types/ASN1Null.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,12 @@
#if CRYPTOKIT_NO_ACCESS_TO_FOUNDATION
import SwiftSystem
#else
#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif
#endif

@available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, macCatalyst 13, visionOS 1.0, *)
extension ASN1 {
Expand Down
4 changes: 4 additions & 0 deletions Sources/Crypto/ASN1/Basic ASN1 Types/ASN1OctetString.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,12 @@
#if CRYPTOKIT_NO_ACCESS_TO_FOUNDATION
import SwiftSystem
#else
#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif
#endif

@available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, macCatalyst 13, visionOS 1.0, *)
extension ASN1 {
Expand Down
4 changes: 4 additions & 0 deletions Sources/Crypto/ASN1/Basic ASN1 Types/ASN1Strings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,12 @@
#if CRYPTOKIT_NO_ACCESS_TO_FOUNDATION
import SwiftSystem
#else
#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif
#endif

@available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, macCatalyst 13, visionOS 1.0, *)
private func contents(of string: StaticString) -> ArraySlice<UInt8> {
Expand Down
4 changes: 4 additions & 0 deletions Sources/Crypto/ASN1/Basic ASN1 Types/ArraySliceBigint.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,12 @@
#if CRYPTOKIT_NO_ACCESS_TO_FOUNDATION
import SwiftSystem
#else
#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif
#endif

// For temporary purposes we pretend that ArraySlice is our "bigint" type. We don't really need anything else.
@available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, macCatalyst 13, visionOS 1.0, *)
Expand Down
4 changes: 4 additions & 0 deletions Sources/Crypto/ASN1/Basic ASN1 Types/GeneralizedTime.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,12 @@
#if CRYPTOKIT_NO_ACCESS_TO_FOUNDATION
import SwiftSystem
#else
#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif
#endif

@available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, macCatalyst 13, visionOS 1.0, *)
extension ASN1 {
Expand Down
4 changes: 4 additions & 0 deletions Sources/Crypto/ASN1/Basic ASN1 Types/ObjectIdentifier.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,12 @@
#if CRYPTOKIT_NO_ACCESS_TO_FOUNDATION
import SwiftSystem
#else
#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif
#endif

@available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, macCatalyst 13, visionOS 1.0, *)
extension ASN1 {
Expand Down
4 changes: 4 additions & 0 deletions Sources/Crypto/ASN1/ECDSASignature.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,12 @@
#if CRYPTOKIT_NO_ACCESS_TO_FOUNDATION
import SwiftSystem
#else
#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif
#endif

@available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, macCatalyst 13, visionOS 1.0, *)
extension ASN1 {
Expand Down
4 changes: 4 additions & 0 deletions Sources/Crypto/ASN1/PEMDocument.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,12 @@
#if CRYPTOKIT_NO_ACCESS_TO_FOUNDATION
import SwiftSystem
#else
#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif
#endif

@available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, macCatalyst 13, visionOS 1.0, *)
extension ASN1 {
Expand Down
4 changes: 4 additions & 0 deletions Sources/Crypto/ASN1/PKCS8PrivateKey.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,12 @@
#if CRYPTOKIT_NO_ACCESS_TO_FOUNDATION
import SwiftSystem
#else
#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif
#endif

@available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, macCatalyst 13, visionOS 1.0, *)
extension ASN1 {
Expand Down
4 changes: 4 additions & 0 deletions Sources/Crypto/ASN1/SEC1PrivateKey.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,12 @@
#if CRYPTOKIT_NO_ACCESS_TO_FOUNDATION
import SwiftSystem
#else
#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif
#endif

@available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, macCatalyst 13, visionOS 1.0, *)
extension ASN1 {
Expand Down
4 changes: 4 additions & 0 deletions Sources/Crypto/ASN1/SubjectPublicKeyInfo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,12 @@
#if CRYPTOKIT_NO_ACCESS_TO_FOUNDATION
import SwiftSystem
#else
#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif
#endif

@available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, macCatalyst 13, visionOS 1.0, *)
extension ASN1 {
Expand Down
4 changes: 4 additions & 0 deletions Sources/Crypto/Digests/Digest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,12 @@
#if CRYPTOKIT_NO_ACCESS_TO_FOUNDATION
public import SwiftSystem
#else
#if canImport(FoundationEssentials)
public import FoundationEssentials
#else
public import Foundation
#endif
#endif

#if hasFeature(Embedded)
/// A type that represents the output of a hash.
Expand Down
4 changes: 4 additions & 0 deletions Sources/Crypto/Digests/HashFunctions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,12 @@ typealias DigestImpl = OpenSSLDigestImpl
#if CRYPTOKIT_NO_ACCESS_TO_FOUNDATION
public import SwiftSystem
#else
#if canImport(FoundationEssentials)
public import FoundationEssentials
#else
public import Foundation
#endif
#endif

/// A type that performs cryptographically secure hashing.
///
Expand Down
4 changes: 4 additions & 0 deletions Sources/Crypto/HPKE/Ciphersuite/HPKE-AEAD.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,12 @@
#if CRYPTOKIT_NO_ACCESS_TO_FOUNDATION
import SwiftSystem
#else
#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif
#endif


@available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, macCatalyst 13, visionOS 1.0, *)
Expand Down
4 changes: 4 additions & 0 deletions Sources/Crypto/HPKE/Ciphersuite/HPKE-Ciphersuite.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,12 @@
#if CRYPTOKIT_NO_ACCESS_TO_FOUNDATION
import SwiftSystem
#else
#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif
#endif


@available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, macCatalyst 13, visionOS 1.0, *)
Expand Down
4 changes: 4 additions & 0 deletions Sources/Crypto/HPKE/Ciphersuite/HPKE-KDF.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,12 @@
#if CRYPTOKIT_NO_ACCESS_TO_FOUNDATION
import SwiftSystem
#else
#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif
#endif

@available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, macCatalyst 13, visionOS 1.0, *)
extension HPKE {
Expand Down
Loading
Loading
0