Skip to content

Bring swift-crypto up to date with CryptoKit 2025 Beta 1 #359

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 8 commits into from
Jun 16, 2025

Conversation

Lukasa
Copy link
Contributor

@Lukasa Lukasa commented Jun 9, 2025

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.

@Lukasa Lukasa added the ⚠️ semver/major Breaks existing public API. label Jun 9, 2025
@Lukasa
Copy link
Contributor Author

Lukasa commented Jun 9, 2025

@fpseverino Thank you for your hard work on the MLKEM/MLDSA implementations! You'll see that they have been brought across as the implementation of the common API layer. In the next week or so we should discuss strategies to allow _CryptoExtras to extend the APIs for the custom mu, as well as potentially to lower the availability guards to match the original implementation.

@0xTim I've also taken this opportunity to have the _CryptoExtras API export Crypto, so only one target is necessary. We should also discuss using the beta period to rename _CryptoExtras, and what that name should be.

Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a planned minor release of swift-crypto before this major one? Because otherwise these "Compatibility" files would not be needed.

In any case, I could update the current implementation of MLKEM and MLDSA to use the future CryptoKit API and simplify everything a bit.

Copy link
Contributor Author

@Lukasa Lukasa Jun 10, 2025

Choose a reason for hiding this comment

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

I think that would be a reasonable idea. As for a minor release, that's a good question. We could choose to do so, or not. Do you have a preference?

@fpseverino
Copy link
Contributor

as well as potentially to lower the availability guards to match the original implementation.

I'm sorry, I didn't quite understand what you mean here. Could you break that down for me?

For ML-DSA, the minimum version was macOS 10.15 (because of CryptoKitError) and I see that it is still that.
As for ML-KEM, in my implementation the minimum version was macOS 14, because in CryptoKit the KEMPrivateKey and KEMPublicKey protocols require macOS 14 (though their versions in swift-crypto only require 10.15); now I see that the minimum version of ML-KEM has been lowered to 10.15.

@Lukasa
Copy link
Contributor Author

Lukasa commented Jun 10, 2025

The actual availability guards will have to be lifted to the 26 release cycle, as that is the availability of the CryptoKit implementations. As you've noted, the BoringSSL-backed implementations have more availability. One of the questions I have will be, can we offer a graceful way to opt in to lowering those guards. Is that even worth doing?

@fpseverino
Copy link
Contributor

fpseverino commented Jun 10, 2025

I think the answer to both questions will have to be the same.

As for a minor release, that's a good question. We could choose to do so, or not. Do you have a preference?

If the minimum required version of ML-DSA and ML-KEM will be raised in September, I don't know how much sense there is in releasing them now with a lower minimum required version, especially considering that many packages already depend on the "3.0.0"..<"5.0.0" version range. It could be a breaking change.

One of the questions I have will be, can we offer a graceful way to opt in to lowering those guards. Is that even worth doing?

On the other hand, it would be nice if these algorithms worked with pre v26 versions, but that would only be possible in Linux and platforms using BoringSSL, right? On Apple platforms it would still require v26, and that would create a discrepancy.

To conclude, in my opinion the simplest and clearest thing would be to release the new post-quantum algorithms with the API and availability guards they will have in CryptoKit.
I just hope that if this is the case, a beta of swift-crypto v4 will be released soon, so that we can start playing with it.

cc @ptoffy as a potential downstream customer who could use ML-DSA in JWTKit

@Lukasa
Copy link
Contributor Author

Lukasa commented Jun 13, 2025

That makes sense @fpseverino, thanks for that proposal. Yes, I'll try to take a beta shortly: I'll clean up the failing CI and then start a side branch for managing the beta releases.

@Lukasa Lukasa changed the base branch from main to wwdc-25 June 16, 2025 10:10
@Lukasa
Copy link
Contributor Author

Lukasa commented Jun 16, 2025

I'm merging this into the tracking branch, over the API breakage check (which is expected).

@Lukasa Lukasa merged commit b5dde9c into apple:wwdc-25 Jun 16, 2025
27 of 30 checks passed
@Lukasa Lukasa deleted the cb-wwdc25-beta-1 branch June 16, 2025 13:54
@0xTim 0xTim mentioned this pull request Jul 1, 2025
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
⚠️ semver/major Breaks existing public API.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants