libsodium_crypto_core_salsa2012 (libsodium v3.0.1)

View Source

The 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

c()

A crypto_core_salsa2012_CONSTBYTES (16-byte) binary.

A crypto_core_salsa2012_INPUTBYTES (16-byte) binary.

k()

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

c()

-type c() :: <<_:128>>.

A crypto_core_salsa2012_CONSTBYTES (16-byte) binary.

in()

-type in() :: <<_:128>>.

A crypto_core_salsa2012_INPUTBYTES (16-byte) binary.

k()

-type k() :: <<_:256>>.

A crypto_core_salsa2012_KEYBYTES (32-byte) binary.

out()

-type out() :: <<_:512>>.

A crypto_core_salsa2012_OUTPUTBYTES (64-byte) binary.

Functions

constbytes()

-spec constbytes() -> Result when Result :: 16.

Return crypto_core_salsa2012_constbytes(), in bytes.

crypto_core_salsa2012(In, K, C)

-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.

inputbytes()

-spec inputbytes() -> Result when Result :: 16.

Return crypto_core_salsa2012_inputbytes(), in bytes.

keybytes()

-spec keybytes() -> Result when Result :: 32.

Return crypto_core_salsa2012_keybytes(), in bytes.

outputbytes()

-spec outputbytes() -> Result when Result :: 64.

Return crypto_core_salsa2012_outputbytes(), in bytes.