apple / swift-crypto

Open-source implementation of a substantial portion of the API of Apple CryptoKit suitable for use on Linux platforms.
https://apple.github.io/swift-crypto
Apache License 2.0
1.43k stars 151 forks source link

Add Sendable annotation to Crypto Extras #208

Open 0xTim opened 8 months ago

0xTim commented 8 months ago

New API Proposal: Sendable Support

Motivation:

Use Swift Crypto types in concurrency contexts invariably starts to hit issues as no types are Sendable. I'm aware there are issues around the main Crypto target as that has match CryptoKit (or does it? Could we add Sendable conformance on Linux?) but it would be great to add it to the types in Crypto Extras

Importance:

It's possible to achieve this with a mix of @preconcurrency and @unchecked Sendable but neither of these are ideal for obvious reasons.

Lukasa commented 8 months ago

Yes, the goal is that the Crypto API exactly matches the CryptoKit one. This avoids users needing to deal with platform-specific imports or other logic.

For CryptoExtras, this can definitely be done separately. @rnro want to take a look at CryptoExtras?

rnro commented 8 months ago

Yep, sure.