Changelog
View Source3.0.1 (2026-10-26)
- Fixes
- Building from a git checkout no longer downloads
config.guessandconfig.subfrom GNU Savannah while generating libsodium'sconfigurescript; it uses the copies installed with autotools, so the build works offline. Hex packages, which include the generated script, were not affected.
- Building from a git checkout no longer downloads
3.0.0 (2026-10-26)
See the migration guide for upgrading from 2.x.
- Breaking changes
- Requires Erlang/OTP 27 or later (module documentation uses
-moduledoc/-doc); CI covers OTP 28 and 29. - The port driver,
libsodium_server, andinclude/libsodium.hrlare gone.libsodium:call/2,3remains as a deprecated shim overlibsodium_nif; the port-specificcall/4,open/0, andclose/1are removed, as are the internalcall/1,2exports of each namespace module. - Arguments that are not binaries or integers now raise
badarginstead offunction_clause. - Streaming and precomputed states (hash, MAC, and signature
init/updatestates, secretstream states, andlibsodium_crypto_aead_aes256gcm:beforenm/1contexts) are opaque NIF resources (erlang:nif_resource(), exported as each module'sstate()type) instead of binaries holding the raw C struct. Each operation returns a new state and leaves its argument unchanged. States cannot be serialized, and passing one to another module's functions, or passing a binary, raisesbadarg. - The
libsodiumapplication no longer depends oncrypto,asn1, orpublic_key.
- Requires Erlang/OTP 27 or later (module documentation uses
- Enhancements
- Generate the native and Erlang sources, the test suite,
ex_doc.config, andREADME.mdfrom YAML definitions undercodegen/withjust codegen(orjust docker-codegen), mirroringlibdecaf: generated files are formatted and carry a content signature, and README examples run against the built library. - Replace the port driver with a NIF (
libsodium_nif). Calls over 64 KiB of input or output move to a dirty CPU scheduler, password hashing always runs on one, and streamingupdate/2functions yield whenever their timeslice is exhausted. - Every module has module and function documentation, specs, and multiline exports. Specs use exact binary types
for fixed-size keys, nonces, tags, and signatures (such as
libsodium_crypto_aead_aes256gcm:k(), which is<<_:256>>), integer ranges for bounded arguments, and literal results for fixed constants. just sanitizersbuilds libsodium and the NIF with AddressSanitizer and UndefinedBehaviorSanitizer in Docker and runs libsodium's tests, the Common Test suites, and a resource cleanup stress test against an ASan emulator.- Migration and development guides under
guides/, included in the documentation. - Benchee benchmarks under
bench/(just bench) compare libsodium's implementations with each other and with OTPcryptowhere it has an equivalent, after checking that both produce identical results. - Modernize
c_src/Makefile: build libsodium out of tree intoc_deps/libsodium-build, track header dependencies, and addformat,lint-format, and sanitizer (SANITIZE=1) support. - New namespaces for algorithms added to libsodium since 1.0.18:
- AEGIS authenticated encryption:
libsodium_crypto_aead_aegis128landlibsodium_crypto_aead_aegis256 - HKDF:
libsodium_crypto_kdf_hkdf_sha256andlibsodium_crypto_kdf_hkdf_sha512 - SHA-3:
libsodium_crypto_hash_sha3256andlibsodium_crypto_hash_sha3512 - Extendable-output functions:
libsodium_crypto_xof_shake128,libsodium_crypto_xof_shake256,libsodium_crypto_xof_turboshake128, andlibsodium_crypto_xof_turboshake256 - Post-quantum key encapsulation:
libsodium_crypto_kem,libsodium_crypto_kem_mlkem768, andlibsodium_crypto_kem_xwing - IP address encryption:
libsodium_crypto_ipcrypt - The Keccak-f[1600] permutation:
libsodium_crypto_core_keccak1600
- AEGIS authenticated encryption:
- New functions:
libsodium_crypto_box_curve25519xchacha20poly1305:seal/2,seal_open/3, andsealbytes/0libsodium_crypto_onetimeauth_poly1305:statebytes/0libsodium_crypto_pwhash:str_alg/4libsodium_randombytes:buf_deterministic/2libsodium_runtime:has_armcrypto/0libsodium_utils:sub/2(implemented by the port driver but never exported),memcmp/2,ip2bin/1, andbin2ip/1libsodium_version:library_minimal/0
- HMAC
init/1functions accept keys of any length, as libsodium does.
- Generate the native and Erlang sources, the test suite,
- Fixes
libsodium_crypto_aead_aes256gcm:beforenm/1and the_afternmfunctions are available again: states are copied into properly aligned memory instead of crashing the VM.libsodium_crypto_sign_ed25519:init/0,update/2,final_create/2, andfinal_verify/3now work; the port driver never implemented them.- The NaCl-style
libsodium_crypto_secretbox:crypto_secretbox/3andopen/3(and their xsalsa20poly1305 equivalents) returned uninitialized memory and overflowed a stack buffer; they now follow NaCl's padded format exactly. - Opening a ciphertext shorter than the authentication tag (
open_easyfor boxes and secret boxes) returns-1instead of overflowing the stack. - Outputs are allocated as binaries instead of stack arrays sized by the input, so large messages can no longer overflow the stack, and every output buffer is wiped before release. Several port driver memory leaks are gone.
libsodium_crypto_stream_chacha20:ietf_xor_ic/4raisesbadargwhen the block counter would overflow, instead of aborting the VM throughsodium_misuse().- Password hash strings are passed to libsodium NUL-terminated; strings of exactly
strbytes/0bytes were read past their end. - Out-of-range output lengths for password hashing and key derivation return
-1before allocating, instead of allocating caller-sized stack arrays. - libsodium is no longer configured with
--enable-opt, which tuned the build for the compiling machine's CPU.
2.0.0 (2022-08-31)
- Fixes
- Include
Makefilein hex.pm package so it works correctly with erlang.mk - Ditching the version tag matching upstream libsodium library since hex.pm requires semantic versioning :-( (which is really a good thing, I'm just whining that I can't break the rules just this once).
- Include
1.0.18 (2022-08-31)
Library Support
- Update to libsodium 1.0.18.
- Removed (deprecated upstream)
crypto_core_salsa208crypto_stream_aes128ctrcrypto_stream_salsa208
- Added
crypto_aead_xchacha20poly1305crypto_box_curve25519xchacha20poly1305crypto_core_ed25519crypto_core_hchacha20crypto_core_ristretto255crypto_kdfcrypto_kdf_blake2bcrypto_kxcrypto_pwhash_argon2idcrypto_scalarmult_ed25519crypto_scalarmult_ristretto255crypto_secretboxcrypto_secretbox_xchacha20poly1305crypto_secretbox_xsalsa20poly1305crypto_secretstream_xchacha20poly1305crypto_shorthash_siphashx24crypto_sign_ed25519phcrypto_stream_xchacha20crypto_verify_16crypto_verify_32crypto_verify_64sodium_base64_encoded_lensodium_base642binsodium_bin2base64sodium_padsodium_subsodium_unpad
Enhancements
- Switch from Travis CI to GitHub Actions.
- Relicense library under MIT license.
- Update version tag to match upstream libsodium library.
Enhancements
- Add detached functions to
libsodium_crypto_aead_aes256gcm:encrypt_detached/3encrypt_detached/4decrypt_detached/4decrypt_detached/5
- Add detached functions to
0.0.10 (2016-10-14)
- Enhancements
- Add detached functions to
libsodium_crypto_aead_aes256gcm:encrypt_detached/3encrypt_detached/4decrypt_detached/4decrypt_detached/5
- Add detached functions to
0.0.9 (2016-10-04)
- Fixes
- Segfault when using
libsodium_crypto_box:seal_open/3where ciphertext length is less than sealbytes. (See #5, thanks to @mtaylor91)
- Segfault when using
0.0.8 (2016-08-08)
- Library Support
- Update to libsodium 1.0.11.
0.0.7 (2016-05-31)
- Library Support
libsodium_crypto_aead_chacha20poly1305detached mode and IETF compliance.
0.0.6 (2016-05-24)
Enhancements
- Tests for the
crypto_pwhashgroup.
- Tests for the
Fixes
- Minor fixes to the following libraries:
libsodium_crypto_pwhashlibsodium_crypto_pwhash_argon2ilibsodium_crypto_pwhash_scryptsalsa208sha256
- Minor fixes to the following libraries:
0.0.5 (2016-05-24)
- Library Support
- Update to libsodium 1.0.10.
libsodium_crypto_pwhash(See #2)libsodium_crypto_pwhash_argon2i(See #2)
0.0.4 (2016-03-10)
- Library Support
libsodium_crypto_pwhash_scryptsalsa208sha256(See #1)
0.0.3 (2016-02-05)
- Fixes
- Minor fixes to build flags and port driver lookup.
0.0.2 (2016-01-16)
- Publish to hex.pm without binary files.
0.0.1 (2016-01-16)
Initial Release
Library Support
libsodium_crypto_aead_aes256gcmlibsodium_crypto_aead_chacha20poly1305libsodium_crypto_authlibsodium_crypto_auth_hmacsha256libsodium_crypto_auth_hmacsha512libsodium_crypto_auth_hmacsha512256libsodium_crypto_boxlibsodium_crypto_box_curve25519xsalsa20poly1305libsodium_crypto_core_hsalsa20libsodium_crypto_core_salsa20libsodium_crypto_core_salsa2012libsodium_crypto_core_salsa208libsodium_crypto_generichashlibsodium_crypto_generichash_blake2blibsodium_crypto_hashlibsodium_crypto_hash_sha256libsodium_crypto_hash_sha512libsodium_crypto_onetimeauthlibsodium_crypto_onetimeauth_poly1305libsodium_crypto_scalarmultlibsodium_crypto_scalarmult_curve25519libsodium_crypto_shorthashlibsodium_crypto_shorthash_siphash24libsodium_crypto_signlibsodium_crypto_sign_ed25519libsodium_crypto_streamlibsodium_crypto_stream_aes128ctrlibsodium_crypto_stream_chacha20libsodium_crypto_stream_salsa20libsodium_crypto_stream_salsa2012libsodium_crypto_stream_salsa208libsodium_crypto_stream_xsalsa20libsodium_randombyteslibsodium_runtimelibsodium_utilslibsodium_version
Basic Tests
aead_aes256gcmaead_chacha20poly1305sign