Skip to content
Open
Show file tree
Hide file tree
Changes from 35 commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
e9de693
Add an external mu variant of the ML-DSA API (65 and 87 variants)
fpseverino Jun 4, 2025
b5dde9c
Bring swift-crypto up to date with CryptoKit 2025 Beta 1 (#359)
Lukasa Jun 16, 2025
e09d149
Revert "Add an external mu variant of the ML-DSA API (65 and 87 varia…
fpseverino Jun 16, 2025
e25c941
Add an external mu variant of the ML-DSA API (65 and 87 variants)
fpseverino Jun 4, 2025
e016958
Revert "Add an external mu variant of the ML-DSA API (65 and 87 varia…
fpseverino Jun 16, 2025
2688efb
Merge branch 'mldsa-external-mu' of https://github.com/fpseverino/swi…
fpseverino Jun 16, 2025
74c97de
Add external mu variant of ML-DSA to BoringSSL implementation
fpseverino Jun 16, 2025
a6213d7
Add external mu API to wrapper with `package` level
fpseverino Jun 16, 2025
bc935ac
Expose external mu API in CryptoExtras
fpseverino Jun 16, 2025
f8ed3ee
Add tests for external mu variant
fpseverino Jun 16, 2025
64aa6ca
Small formatting fixes
fpseverino Jun 16, 2025
fdb09e2
Use computed variable to get BoringSSL implementation
fpseverino Jun 16, 2025
f8bb7ef
Add `@testable` back in tests
fpseverino Jun 16, 2025
8f06719
Make the linter happy
fpseverino Jun 16, 2025
67074c0
Update CMakeLists and use FoundationEssentials
fpseverino Jun 17, 2025
83a1500
Replace all Foundation imports with FoundationEssentials (#363)
Lukasa Jun 18, 2025
1eb3eec
Catch the WWDC-25 branch up to the tip of main (#365)
Lukasa Jun 18, 2025
2c12b1b
Merge branch 'wwdc-25' into mldsa-external-mu
fpseverino Jun 18, 2025
794dfa6
Update DocC
fpseverino Jun 19, 2025
8be1081
Perform another catch-up merge for the WWDC 2025 branch (#367)
Lukasa Jun 20, 2025
8e57f3e
Merge branch 'wwdc-25' into mldsa-external-mu
fpseverino Jun 20, 2025
9b06971
Adopt Swift 6 mode (#368)
Lukasa Jun 23, 2025
28350a9
Merge branch 'wwdc-25' into mldsa-external-mu
fpseverino Jun 23, 2025
63d96f1
Remove some warnings
fpseverino Jun 24, 2025
0434231
Format and remove warnings from MLKEM.swift
fpseverino Jun 24, 2025
66b1202
Remove `signature:` parameter label from `isValidSignature`
fpseverino Aug 6, 2025
d9f3641
[WWDC25] Add SHA-3 implementation backed by XKCP (#397)
simonjbeaumont Aug 11, 2025
478a430
Merge branch 'wwdc-25' into mldsa-external-mu
fpseverino Aug 18, 2025
890595d
Catch-up merge main into wwdc25 branch (#403)
Lukasa Sep 9, 2025
8ba4cb8
Merge branch 'wwdc-25' into mldsa-external-mu
fpseverino Sep 9, 2025
ea7f8fb
Update to RC SDK (#410)
Lukasa Sep 10, 2025
5247e53
Merge branch 'wwdc-25' into mldsa-external-mu
fpseverino Sep 10, 2025
d9638b0
Fix conflicts
fpseverino Sep 10, 2025
4a6a254
Remove unreleated stuff
fpseverino Sep 10, 2025
f9fa563
Fix conflicts
fpseverino Sep 10, 2025
1d62dfa
Move external mu methods to separate file
fpseverino Sep 12, 2025
47da0e2
Formatting
fpseverino Sep 12, 2025
3a8c300
Update CMakeLists.txt
fpseverino Sep 12, 2025
4e662b8
Rename _CryptoExtras Take 2 (#407)
0xTim Sep 15, 2025
d5fce84
Merge remote-tracking branch 'upstream/wwdc-25' into mldsa-external-mu
fpseverino Sep 15, 2025
46d7ce0
Move external mu files to new CryptoExtras module
fpseverino Sep 15, 2025
8ec37c7
Update `withUnsafeBytes` to `package` access level
fpseverino Sep 15, 2025
a34d9fb
Formatting
fpseverino Sep 15, 2025
2febca7
Update for macOS 26
fpseverino Sep 16, 2025
788c399
Make external mu work when `let development = false`
fpseverino Sep 16, 2025
981d583
Move MLDSA implementation to CryptoBoringWrapper
fpseverino Sep 16, 2025
97f7ce6
Update CMakeLists
fpseverino Sep 16, 2025
1d82983
Remove flag checks in CryptoBoringWrapper
fpseverino Sep 17, 2025
459adb9
Fix compiler guard for SHA-3 tests (#401)
simonjbeaumont Sep 22, 2025
e0883b4
Final catchup merge (#415)
Lukasa Sep 24, 2025
fc2e934
Merge branch 'wwdc-25' into mldsa-external-mu
fpseverino Sep 29, 2025
7bc3dcc
Merge branch 'main' into mldsa-external-mu
fpseverino Sep 29, 2025
6ebab68
Remove `MLDSA_boring.swift`
fpseverino Sep 29, 2025
d35c528
Merge branch 'main' into mldsa-external-mu
fpseverino Oct 8, 2025
ccde93d
Remove old `Optional+withUnsafeBytes`
fpseverino Oct 8, 2025
e754aae
Update CMakeLists
fpseverino Oct 23, 2025
0587ac3
Merge branch 'main' into mldsa-external-mu
fpseverino Oct 23, 2025
be80d9e
Merge branch 'main' into mldsa-external-mu
fpseverino Oct 23, 2025
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
4 changes: 2 additions & 2 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ _[One line description of your change]_
- [ ] I've updated the documentation if necessary

#### If you've made changes to `gyb` files
- [ ] I've run `.script/generate_boilerplate_files_with_gyb` and included updated generated files in a commit of this pull request
- [ ] I've run `./scripts/generate_boilerplate_files_with_gyb.sh` and included updated generated files in a commit of this pull request

### Motivation:

Expand All @@ -21,4 +21,4 @@ _[Describe the modifications you've done.]_

### Result:

_[After your change, what will change.]_
_[After your change, what will change.]_
21 changes: 21 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,32 @@ jobs:
linux_6_1_arguments_override: "--explicit-target-dependency-import-check error"
linux_nightly_next_arguments_override: "--explicit-target-dependency-import-check error"
linux_nightly_main_arguments_override: "--explicit-target-dependency-import-check error"
windows_6_0_enabled: true
windows_6_1_enabled: true
windows_nightly_next_enabled: true
windows_nightly_main_enabled: true
windows_6_0_arguments_override: "--explicit-target-dependency-import-check error"
windows_6_1_arguments_override: "--explicit-target-dependency-import-check error"
windows_nightly_next_arguments_override: "--explicit-target-dependency-import-check error"
windows_nightly_main_arguments_override: "--explicit-target-dependency-import-check error"

release-builds:
name: Release builds
uses: apple/swift-nio/.github/workflows/release_builds.yml@main
with:
windows_6_0_enabled: true
windows_6_1_enabled: true
windows_nightly_next_enabled: true
windows_nightly_main_enabled: true

cxx-interop:
name: Cxx interop
uses: apple/swift-nio/.github/workflows/cxx_interop.yml@main

static-sdk:
name: Static SDK
uses: apple/swift-nio/.github/workflows/static_sdk.yml@main

macos-tests:
name: macOS tests
uses: apple/swift-nio/.github/workflows/macos_tests.yml@main
Expand Down
15 changes: 15 additions & 0 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,15 @@ jobs:
windows_nightly_next_arguments_override: "--explicit-target-dependency-import-check error"
windows_nightly_main_arguments_override: "--explicit-target-dependency-import-check error"

release-builds:
name: Release builds
uses: apple/swift-nio/.github/workflows/release_builds.yml@main
with:
windows_6_0_enabled: true
windows_6_1_enabled: true
windows_nightly_next_enabled: true
windows_nightly_main_enabled: true

cxx-interop:
name: Cxx interop
uses: apple/swift-nio/.github/workflows/cxx_interop.yml@main
Expand All @@ -44,6 +53,8 @@ jobs:
{ "name": "CCryptoBoringSSL", "type": "source", "exceptions": [] },
{ "name": "CCryptoBoringSSLShims", "type": "source", "exceptions": [] },
{ "name": "CryptoBoringWrapper", "type": "source", "exceptions": [] },
{ "name": "CXKCP", "type": "source", "exceptions": [] },
{ "name": "CXKCPShims", "type": "source", "exceptions": [] },
{ "name": "Crypto", "type": "source", "exceptions": [] },
{ "name": "_CryptoExtras", "type": "source", "exceptions": [] },
{ "name": "CCryptoBoringSSL", "type": "assembly", "exceptions": [ "*/AES/*.swift" ] }
Expand All @@ -56,3 +67,7 @@ jobs:
with:
runner_pool: general
build_scheme: swift-crypto-Package

static-sdk:
name: Static SDK
uses: apple/swift-nio/.github/workflows/static_sdk.yml@main
1 change: 1 addition & 0 deletions .licenseignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ dev/update-benchmark-thresholds
**/*.der
.swiftformat
Sources/CCryptoBoringSSL/*
Sources/CXKCP/*
**/*.swift.gyb
scripts/*.patch
scripts/gyb
Expand Down
12 changes: 11 additions & 1 deletion .swiftformatignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ Sources/Crypto/Digests/Digest.swift
Sources/Crypto/Digests/Digests.swift
Sources/Crypto/Digests/HashFunctions.swift
Sources/Crypto/Digests/HashFunctions_SHA2.swift
Sources/Crypto/Digests/HashFunctions_SHA3.swift
Sources/Crypto/HPKE/Ciphersuite/HPKE-AEAD.swift
Sources/Crypto/HPKE/Ciphersuite/HPKE-Ciphersuite.swift
Sources/Crypto/HPKE/Ciphersuite/HPKE-KDF.swift
Expand All @@ -43,8 +44,12 @@ Sources/Crypto/HPKE/Modes/HPKE-Modes.swift
Sources/Crypto/Insecure/Insecure.swift
Sources/Crypto/Insecure/Insecure_HashFunctions.swift
Sources/Crypto/KEM/KEM.swift
Sources/Crypto/KEM/KEM-Errors.swift
Sources/Crypto/KEM/MLKEM.swift
Sources/Crypto/KEM/XWing.swift
Sources/Crypto/Key Agreement/DH.swift
Sources/Crypto/Key Agreement/ECDH.swift
Sources/Crypto/Key Derivation/ANSIx963.swift
Sources/Crypto/Key Derivation/HKDF.swift
Sources/Crypto/Key Wrapping/AESWrap.swift
Sources/Crypto/Keys/EC/Curve25519.swift
Expand All @@ -58,6 +63,7 @@ Sources/Crypto/Message Authentication Codes/MessageAuthenticationCode.swift
Sources/Crypto/PRF/AES.swift
Sources/Crypto/Signatures/ECDSA.swift
Sources/Crypto/Signatures/Ed25519.swift
Sources/Crypto/Signatures/MLDSA.swift
Sources/Crypto/Signatures/Signature.swift
Sources/Crypto/Util/PrettyBytes.swift
Sources/Crypto/Util/SafeCompare.swift
Expand Down Expand Up @@ -94,7 +100,6 @@ Sources/_CryptoExtras/OPRFs/VOPRFClient.swift
Sources/_CryptoExtras/OPRFs/VOPRFServer.swift
Sources/_CryptoExtras/RSA/RSA+BlindSigning.swift
Sources/_CryptoExtras/RSA/RSA.swift
Sources/_CryptoExtras/RSA/RSA_security.swift
Sources/_CryptoExtras/Util/BoringSSLHelpers.swift
Sources/_CryptoExtras/Util/DigestType.swift
Sources/_CryptoExtras/Util/Error.swift
Expand All @@ -116,6 +121,9 @@ Tests/CryptoTests/Encodings/DERTests.swift
Tests/CryptoTests/Encodings/ECKeyEncodingsTests.swift
Tests/CryptoTests/HPKE/HPKETests-TestVectors.swift
Tests/CryptoTests/HPKE/HPKETests.swift
Tests/CryptoTests/KEM/MLKEMKeyGenTests.swift
Tests/CryptoTests/KEM/MLKEMTests.swift
Tests/CryptoTests/KEM/XWingTests.swift
Tests/CryptoTests/Key Derivation/ECprivateKeysFromSeeds.swift
Tests/CryptoTests/Key Derivation/HKDFTests.swift
Tests/CryptoTests/Key Derivation/SharedSecretTests.swift
Expand All @@ -126,6 +134,8 @@ Tests/CryptoTests/SecureBytes/SecureBytesTests.swift
Tests/CryptoTests/Signatures/ECDSA/ECDSASignatureTests.swift
Tests/CryptoTests/Signatures/ECDSA/RawECDSASignaturesTests.swift
Tests/CryptoTests/Signatures/EdDSA/Ed25519-Runner.swift
Tests/CryptoTests/Signatures/MLDSA/MLDSAKeyGenTests.swift
Tests/CryptoTests/Signatures/MLDSA/MLDSATests.swift
Tests/CryptoTests/Utils/PrettyBytes.swift
Tests/CryptoTests/Utils/RFCVector.swift
Tests/CryptoTests/Utils/SplitData.swift
Expand Down
3 changes: 2 additions & 1 deletion .unacceptablelanguageignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
Sources/CCryptoBoringSSL/*
Sources/CCryptoBoringSSL/*
Sources/CXKCP/*
111 changes: 110 additions & 1 deletion Benchmarks/Benchmarks/Benchmarks.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,76 @@
//===----------------------------------------------------------------------===//
import Benchmark
import Crypto
import Foundation
import _CryptoExtras

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

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

Benchmark(
"arc-issue-p256",
configuration: Benchmark.Configuration(
metrics: defaultMetrics,
scalingFactor: .kilo,
maxDuration: .seconds(10_000_000),
maxIterations: 3
)
) { benchmark in
let privateKey = P256._ARCV1.PrivateKey()
let publicKey = privateKey.publicKey
let requestContext = Data("shared request context".utf8)
let precredential = try publicKey.prepareCredentialRequest(requestContext: requestContext)
let credentialRequest = precredential.credentialRequest

benchmark.startMeasurement()

for _ in benchmark.scaledIterations {
blackHole(try privateKey.issue(credentialRequest))
}
}

Benchmark(
"arc-verify-p256",
configuration: Benchmark.Configuration(
metrics: defaultMetrics,
scalingFactor: .kilo,
maxDuration: .seconds(10_000_000),
maxIterations: 10
)
) { benchmark in
let privateKey = P256._ARCV1.PrivateKey()
let publicKey = privateKey.publicKey
let requestContext = Data("shared request context".utf8)
let (presentationContext, presentationLimit) = (Data("shared presentation context".utf8), 2)
let precredential = try publicKey.prepareCredentialRequest(requestContext: requestContext)
let credentialRequest = precredential.credentialRequest
let credentialResponse = try privateKey.issue(credentialRequest)
var credential = try publicKey.finalize(credentialResponse, for: precredential)
let (presentation, nonce) = try credential.makePresentation(
context: presentationContext,
presentationLimit: presentationLimit
)

benchmark.startMeasurement()

for _ in benchmark.scaledIterations {
blackHole(
try privateKey.verify(
presentation,
requestContext: requestContext,
presentationContext: presentationContext,
presentationLimit: presentationLimit,
nonce: nonce
)
)
}
}

Benchmark(
"arc-issue-p384",
configuration: Benchmark.Configuration(
Expand Down Expand Up @@ -99,4 +163,49 @@ let benchmarks = {
blackHole(try privateKey.evaluate(blindedElement))
}
}

Benchmark(
"key-exchange-p256",
configuration: Benchmark.Configuration(
metrics: defaultMetrics,
scalingFactor: .kilo,
maxDuration: .seconds(10_000_000),
maxIterations: 10
)
) { benchmark in
for _ in benchmark.scaledIterations {
let (key1, key2) = (P256.KeyAgreement.PrivateKey(), P256.KeyAgreement.PrivateKey())
blackHole(try key1.sharedSecretFromKeyAgreement(with: key2.publicKey))
}
}

Benchmark(
"key-exchange-p384",
configuration: Benchmark.Configuration(
metrics: defaultMetrics,
scalingFactor: .kilo,
maxDuration: .seconds(10_000_000),
maxIterations: 10
)
) { benchmark in
for _ in benchmark.scaledIterations {
let (key1, key2) = (P384.KeyAgreement.PrivateKey(), P384.KeyAgreement.PrivateKey())
blackHole(try key1.sharedSecretFromKeyAgreement(with: key2.publicKey))
}
}

Benchmark(
"key-exchange-p521",
configuration: Benchmark.Configuration(
metrics: defaultMetrics,
scalingFactor: .kilo,
maxDuration: .seconds(10_000_000),
maxIterations: 10
)
) { benchmark in
for _ in benchmark.scaledIterations {
let (key1, key2) = (P521.KeyAgreement.PrivateKey(), P521.KeyAgreement.PrivateKey())
blackHole(try key1.sharedSecretFromKeyAgreement(with: key2.publicKey))
}
}
}
16 changes: 16 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@

cmake_minimum_required(VERSION 3.15.1)

if(POLICY CMP0157)
cmake_policy(SET CMP0157 NEW)
endif()

project(SwiftCrypto
LANGUAGES ASM C CXX Swift)

Expand Down Expand Up @@ -47,6 +51,18 @@ if(CMAKE_SYSTEM_NAME STREQUAL Darwin AND NOT CMAKE_CROSSCOMPILING)
set(CMAKE_RANLIB "/usr/bin/ranlib")
endif()

set(CMAKE_CXX_STANDARD 17)
if(CMAKE_SYSTEM_NAME STREQUAL Windows)
# We need to ensure that we don't include the min/max macros from the Windows SDK.
add_compile_definitions(NOMINMAX)
# We can only link against the DLL version of the MSVC runtime library for now.
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreadedDLL")
if(CMAKE_Swift_COMPILER_VERSION VERSION_EQUAL 0.0.0 OR CMAKE_Swift_COMPILER_VERSION VERSION_GREATER_EQUAL 6.2)
# We need to set the static library prefix to "lib" so that we can link against the static libraries.
set(CMAKE_STATIC_LIBRARY_PREFIX_Swift "lib")
endif()
endif()

if(NOT CMAKE_SYSTEM_NAME STREQUAL Darwin)
find_package(dispatch CONFIG)
find_package(Foundation CONFIG)
Expand Down
2 changes: 1 addition & 1 deletion NOTICE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ This product contains test vectors from Google's wycheproof project.

---

This product contains a derivation of various scripts from SwiftNIO.
This product contains a derivation of various files from SwiftNIO.

* LICENSE (Apache License 2.0):
* https://www.apache.org/licenses/LICENSE-2.0
Expand Down
Loading