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
17 changes: 16 additions & 1 deletion Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version:6.0
// swift-tools-version:6.1
//===----------------------------------------------------------------------===//
//
// This source file is part of the SwiftCrypto open source project
Expand Down Expand Up @@ -53,6 +53,7 @@ if development || isFreeBSD {
"CXKCPShims",
]
} else {
#if !canImport(Darwin)
let platforms: [Platform] = [
Platform.linux,
Platform.android,
Expand All @@ -71,6 +72,19 @@ if development || isFreeBSD {
.target(name: "CXKCP", condition: .when(platforms: platforms)),
.target(name: "CXKCPShims", condition: .when(platforms: platforms)),
]
#else
swiftSettings = [
.define("CRYPTO_IN_SWIFTPM"),
.define("CRYPTO_IN_SWIFTPM_FORCE_BUILD_API", .when(traits: ["FORCE_BUILD_SWIFT_CRYPTO_API"])),
]
dependencies = [
.target(name: "CCryptoBoringSSL", condition: .when(traits: ["FORCE_BUILD_SWIFT_CRYPTO_API"])),
.target(name: "CCryptoBoringSSLShims", condition: .when(traits: ["FORCE_BUILD_SWIFT_CRYPTO_API"])),
.target(name: "CryptoBoringWrapper", condition: .when(traits: ["FORCE_BUILD_SWIFT_CRYPTO_API"])),
.target(name: "CXKCP", condition: .when(traits: ["FORCE_BUILD_SWIFT_CRYPTO_API"])),
.target(name: "CXKCPShims", condition: .when(traits: ["FORCE_BUILD_SWIFT_CRYPTO_API"])),
]
#endif
}

// This doesn't work when cross-compiling: the privacy manifest will be included in the Bundle and
Expand All @@ -96,6 +110,7 @@ let package = Package(
.library(name: "CCryptoBoringSSL", type: .static, targets: ["CCryptoBoringSSL"]),
MANGLE_END */
],
traits: [.trait(name: "FORCE_BUILD_SWIFT_CRYPTO_API")],
dependencies: [
// Dependencies are added below so that they can be switched between local and absolute URLs
],
Expand Down
4 changes: 4 additions & 0 deletions Sources/CryptoExtras/AES/AES_CBC.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@
//
//===----------------------------------------------------------------------===//

#if CRYPTO_IN_SWIFTPM && !CRYPTO_IN_SWIFTPM_FORCE_BUILD_API
@_exported import CryptoKit
#else
import Crypto
#endif
#if canImport(FoundationEssentials)
import FoundationEssentials
#else
Expand Down
4 changes: 4 additions & 0 deletions Sources/CryptoExtras/AES/AES_CFB.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@
//
//===----------------------------------------------------------------------===//

#if CRYPTO_IN_SWIFTPM && !CRYPTO_IN_SWIFTPM_FORCE_BUILD_API
@_exported import CryptoKit
#else
import Crypto
#endif
#if canImport(FoundationEssentials)
import FoundationEssentials
#else
Expand Down
4 changes: 4 additions & 0 deletions Sources/CryptoExtras/AES/AES_CTR.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@
//
//===----------------------------------------------------------------------===//

#if CRYPTO_IN_SWIFTPM && !CRYPTO_IN_SWIFTPM_FORCE_BUILD_API
@_exported import CryptoKit
#else
import Crypto
#endif
#if canImport(FoundationEssentials)
import FoundationEssentials
#else
Expand Down
4 changes: 4 additions & 0 deletions Sources/CryptoExtras/AES/AES_GCM_SIV.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@
//
//===----------------------------------------------------------------------===//

#if CRYPTO_IN_SWIFTPM && !CRYPTO_IN_SWIFTPM_FORCE_BUILD_API
@_exported import CryptoKit
#else
import Crypto
#endif
@_implementationOnly import CCryptoBoringSSL
@_implementationOnly import CCryptoBoringSSLShims
import CryptoBoringWrapper
Expand Down
4 changes: 4 additions & 0 deletions Sources/CryptoExtras/AES/Block Function.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@
//
//===----------------------------------------------------------------------===//

#if CRYPTO_IN_SWIFTPM && !CRYPTO_IN_SWIFTPM_FORCE_BUILD_API
@_exported import CryptoKit
#else
import Crypto
#endif
@_implementationOnly import CCryptoBoringSSL
@_implementationOnly import CCryptoBoringSSLShims
import CryptoBoringWrapper
Expand Down
4 changes: 4 additions & 0 deletions Sources/CryptoExtras/AES/BoringSSL/AES_CFB_boring.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@
//===----------------------------------------------------------------------===//

@_implementationOnly import CCryptoBoringSSL
#if CRYPTO_IN_SWIFTPM && !CRYPTO_IN_SWIFTPM_FORCE_BUILD_API
@_exported import CryptoKit
#else
import Crypto
#endif

#if canImport(FoundationEssentials)
import FoundationEssentials
Expand Down
4 changes: 4 additions & 0 deletions Sources/CryptoExtras/AES/BoringSSL/AES_CTR_boring.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@
//===----------------------------------------------------------------------===//

@_implementationOnly import CCryptoBoringSSL
#if CRYPTO_IN_SWIFTPM && !CRYPTO_IN_SWIFTPM_FORCE_BUILD_API
@_exported import CryptoKit
#else
import Crypto
#endif

#if canImport(FoundationEssentials)
import FoundationEssentials
Expand Down
4 changes: 4 additions & 0 deletions Sources/CryptoExtras/AES/BoringSSL/AES_GCM_SIV_boring.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@

@_implementationOnly import CCryptoBoringSSL
@_implementationOnly import CCryptoBoringSSLShims
#if CRYPTO_IN_SWIFTPM && !CRYPTO_IN_SWIFTPM_FORCE_BUILD_API
@_exported import CryptoKit
#else
import Crypto
#endif
import CryptoBoringWrapper

#if canImport(FoundationEssentials)
Expand Down
6 changes: 5 additions & 1 deletion Sources/CryptoExtras/AES/CMAC.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@
//
//===----------------------------------------------------------------------===//
@_implementationOnly import CCryptoBoringSSL
#if CRYPTO_IN_SWIFTPM && !CRYPTO_IN_SWIFTPM_FORCE_BUILD_API
@_exported import CryptoKit
#else
import Crypto
#endif

#if canImport(FoundationEssentials)
import FoundationEssentials
Expand Down Expand Up @@ -47,7 +51,7 @@ extension AES {
/// - outputSize: The number of bytes of MAC to generate. Must be in the range 0 to 16 inclusive.
public init(key: SymmetricKey, outputSize: Int) throws {
guard [128, 192, 256].contains(key.bitCount) else {
throw CryptoError.incorrectKeySize
throw CryptoKitError.incorrectKeySize
}
guard (0...16).contains(outputSize) else {
throw CryptoKitError.incorrectParameterSize
Expand Down
4 changes: 4 additions & 0 deletions Sources/CryptoExtras/ARC/ARC+API.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//
#if CRYPTO_IN_SWIFTPM && !CRYPTO_IN_SWIFTPM_FORCE_BUILD_API
@_exported import CryptoKit
#else
import Crypto
#endif
#if canImport(FoundationEssentials)
import FoundationEssentials
#else
Expand Down
4 changes: 4 additions & 0 deletions Sources/CryptoExtras/ARC/ARC.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//
#if CRYPTO_IN_SWIFTPM && !CRYPTO_IN_SWIFTPM_FORCE_BUILD_API
@_exported import CryptoKit
#else
import Crypto
#endif
#if canImport(FoundationEssentials)
import FoundationEssentials
#else
Expand Down
4 changes: 4 additions & 0 deletions Sources/CryptoExtras/ARC/ARCCredential.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//
#if CRYPTO_IN_SWIFTPM && !CRYPTO_IN_SWIFTPM_FORCE_BUILD_API
@_exported import CryptoKit
#else
import Crypto
#endif
#if canImport(FoundationEssentials)
import FoundationEssentials
#else
Expand Down
4 changes: 4 additions & 0 deletions Sources/CryptoExtras/ARC/ARCEncoding.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@ import FoundationEssentials
#else
import Foundation
#endif
#if CRYPTO_IN_SWIFTPM && !CRYPTO_IN_SWIFTPM_FORCE_BUILD_API
@_exported import CryptoKit
#else
import Crypto
#endif

@available(macOS 10.15, iOS 13.2, tvOS 13.2, watchOS 6.1, macCatalyst 13.2, visionOS 1.2, *)
typealias ARCP256 = HashToCurveImpl<P256>
Expand Down
4 changes: 4 additions & 0 deletions Sources/CryptoExtras/ARC/ARCPrecredential.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//
#if CRYPTO_IN_SWIFTPM && !CRYPTO_IN_SWIFTPM_FORCE_BUILD_API
@_exported import CryptoKit
#else
import Crypto
#endif
#if canImport(FoundationEssentials)
import FoundationEssentials
#else
Expand Down
4 changes: 4 additions & 0 deletions Sources/CryptoExtras/ARC/ARCPresentation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//
#if CRYPTO_IN_SWIFTPM && !CRYPTO_IN_SWIFTPM_FORCE_BUILD_API
@_exported import CryptoKit
#else
import Crypto
#endif
#if canImport(FoundationEssentials)
import FoundationEssentials
#else
Expand Down
4 changes: 4 additions & 0 deletions Sources/CryptoExtras/ARC/ARCRequest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//
#if CRYPTO_IN_SWIFTPM && !CRYPTO_IN_SWIFTPM_FORCE_BUILD_API
@_exported import CryptoKit
#else
import Crypto
#endif
#if canImport(FoundationEssentials)
import FoundationEssentials
#else
Expand Down
4 changes: 4 additions & 0 deletions Sources/CryptoExtras/ARC/ARCResponse.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//
#if CRYPTO_IN_SWIFTPM && !CRYPTO_IN_SWIFTPM_FORCE_BUILD_API
@_exported import CryptoKit
#else
import Crypto
#endif
#if canImport(FoundationEssentials)
import FoundationEssentials
#else
Expand Down
4 changes: 4 additions & 0 deletions Sources/CryptoExtras/ARC/ARCServer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//
#if CRYPTO_IN_SWIFTPM && !CRYPTO_IN_SWIFTPM_FORCE_BUILD_API
@_exported import CryptoKit
#else
import Crypto
#endif
#if canImport(FoundationEssentials)
import FoundationEssentials
#else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@

@_implementationOnly import CCryptoBoringSSL
@_implementationOnly import CCryptoBoringSSLShims
#if CRYPTO_IN_SWIFTPM && !CRYPTO_IN_SWIFTPM_FORCE_BUILD_API
@_exported import CryptoKit
#else
import Crypto
#endif
import CryptoBoringWrapper

#if canImport(FoundationEssentials)
Expand Down
4 changes: 4 additions & 0 deletions Sources/CryptoExtras/ChaCha20CTR/ChaCha20CTR.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@

@_implementationOnly import CCryptoBoringSSL
@_implementationOnly import CCryptoBoringSSLShims
#if CRYPTO_IN_SWIFTPM && !CRYPTO_IN_SWIFTPM_FORCE_BUILD_API
@_exported import CryptoKit
#else
import Crypto
#endif
import CryptoBoringWrapper
#if canImport(FoundationEssentials)
import FoundationEssentials
Expand Down
4 changes: 4 additions & 0 deletions Sources/CryptoExtras/EC/Curve25519+PEM.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@
//
//===----------------------------------------------------------------------===//

#if CRYPTO_IN_SWIFTPM && !CRYPTO_IN_SWIFTPM_FORCE_BUILD_API
@_exported import CryptoKit
#else
import Crypto
#endif
import Foundation
import SwiftASN1

Expand Down
4 changes: 4 additions & 0 deletions Sources/CryptoExtras/EC/PKCS8DERRepresentation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@
//
//===----------------------------------------------------------------------===//

#if CRYPTO_IN_SWIFTPM && !CRYPTO_IN_SWIFTPM_FORCE_BUILD_API
@_exported import CryptoKit
#else
import Crypto
#endif
import Foundation
import SwiftASN1

Expand Down
4 changes: 4 additions & 0 deletions Sources/CryptoExtras/EC/PKCS8PrivateKey.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@
//
//===----------------------------------------------------------------------===//

#if CRYPTO_IN_SWIFTPM && !CRYPTO_IN_SWIFTPM_FORCE_BUILD_API
@_exported import CryptoKit
#else
import Crypto
#endif
import SwiftASN1

@available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, macCatalyst 13, visionOS 1.0, *)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//
#if CRYPTO_IN_SWIFTPM && !CRYPTO_IN_SWIFTPM_FORCE_BUILD_API
@_exported import CryptoKit
#else
import Crypto
#endif
import CryptoBoringWrapper

#if canImport(FoundationEssentials)
Expand Down
4 changes: 4 additions & 0 deletions Sources/CryptoExtras/ECToolbox/ECToolbox.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//
#if CRYPTO_IN_SWIFTPM && !CRYPTO_IN_SWIFTPM_FORCE_BUILD_API
@_exported import CryptoKit
#else
import Crypto
#endif
#if canImport(FoundationEssentials)
import FoundationEssentials
#else
Expand Down
4 changes: 4 additions & 0 deletions Sources/CryptoExtras/H2G/HashToField.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ import FoundationEssentials
#else
import Foundation
#endif
#if CRYPTO_IN_SWIFTPM && !CRYPTO_IN_SWIFTPM_FORCE_BUILD_API
@_exported import CryptoKit
#else
import Crypto
#endif

@available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, macCatalyst 13, visionOS 1.0, *)
extension Data {
Expand Down
4 changes: 4 additions & 0 deletions Sources/CryptoExtras/Key Derivation/KDF.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//
#if CRYPTO_IN_SWIFTPM && !CRYPTO_IN_SWIFTPM_FORCE_BUILD_API
@_exported import CryptoKit
#else
import Crypto
#endif
#if canImport(FoundationEssentials)
import FoundationEssentials
#else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//
#if CRYPTO_IN_SWIFTPM && !CRYPTO_IN_SWIFTPM_FORCE_BUILD_API
@_exported import CryptoKit
#else
import Crypto
#endif

#if canImport(FoundationEssentials)
import FoundationEssentials
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//
#if CRYPTO_IN_SWIFTPM && !CRYPTO_IN_SWIFTPM_FORCE_BUILD_API
@_exported import CryptoKit
#else
import Crypto
#endif

#if canImport(FoundationEssentials)
import FoundationEssentials
Expand Down
Loading