Conversation
Lukasa
left a comment
There was a problem hiding this comment.
Thanks for opening this PR!
This is an interesting idea. However, because it lacks a BoringSSL backend, I think the bar for accepting it into this repo is quite high. In general things without BoringSSL backends can just as easily be shipped outside swift-crypto as inside, because there is no need for a new set of C backend libraries. To that end, I'd encourage you to publish this code as a standalone Swift package.
|
Thank you for the quick response. I appreciate the desire to stay close to BoringSSL's feature set. I'd like to share why I believe Argon2id is a critical addition for the Swift community right now:
Given the importance of Argon2id for modern security, would you be open to hosting this Swift-native version in |
|
I remain inclined to think that a best version of the Swift ecosystem is one in which people feel comfortable doing important work outside of Apple-owned repositories. Swift Crypto has access to the vendored copy of BoringSSL, which provides some of the best cryptographic implementations on the planet in terms of performance and correctness. That's highly valuable, and getting access to those primitives is a good reason to add something to the library. When that access is unnecessary, I want to encourage folks to feel free to innovate away from the slower cycles of this library. As and when BoringSSL support lands, we can of course revisit. |
Add Argon2id key derivation function (RFC 9106)
Checklist
If you've made changes to
gybfiles./scripts/generate_boilerplate_files_with_gyb.shand included updated generated files in a commit of this pull requestMotivation:
Argon2id is the recommended password hashing algorithm by OWASP and the winner of the Password Hashing Competition. It provides superior resistance to GPU/ASIC attacks compared to bcrypt and PBKDF2. BoringSSL does not currently include Argon2, making a pure Swift implementation necessary for cross-platform support.
Modifications:
- Added
KDF.Argon2idpublic API following the existingKDF.Scryptpattern- Implemented pure Swift Argon2id (RFC 9106) with internal BLAKE2b primitive (variable-length output of 64–1024 bytes required by Argon2, not available in BoringSSL's fixed BLAKE2b-256)
- Added test case verified against official RFC 9106 Section 5.3 test vector
Files added:
- Sources/CryptoExtras/Key Derivation/Argon2/Argon2.swift
- Sources/CryptoExtras/Key Derivation/Argon2/Native/Argon2id+Native.swift
- Sources/CryptoExtras/Key Derivation/Argon2/Native/Blake2b.swift
- Tests/CryptoExtrasTests/Argon2Tests.swift
Result:
Users can derive cryptographic keys using Argon2id: