libsodium_crypto_core_salsa20 (libsodium v3.0.1)
View SourceThe Salsa20 core function, which maps a keybytes/0 byte key, a
inputbytes/0 byte input (nonce and block counter) and a constbytes/0
byte constant to one outputbytes/0 byte keystream block. It is the
building block of the Salsa20 stream cipher.
The constant C is normally the 16-byte string <<"expand 32-byte k">>.
This is a low-level primitive; most applications should use
libsodium_crypto_stream_salsa20 or a higher-level construction.
Key = libsodium_randombytes:buf(libsodium_crypto_core_salsa20:keybytes()),
In = libsodium_randombytes:buf(libsodium_crypto_core_salsa20:inputbytes()),
Out = libsodium_crypto_core_salsa20:crypto_core_salsa20(In, Key, <<"expand 32-byte k">>),
64 = byte_size(Out),
Out = libsodium_crypto_core_salsa20:crypto_core_salsa20(In, Key, <<"expand 32-byte k">>).
Summary
Types
A crypto_core_salsa20_CONSTBYTES (16-byte) binary.
A crypto_core_salsa20_INPUTBYTES (16-byte) binary.
A crypto_core_salsa20_KEYBYTES (32-byte) binary.
A crypto_core_salsa20_OUTPUTBYTES (64-byte) binary.
Functions
Return crypto_core_salsa20_constbytes(), in bytes.
Compute the Salsa20 core of the inputbytes/0 byte input In
with the keybytes/0 byte key K and the constbytes/0 byte constant
C, returning outputbytes/0 bytes.
Return crypto_core_salsa20_inputbytes(), in bytes.
Return crypto_core_salsa20_keybytes(), in bytes.
Return crypto_core_salsa20_outputbytes(), in bytes.
Types
-type c() :: <<_:128>>.
A crypto_core_salsa20_CONSTBYTES (16-byte) binary.
-type in() :: <<_:128>>.
A crypto_core_salsa20_INPUTBYTES (16-byte) binary.
-type k() :: <<_:256>>.
A crypto_core_salsa20_KEYBYTES (32-byte) binary.
-type out() :: <<_:512>>.
A crypto_core_salsa20_OUTPUTBYTES (64-byte) binary.
Functions
-spec constbytes() -> Result when Result :: 16.
Return crypto_core_salsa20_constbytes(), in bytes.
Compute the Salsa20 core of the inputbytes/0 byte input In
with the keybytes/0 byte key K and the constbytes/0 byte constant
C, returning outputbytes/0 bytes.
-spec inputbytes() -> Result when Result :: 16.
Return crypto_core_salsa20_inputbytes(), in bytes.
-spec keybytes() -> Result when Result :: 32.
Return crypto_core_salsa20_keybytes(), in bytes.
-spec outputbytes() -> Result when Result :: 64.
Return crypto_core_salsa20_outputbytes(), in bytes.