libsodium_crypto_core_salsa2012 (libsodium v3.0.1)
View SourceThe Salsa20/12 core function (Salsa20 reduced to 12 rounds), 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.
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_salsa2012 or a higher-level construction.
Key = libsodium_randombytes:buf(libsodium_crypto_core_salsa2012:keybytes()),
In = libsodium_randombytes:buf(libsodium_crypto_core_salsa2012:inputbytes()),
Out = libsodium_crypto_core_salsa2012:crypto_core_salsa2012(In, Key, <<"expand 32-byte k">>),
64 = byte_size(Out),
Out = libsodium_crypto_core_salsa2012:crypto_core_salsa2012(In, Key, <<"expand 32-byte k">>).
Summary
Types
A crypto_core_salsa2012_CONSTBYTES (16-byte) binary.
A crypto_core_salsa2012_INPUTBYTES (16-byte) binary.
A crypto_core_salsa2012_KEYBYTES (32-byte) binary.
A crypto_core_salsa2012_OUTPUTBYTES (64-byte) binary.
Functions
Return crypto_core_salsa2012_constbytes(), in bytes.
Compute the Salsa20/12 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_salsa2012_inputbytes(), in bytes.
Return crypto_core_salsa2012_keybytes(), in bytes.
Return crypto_core_salsa2012_outputbytes(), in bytes.
Types
-type c() :: <<_:128>>.
A crypto_core_salsa2012_CONSTBYTES (16-byte) binary.
-type in() :: <<_:128>>.
A crypto_core_salsa2012_INPUTBYTES (16-byte) binary.
-type k() :: <<_:256>>.
A crypto_core_salsa2012_KEYBYTES (32-byte) binary.
-type out() :: <<_:512>>.
A crypto_core_salsa2012_OUTPUTBYTES (64-byte) binary.
Functions
-spec constbytes() -> Result when Result :: 16.
Return crypto_core_salsa2012_constbytes(), in bytes.
-spec crypto_core_salsa2012(In, K, C) -> Result when In :: in(), K :: k(), C :: c(), Result :: out().
Compute the Salsa20/12 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_salsa2012_inputbytes(), in bytes.
-spec keybytes() -> Result when Result :: 32.
Return crypto_core_salsa2012_keybytes(), in bytes.
-spec outputbytes() -> Result when Result :: 64.
Return crypto_core_salsa2012_outputbytes(), in bytes.