feat: implement scrypt key derivation function#849
Merged
boorad merged 2 commits intomargelo:mainfrom Dec 7, 2025
Merged
Conversation
- uses EVP_PBE_scrypt API (same as Node.js) - all parameters are uint64_t for this API - added scrypt to iOS Podspec and Android CMakeLists - RFC 7914 test vectors included - fixed test case 1 expected hash to match RFC - maxmem set to 32MB for headroom - benchmark uses N=256 for faster runs - error handling in benchmark code
scrypt key derivation function
boorad
approved these changes
Dec 7, 2025
This was referenced Dec 7, 2025
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Scrypt Implementation (Node.js-Compatible · RFC 7914 Compliant)
This PR introduces a fully native, cryptographically correct implementation of
scrypt, matching Node.js behavior and passing all official RFC 7914 test vectors.Summary
This feature adds complete support for the
scryptpassword-based key derivation function with:EVP_PBE_scryptImplementation Details
✅ Core Implementation
Uses
EVP_PBE_scryptfor correctness (same as Node.js)Parameters (N, r, p, maxmem) handled as
uint64_t(required by OpenSSL)Platform integration:
CMakeLists.txtMirrors Node.js behavior exactly:
crypto.scrypt()crypto.scryptSync()Testing
✔ RFC 7914 Official Test Vectors
All 9 passed:
✔ API Compatibility
Both
scryptandscryptSyncbehave identically to Node.js.Benchmarks
Benchmarks compare:
1340.14xUsing N = 256 for mobile-friendly runs.
Includes proper memory limiting using OpenSSL’s
maxmem(default 32MB).🔐 Cryptographic Correctness
This implementation is cryptographically sound because it:
🛠 Breaking Changes
None — this is a new feature addition.