Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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: 1 addition & 1 deletion .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ jobs:
{ "name": "CXKCP", "type": "source", "exceptions": [] },
{ "name": "CXKCPShims", "type": "source", "exceptions": [] },
{ "name": "Crypto", "type": "source", "exceptions": [] },
{ "name": "_CryptoExtras", "type": "source", "exceptions": [] },
{ "name": "CryptoExtras", "type": "source", "exceptions": [] },
{ "name": "CCryptoBoringSSL", "type": "assembly", "exceptions": [ "*/AES/*.swift" ] }
]
}
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.DS_Store
/.build
.build
/out
/Packages
/*.xcodeproj
Expand All @@ -12,6 +12,7 @@ Package.resolved
DerivedData
.swiftpm
**/gyb.pyc
scripts/__pycache__/

.*.sw[nop]

Expand Down
2 changes: 1 addition & 1 deletion .spi.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
version: 1
builder:
configs:
- documentation_targets: [Crypto, _CryptoExtras]
- documentation_targets: [Crypto, CryptoExtras]
platform: linux
136 changes: 68 additions & 68 deletions .swiftformatignore
Original file line number Diff line number Diff line change
Expand Up @@ -69,46 +69,46 @@ Sources/Crypto/Util/PrettyBytes.swift
Sources/Crypto/Util/SafeCompare.swift
Sources/Crypto/Util/SecureBytes.swift
Sources/Crypto/Util/Zeroization.swift
Sources/_CryptoExtras/AES/AES_CBC.swift
Sources/_CryptoExtras/AES/AES_CFB.swift
Sources/_CryptoExtras/AES/AES_CTR.swift
Sources/_CryptoExtras/AES/AES_GCM_SIV.swift
Sources/_CryptoExtras/AES/Block Function.swift
Sources/_CryptoExtras/ARC/ARC+API.swift
Sources/_CryptoExtras/ARC/ARC.swift
Sources/_CryptoExtras/ARC/ARCCredential.swift
Sources/_CryptoExtras/ARC/ARCEncoding.swift
Sources/_CryptoExtras/ARC/ARCPrecredential.swift
Sources/_CryptoExtras/ARC/ARCPresentation.swift
Sources/_CryptoExtras/ARC/ARCRequest.swift
Sources/_CryptoExtras/ARC/ARCResponse.swift
Sources/_CryptoExtras/ARC/ARCServer.swift
Sources/_CryptoExtras/ZKPs/Prover.swift
Sources/_CryptoExtras/ZKPs/Verifier.swift
Sources/_CryptoExtras/ZKPs/ZKPToolbox.swift
Sources/_CryptoExtras/ChaCha20CTR/ChaCha20CTR.swift
Sources/_CryptoExtras/ECToolbox/ECToolbox.swift
Sources/_CryptoExtras/H2G/HashToField.swift
Sources/_CryptoExtras/Key Derivation/KDF.swift
Sources/_CryptoExtras/Key Derivation/PBKDF2/PBKDF2.swift
Sources/_CryptoExtras/Key Derivation/Scrypt/Scrypt.swift
Sources/_CryptoExtras/OPRFs/OPRF.swift
Sources/_CryptoExtras/OPRFs/OPRFClient.swift
Sources/_CryptoExtras/OPRFs/OPRFServer.swift
Sources/_CryptoExtras/OPRFs/VOPRF+API.swift
Sources/_CryptoExtras/OPRFs/VOPRFClient.swift
Sources/_CryptoExtras/OPRFs/VOPRFServer.swift
Sources/_CryptoExtras/RSA/RSA+BlindSigning.swift
Sources/_CryptoExtras/RSA/RSA.swift
Sources/_CryptoExtras/Util/BoringSSLHelpers.swift
Sources/_CryptoExtras/Util/DigestType.swift
Sources/_CryptoExtras/Util/Error.swift
Sources/_CryptoExtras/Util/I2OSP.swift
Sources/_CryptoExtras/Util/IntegerEncoding.swift
Sources/_CryptoExtras/Util/PEMDocument.swift
Sources/_CryptoExtras/Util/PrettyBytes.swift
Sources/_CryptoExtras/Util/SubjectPublicKeyInfo.swift
Sources/_CryptoExtras/ZKPs/DLEQ.swift
Sources/CryptoExtras/AES/AES_CBC.swift
Sources/CryptoExtras/AES/AES_CFB.swift
Sources/CryptoExtras/AES/AES_CTR.swift
Sources/CryptoExtras/AES/AES_GCM_SIV.swift
Sources/CryptoExtras/AES/Block Function.swift
Sources/CryptoExtras/ARC/ARC+API.swift
Sources/CryptoExtras/ARC/ARC.swift
Sources/CryptoExtras/ARC/ARCCredential.swift
Sources/CryptoExtras/ARC/ARCEncoding.swift
Sources/CryptoExtras/ARC/ARCPrecredential.swift
Sources/CryptoExtras/ARC/ARCPresentation.swift
Sources/CryptoExtras/ARC/ARCRequest.swift
Sources/CryptoExtras/ARC/ARCResponse.swift
Sources/CryptoExtras/ARC/ARCServer.swift
Sources/CryptoExtras/ZKPs/Prover.swift
Sources/CryptoExtras/ZKPs/Verifier.swift
Sources/CryptoExtras/ZKPs/ZKPToolbox.swift
Sources/CryptoExtras/ChaCha20CTR/ChaCha20CTR.swift
Sources/CryptoExtras/ECToolbox/ECToolbox.swift
Sources/CryptoExtras/H2G/HashToField.swift
Sources/CryptoExtras/Key Derivation/KDF.swift
Sources/CryptoExtras/Key Derivation/PBKDF2/PBKDF2.swift
Sources/CryptoExtras/Key Derivation/Scrypt/Scrypt.swift
Sources/CryptoExtras/OPRFs/OPRF.swift
Sources/CryptoExtras/OPRFs/OPRFClient.swift
Sources/CryptoExtras/OPRFs/OPRFServer.swift
Sources/CryptoExtras/OPRFs/VOPRF+API.swift
Sources/CryptoExtras/OPRFs/VOPRFClient.swift
Sources/CryptoExtras/OPRFs/VOPRFServer.swift
Sources/CryptoExtras/RSA/RSA+BlindSigning.swift
Sources/CryptoExtras/RSA/RSA.swift
Sources/CryptoExtras/Util/BoringSSLHelpers.swift
Sources/CryptoExtras/Util/DigestType.swift
Sources/CryptoExtras/Util/Error.swift
Sources/CryptoExtras/Util/I2OSP.swift
Sources/CryptoExtras/Util/IntegerEncoding.swift
Sources/CryptoExtras/Util/PEMDocument.swift
Sources/CryptoExtras/Util/PrettyBytes.swift
Sources/CryptoExtras/Util/SubjectPublicKeyInfo.swift
Sources/CryptoExtras/ZKPs/DLEQ.swift
Sources/crypto-shasum/main.swift
Tests/CryptoTests/ASN1/ASN1Tests.swift
Tests/CryptoTests/ASN1/GeneralizedTimeTests.swift
Expand Down Expand Up @@ -141,31 +141,31 @@ Tests/CryptoTests/Utils/RFCVector.swift
Tests/CryptoTests/Utils/SplitData.swift
Tests/CryptoTests/Utils/Wycheproof.swift
Tests/CryptoTests/Utils/XCTestUtils.swift
Tests/_CryptoExtrasTests/AES Block Function Tests.swift
Tests/_CryptoExtrasTests/AES-GCM-SIV-Runner.swift
Tests/_CryptoExtrasTests/AES_CBCTests.swift
Tests/_CryptoExtrasTests/AES_CFBTests.swift
Tests/_CryptoExtrasTests/AES_CTRTests.swift
Tests/_CryptoExtrasTests/ARC/ARCAPITests.swift
Tests/_CryptoExtrasTests/ARC/ARCEncodingTests.swift
Tests/_CryptoExtrasTests/ARC/ARCPublicAPITests.swift
Tests/_CryptoExtrasTests/ARC/ARCTestVectors.swift
Tests/_CryptoExtrasTests/ARC/ARCTests.swift
Tests/_CryptoExtrasTests/ChaCha20CTRTests.swift
Tests/_CryptoExtrasTests/ECToolbox/HashToCurveTests.swift
Tests/_CryptoExtrasTests/OPRFs/ECVOPRFTests.swift
Tests/_CryptoExtrasTests/OPRFs/VOPRFAPITests.swift
Tests/_CryptoExtrasTests/OPRFs/VOPRFPublicAPITests.swift
Tests/_CryptoExtrasTests/PBKDF2Tests.swift
Tests/_CryptoExtrasTests/ScryptTests.swift
Tests/_CryptoExtrasTests/TestRSABlindSigning.swift
Tests/_CryptoExtrasTests/TestRSABlindSigningAPI.swift
Tests/_CryptoExtrasTests/TestRSAEncryption.swift
Tests/_CryptoExtrasTests/TestRSASigning.swift
Tests/_CryptoExtrasTests/Util/IntegerEncodingTests.swift
Tests/_CryptoExtrasTests/Utils/BytesUtil.swift
Tests/_CryptoExtrasTests/Utils/RFCVector.swift
Tests/_CryptoExtrasTests/Utils/SplitData.swift
Tests/_CryptoExtrasTests/Utils/Wycheproof.swift
Tests/_CryptoExtrasTests/Utils/XCTestUtils.swift
Tests/_CryptoExtrasTests/ZKPs/ZKPToolbox.swift
Tests/CryptoExtrasTests/AES Block Function Tests.swift
Tests/CryptoExtrasTests/AES-GCM-SIV-Runner.swift
Tests/CryptoExtrasTests/AES_CBCTests.swift
Tests/CryptoExtrasTests/AES_CFBTests.swift
Tests/CryptoExtrasTests/AES_CTRTests.swift
Tests/CryptoExtrasTests/ARC/ARCAPITests.swift
Tests/CryptoExtrasTests/ARC/ARCEncodingTests.swift
Tests/CryptoExtrasTests/ARC/ARCPublicAPITests.swift
Tests/CryptoExtrasTests/ARC/ARCTestVectors.swift
Tests/CryptoExtrasTests/ARC/ARCTests.swift
Tests/CryptoExtrasTests/ChaCha20CTRTests.swift
Tests/CryptoExtrasTests/ECToolbox/HashToCurveTests.swift
Tests/CryptoExtrasTests/OPRFs/ECVOPRFTests.swift
Tests/CryptoExtrasTests/OPRFs/VOPRFAPITests.swift
Tests/CryptoExtrasTests/OPRFs/VOPRFPublicAPITests.swift
Tests/CryptoExtrasTests/PBKDF2Tests.swift
Tests/CryptoExtrasTests/ScryptTests.swift
Tests/CryptoExtrasTests/TestRSABlindSigning.swift
Tests/CryptoExtrasTests/TestRSABlindSigningAPI.swift
Tests/CryptoExtrasTests/TestRSAEncryption.swift
Tests/CryptoExtrasTests/TestRSASigning.swift
Tests/CryptoExtrasTests/Util/IntegerEncodingTests.swift
Tests/CryptoExtrasTests/Utils/BytesUtil.swift
Tests/CryptoExtrasTests/Utils/RFCVector.swift
Tests/CryptoExtrasTests/Utils/SplitData.swift
Tests/CryptoExtrasTests/Utils/Wycheproof.swift
Tests/CryptoExtrasTests/Utils/XCTestUtils.swift
Tests/CryptoExtrasTests/ZKPs/ZKPToolbox.swift
2 changes: 1 addition & 1 deletion Benchmarks/Benchmarks/Benchmarks.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
//===----------------------------------------------------------------------===//
import Benchmark
import Crypto
import _CryptoExtras
import CryptoExtras

#if canImport(FoundationEssentials)
import FoundationEssentials
Expand Down
2 changes: 1 addition & 1 deletion Benchmarks/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ let package = Package(
dependencies: [
.product(name: "Benchmark", package: "package-benchmark"),
.product(name: "Crypto", package: "swift-crypto"),
.product(name: "_CryptoExtras", package: "swift-crypto"),
.product(name: "CryptoExtras", package: "swift-crypto"),
],
path: "Benchmarks/",
plugins: [
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ act --container-architecture linux/amd64 pull_request -j cmake-lists -W ./.githu

You can find the underlying script at https://github.com/apple/swift-nio/blob/main/scripts/update-cmake-lists.sh . Using the script directly is less straightforwards because it requires you to pass the JSON config from the `pull_request.yml` file into the script, such as:
```
curl -s https://raw.githubusercontent.com/apple/swift-nio/main/scripts/update-cmake-lists.sh | CONFIG_JSON='{"targets":[{"name":"CCryptoBoringSSL","type":"source","exceptions":[]},{"name":"CCryptoBoringSSLShims","type":"source","exceptions":[]},{"name":"CryptoBoringWrapper","type":"source","exceptions":[]},{"name":"Crypto","type":"source","exceptions":[]},{"name":"_CryptoExtras","type":"source","exceptions":[]},{"name":"CCryptoBoringSSL","type":"assembly","exceptions":["*/AES/*.swift"]}]}' bash
curl -s https://raw.githubusercontent.com/apple/swift-nio/main/scripts/update-cmake-lists.sh | CONFIG_JSON='{"targets":[{"name":"CCryptoBoringSSL","type":"source","exceptions":[]},{"name":"CCryptoBoringSSLShims","type":"source","exceptions":[]},{"name":"CryptoBoringWrapper","type":"source","exceptions":[]},{"name":"Crypto","type":"source","exceptions":[]},{"name":"CryptoExtras","type":"source","exceptions":[]},{"name":"CCryptoBoringSSL","type":"assembly","exceptions":["*/AES/*.swift"]}]}' bash
```

## API Evolution
Expand Down
10 changes: 6 additions & 4 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@ let package = Package(
name: "swift-crypto",
products: [
.library(name: "Crypto", targets: ["Crypto"]),
.library(name: "_CryptoExtras", targets: ["_CryptoExtras"]),
// Kept for backward compatibility
.library(name: "_CryptoExtras", targets: ["CryptoExtras"]),
.library(name: "CryptoExtras", targets: ["CryptoExtras"]),
/* This target is used only for symbol mangling. It's added and removed automatically because it emits build warnings. MANGLE_START
.library(name: "CCryptoBoringSSL", type: .static, targets: ["CCryptoBoringSSL"]),
MANGLE_END */
Expand Down Expand Up @@ -177,7 +179,7 @@ let package = Package(
swiftSettings: swiftSettings
),
.target(
name: "_CryptoExtras",
name: "CryptoExtras",
dependencies: [
"CCryptoBoringSSL",
"CCryptoBoringSSLShims",
Expand Down Expand Up @@ -219,8 +221,8 @@ let package = Package(
swiftSettings: swiftSettings
),
.testTarget(
name: "_CryptoExtrasTests",
dependencies: ["_CryptoExtras"],
name: "CryptoExtrasTests",
dependencies: ["CryptoExtras"],
resources: [
.copy("ECToolbox/H2CVectors/P256_XMD-SHA-256_SSWU_RO_.json"),
.copy("ECToolbox/H2CVectors/P384_XMD-SHA-384_SSWU_RO_.json"),
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ When building Swift Crypto for use on Linux or Windows, Swift Crypto builds subs
2. The common API of Swift Crypto and CryptoKit.
3. The backing implementation of this common API, which calls into BoringSSL.

The API code, and some cryptographic primitives which are directly implemented in Swift, are exactly the same for both Apple CryptoKit and Swift Crypto. The backing BoringSSL-based implementation is unique to Swift Crypto.
The API code, and some cryptographic primitives which are directly implemented in Swift, are exactly the same for both Apple CryptoKit and Swift Crypto. The backing BoringSSL-based implementation is unique to Swift Crypto. In addition, there is another product, `CryptoExtras`, which provides additional functionality that is not offered in CryptoKit, which contains cryptographic APIS predominantly useful in the server ecosystem. **Note**: if you depend on CryptoExtras you'll bundle the BoringSSL implementation of the library in your application, no matter the platform.

## Evolution

Expand Down
2 changes: 1 addition & 1 deletion Sources/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ add_subdirectory(CXKCP)
add_subdirectory(CXKCPShims)
add_subdirectory(CryptoBoringWrapper)
add_subdirectory(Crypto)
add_subdirectory(_CryptoExtras)
add_subdirectory(CryptoExtras)
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
##
##===----------------------------------------------------------------------===##

add_library(_CryptoExtras
add_library(CryptoExtras
"AES/AES_CBC.swift"
"AES/AES_CFB.swift"
"AES/AES_CTR.swift"
Expand Down Expand Up @@ -76,29 +76,29 @@ add_library(_CryptoExtras
"ZKPs/ZKPToolbox.swift"
)

target_compile_options(_CryptoExtras PRIVATE -DCRYPTO_IN_SWIFTPM)
target_compile_options(CryptoExtras PRIVATE -DCRYPTO_IN_SWIFTPM)

if(NOT CMAKE_SYSTEM_NAME STREQUAL "Darwin")
target_compile_options(_CryptoExtras PRIVATE -DCRYPTO_IN_SWIFTPM_FORCE_BUILD_API)
target_compile_options(CryptoExtras PRIVATE -DCRYPTO_IN_SWIFTPM_FORCE_BUILD_API)
endif()

target_include_directories(_CryptoExtras PRIVATE
target_include_directories(CryptoExtras PRIVATE
$<TARGET_PROPERTY:CCryptoBoringSSL,INCLUDE_DIRECTORIES>
$<TARGET_PROPERTY:CCryptoBoringSSLShims,INCLUDE_DIRECTORIES>)

target_link_libraries(_CryptoExtras PUBLIC
target_link_libraries(CryptoExtras PUBLIC
$<$<NOT:$<PLATFORM_ID:Darwin>>:Foundation>
Crypto
CryptoBoringWrapper
CCryptoBoringSSL
CCryptoBoringSSLShims)

target_compile_options(_CryptoExtras PRIVATE ${SWIFT_CRYPTO_COMPILE_OPTIONS})
target_compile_options(CryptoExtras PRIVATE ${SWIFT_CRYPTO_COMPILE_OPTIONS})

target_link_options(_CryptoExtras PRIVATE
target_link_options(CryptoExtras PRIVATE
"$<$<PLATFORM_ID:Darwin>:SHELL:-Xlinker -framework -Xlinker Security>")

set_target_properties(_CryptoExtras PROPERTIES
set_target_properties(CryptoExtras PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_Swift_MODULE_DIRECTORY})

set_property(GLOBAL APPEND PROPERTY SWIFT_CRYPTO_EXPORTS _CryptoExtras)
set_property(GLOBAL APPEND PROPERTY SWIFT_CRYPTO_EXPORTS CryptoExtras)
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# ``_CryptoExtras``
# ``CryptoExtras``

Provides additional cryptographic APIs that are not available in CryptoKit (and therefore the core Crypto library).

Expand All @@ -10,7 +10,7 @@ Provides additional cryptographic APIs that are not available in CryptoKit (and

### Ciphers

- ``_CryptoExtras/Crypto/AES``
- ``CryptoExtras/Crypto/AES``

### Public key cryptography

Expand All @@ -22,4 +22,4 @@ Provides additional cryptographic APIs that are not available in CryptoKit (and

### Legacy algorithms

- ``_CryptoExtras/Crypto/Insecure``
- ``CryptoExtras/Crypto/Insecure``
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import Foundation
#endif
import XCTest
import Crypto
import _CryptoExtras
import CryptoExtras

final class AESBlockFunctionTests: XCTestCase {
static let nistPlaintextChunks: [[UInt8]] = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import Foundation
#endif
import XCTest
import Crypto
import _CryptoExtras
import CryptoExtras

struct AEADTestGroup: Codable {
let ivSize: Int
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import FoundationEssentials
#else
import Foundation
#endif
import _CryptoExtras
import CryptoExtras
import XCTest

final class CBCTests: XCTestCase {
Expand Down Expand Up @@ -162,7 +162,7 @@ final class CBCTests: XCTestCase {
}
}
}

func testToDataConversion() throws {
let randomBytes = (0..<16).map { _ in UInt8.random(in: UInt8.min...UInt8.max) }
let dataIn = Data(randomBytes)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

import Crypto
import CryptoBoringWrapper
@testable import _CryptoExtras
@testable import CryptoExtras
import XCTest

final class AES_CFBTests: XCTestCase {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import FoundationEssentials
#else
import Foundation
#endif
@testable import _CryptoExtras
@testable import CryptoExtras
import XCTest

final class AESCTRTests: XCTestCase {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
//
//===----------------------------------------------------------------------===//
import Crypto
@testable import _CryptoExtras
@testable import CryptoExtras
import XCTest

@available(iOS 16.0, macOS 13.0, watchOS 9.0, tvOS 16.0, macCatalyst 16.0, visionOS 2.0, *)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//
@testable import _CryptoExtras
@testable import CryptoExtras
import XCTest
import Crypto

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
//
//===----------------------------------------------------------------------===//
import Crypto
import _CryptoExtras // NOTE: No @testable import, because we want to test the public API.
import CryptoExtras // NOTE: No @testable import, because we want to test the public API.
import XCTest

@available(iOS 16.0, macOS 13.0, watchOS 9.0, tvOS 16.0, macCatalyst 16.0, visionOS 2.0, *)
Expand Down
Loading