You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Stdlib: password hashing, HMAC and constant-time comparison (Crypto) #459
The stdlib has Digest.sha256 and secure random bytes (#404). Authentication needs three more things, all of which are one call into OTP's crypto but are untyped Any through BEAM.* today:
Getting any of these subtly wrong is a security bug, which is the argument for one reviewed implementation over one per application.
A possible surface:
Crypto.Password.hash(password) # -> String, self-describing: scheme$rounds$salt$key
Crypto.Password.verify(password, stored) # -> Bool, constant time
Crypto.hmac(:sha256, key, data) # -> Binary
Crypto.equal?(a, b) # -> Bool, constant time
docs/web-stack-plan.md lists Crypto among the wrappers to promote into the stdlib once a framework has proved the API; a working userland version of the first two rows now exists in an application (PBKDF2-HMAC-SHA256, per-password salt, parameters stored with the hash) and can be contributed as a starting point.
Environment: Kex 0.4.0-rc.1 (30c7979), Tey 0.2.1, Erlang/OTP 29.0.5 (Homebrew), macOS arm64. Found while building an application on Rodolfo 0.2 and Harmat 0.1.
Another use case: an S3-compatible storage backend for Metro (Metro.Storage). Signing a request for S3 (AWS Signature Version 4) chains HMAC-SHA256, each key being the previous step's binary digest:
Activity
akoskovacs commentedon Oct 15, 2026
Another use case: an S3-compatible storage backend for Metro (
Metro.Storage). Signing a request for S3 (AWS Signature Version 4) chains HMAC-SHA256, each key being the previous step's binary digest:So beyond
Crypto.hmacSha256(key, message), it needs to:Binarykey and returnBinary, with.hexfor the last step;Digest.sha256(Binary) -> Binaryalready exists, which covers the payload hash. Until HMAC exists, Metro can only keep uploads in a folder.