Compare commits

..
11 Commits
Author SHA1 Message Date
+6 e0883b430c Final catchup merge (#415)
This is the last catchup merge into the WWDC-25 branch required to get
the two branches to line up. From here, it's a straightforward merge to
`main` to get the WWDC-25 branch in.

---------

Co-authored-by: YourMJK <37852512+YourMJK@users.noreply.github.com>
Co-authored-by: Rick Newton-Rogers <rnro@apple.com>
Co-authored-by: Raphael <josephnoir@users.noreply.github.com>
Co-authored-by: Si Beaumont <beaumont@apple.com>
Co-authored-by: Evan Wilde <ewilde@apple.com>
Co-authored-by: Tim Condon <0xTim@users.noreply.github.com>
Co-authored-by: Gus Cairo <gus.cairo@apple.com>
Co-authored-by: George Barnett <gbarnett@apple.com>
Co-authored-by: Fabrice de Gans <Steelskin@users.noreply.github.com>
Co-authored-by: Wojciech Nagrodzki <278594+wnagrodzki@users.noreply.github.com>
Co-authored-by: Jesse L. Zamora <xtremekforever@gmail.com>
Co-authored-by: aryan-25 <aryan_shah@apple.com>
Co-authored-by: Gwynne Raskind <gwynne@vapor.codes>
Co-authored-by: 3405691582 <dsk@google.com>
Co-authored-by: Paul Toffoloni <69189821+ptoffy@users.noreply.github.com>
2025-09-24 17:22:11 +01:00
Si Beaumont 459adb9e07 Fix compiler guard for SHA-3 tests (#401) 2025-09-22 13:40:32 +00:00
Tim Condon 4e662b89da Rename _CryptoExtras Take 2 (#407)
Following on from #281, opened as a new PR as the conflicts were too
many

### Checklist
- [x] I've run tests to see all new and existing tests pass
- [x] I've followed the code style of the rest of the project
- [x] I've read the [Contribution Guidelines](CONTRIBUTING.md)
- [x] 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

### Motivation:

_[Explain here the context, and why you're making that change. What is
the problem you're trying to solve.]_

### Modifications:

_[Describe the modifications you've done.]_

### Result:

_[After your change, what will change.]_
2025-09-15 15:07:07 +01:00
Cory Benfield ea7f8fbce1 Update to RC SDK (#410)
This patch brings us up-to-date with the RC SDK. There are a couple of
tweaks to the MLDSA code and the XWing code, mostly a few minor
interface changes. I've adopted those in the backing code, and also
wired up the SHA3 integrity checks.
2025-09-10 10:26:24 +01:00
+3 890595d10e Catch-up merge main into wwdc25 branch (#403)
Co-authored-by: YourMJK <37852512+YourMJK@users.noreply.github.com>
Co-authored-by: Rick Newton-Rogers <rnro@apple.com>
Co-authored-by: Raphael <josephnoir@users.noreply.github.com>
Co-authored-by: Si Beaumont <beaumont@apple.com>
Co-authored-by: Evan Wilde <ewilde@apple.com>
Co-authored-by: Tim Condon <0xTim@users.noreply.github.com>
Co-authored-by: Gus Cairo <gus.cairo@apple.com>
Co-authored-by: George Barnett <gbarnett@apple.com>
Co-authored-by: Fabrice de Gans <Steelskin@users.noreply.github.com>
Co-authored-by: Wojciech Nagrodzki <278594+wnagrodzki@users.noreply.github.com>
Co-authored-by: Jesse L. Zamora <xtremekforever@gmail.com>
Co-authored-by: aryan-25 <aryan_shah@apple.com>
2025-09-09 16:12:32 +01:00
Si Beaumont d9f3641899 [WWDC25] Add SHA-3 implementation backed by XKCP (#397)
## Motivation

CryptoKit is adding API for SHA-3, which BoringSSL does not support. To
maintain API parity, we need to provide a backing implementation. For
this, we can use XKCP[^1], which provides the reference implementation,
as well as several optimized solutions, suitable for vendoring into
other projects.

## Modifications

The following changes have been made in separate commits to help with
the review:

- Add vendor-xkcp.sh script
- Revendor xkcp#master (heads/master-0-g11297f5)
- Add CXCKP target with modulemap and umbrella header
- Add CXKCPTests test target with simple test vectors
- Add CXKCPShims with function wrappers for macros to call from Swift
- Remove #if false guard from HashFunctions_SHA3.swift
- Add SHA-3 implementation backed by libXKCP
- Add new DigestImplSHA3 platform-specific type alias
- Remove #if false from DigestsTests.swift to get SHA-3 tests

## Result

Swift Crypto provides functioning SHA-3 API.

## Notes

This PR is for the `wwdc-25` side branch.

[^1]: https://github.com/XKCP/XKCP
2025-08-11 19:28:46 +01:00
Cory Benfield 9b0697120a Adopt Swift 6 mode (#368)
Motivation

The Swift 6 language mode adopts data-race safety by default. While
Swift Crypto itself has no concurrent code, it is still useful to force
us to ensure that our code is properly Sendable-correct.

Modifications

- @unchecked Sendable on several CoW data types
- Some necessary Sendable constraints on ECToolbox protocols
- Add some missing protocol constraints on ARC types.

Result

Swift 6 clean.
2025-06-23 09:47:46 +01:00
Cory BenfieldandYourMJK 8be108101e Perform another catch-up merge for the WWDC 2025 branch (#367)
Co-authored-by: YourMJK <37852512+YourMJK@users.noreply.github.com>
2025-06-20 07:19:17 +01:00
Cory BenfieldandYourMJK 1eb3eec7d9 Catch the WWDC-25 branch up to the tip of main (#365)
To keep the WWDC-25 branch from rotting too badly, we'll be doing
regular catch-up merges. This is the first.

Co-authored-by: YourMJK <37852512+YourMJK@users.noreply.github.com>
2025-06-18 16:17:54 +01:00
Cory Benfield 83a1500dac Replace all Foundation imports with FoundationEssentials (#363)
### Motivation:

FoundationEssentials produces smaller binaries on most platforms.

### Modifications:

Where FoundationEssentials is available, import that.

### Result:

Improved binary size
2025-06-18 15:59:27 +01:00
Cory Benfield b5dde9c658 Bring swift-crypto up to date with CryptoKit 2025 Beta 1 (#359)
This PR sets swift-crypto up for alignment with the WWDC 2025 CryptoKit
APIs. This includes the parity APIs for MLKEM and MLDSA, as well as
XWing.

At this time the SHA3 APIs are disabled, as they require a novel
implementation strategy. This will come later in the summer. All API
features that require SHA3 are therefore also disabled at runtime.
2025-06-16 14:54:28 +01:00
2 changed files with 5 additions and 11 deletions

No files matched your search

+5 -10
View File
@@ -7,9 +7,9 @@ Swift Crypto is an open-source implementation of a substantial portion of the AP
Swift Crypto is available as a Swift Package Manager package. To use it, add the following dependency in your `Package.swift`:
```swift
// swift-crypto 1.x, 2.x, 3.x, and 4.x are almost API compatible, so most clients
// swift-crypto 1.x, 2.x and 3.x are almost API compatible, so most clients
// should allow any of them
.package(url: "https://github.com/apple/swift-crypto.git", "1.0.0" ..< "5.0.0"),
.package(url: "https://github.com/apple/swift-crypto.git", "1.0.0" ..< "4.0.0"),
```
and to your target, add `Crypto` to your dependencies. You can then `import Crypto` to get access to Swift Crypto's functionality.
@@ -108,7 +108,7 @@ If you believe you have identified a vulnerability in Swift Crypto, please [repo
### Swift versions
The most recent versions of Swift Crypto support Swift 6 and newer. The minimum Swift version supported by Swift Crypto releases are detailed below:
The most recent versions of Swift Crypto support Swift 5.7 and newer. The minimum Swift version supported by Swift Crypto releases are detailed below:
Swift Crypto | Minimum Swift Version
--------------------|----------------------
@@ -119,8 +119,7 @@ Swift Crypto | Minimum Swift Version
`3.1.0 ..< 3.3.0` | 5.7
`3.3.0 ..< 3.8.0` | 5.8
`3.9.0 ..< 3.13.0` | 5.9
`3.13.0 ..< 4.0.0` | 5.10
`4.0.0 ...` | 6.0
`3.13.0 ...` | 5.10
### Compatibility
@@ -132,14 +131,10 @@ SemVer and Swift Crypto's Public API guarantees should result in a working progr
Swift Crypto 2.0.0 was released in September 2021. The only breaking change between Swift Crypto 2.0.0 and 1.0.0 was the addition of new cases in the `CryptoError` enumeration. For most users, then, it's safe to depend on either the 1.0.0 _or_ 2.0.0 series of releases.
Swift Crypto 3.0.0 was released in September 2023. Again the only breaking change was the addition of new cases in the `CryptoError` enumeration, so most users can safely depend on the 1.0.0, 2.0.0, or 3.0.0 series of releases.
Swift Crypto 4.0.0 was released in September 2025. Again the only breaking change was the addition of new cases in the `CryptoError` enumeration, so most users can safely depend on the 1.0.0, 2.0.0, 3.0.0, or 4.0.0 series of releases. Note that in this release `_CryptoExtras` was renamed to `CryptoExtras`. The old products and targets have been kept around for compatibility reasons, but users depending only on new code should use `CryptoExtras` not `_CryptoExtras`.
To do so, please use the following dependency in your `Package.swift`:
```swift
.package(url: "https://github.com/apple/swift-crypto.git", "1.0.0" ..< "5.0.0"),
.package(url: "https://github.com/apple/swift-crypto.git", "1.0.0" ..< "3.0.0"),
```
### Developing Swift Crypto on macOS
@@ -11,7 +11,6 @@
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//
import Crypto
import Foundation
import XCTest