Skip to content

crypto_stream

John Regan edited this page Jan 3, 2022 · 3 revisions

Wrappers for the crypto_stream functions.

Synopsis

local luasodium = require'luasodium'

local message = 'a message to xor'
local key = luasodium.crypto_stream_keygen()
local nonce = string.rep('\0',luasodium.crypto_stream_NONCEBYTES)
local xord = luasodium.crypto_stream_xor(message,nonce,key)
assert(luasodium.crypto_stream_xor(xord,nonce,key) == message)

Constants

  • luasodium.crypto_stream_NONCEBYTES
  • luasodium.crypto_stream_KEYBYTES
  • luasodium.crypto_stream_xsalsa20_NONCEBYTES
  • luasodium.crypto_stream_xsalsa20_KEYBYTES
  • luasodium.crypto_stream_salsa20_NONCEBYTES
  • luasodium.crypto_stream_xsalsa20_KEYBYTES
  • luasodium.crypto_stream_salsa2012_NONCEBYTES
  • luasodium.crypto_stream_xsalsa2012_KEYBYTES
  • luasodium.crypto_stream_xchacha20_NONCEBYTES
  • luasodium.crypto_stream_xchacha20_KEYBYTES
  • luasodium.crypto_stream_chacha20_NONCEBYTES
  • luasodium.crypto_stream_chacha20_KEYBYTES
  • luasodium.crypto_stream_chacha20_ietf_NONCEBYTES
  • luasodium.crypto_stream_chacha20_ietf_KEYBYTES

Functions

crypto_stream

syntax: string pseudorandom = luasodium.crypto_stream(number length, string nonce, string key)

Return a string of pseudo random bytes using the given nonce and key.

crypto_stream_xor

syntax: string result = luasodium.crypto_stream_xor(string message, string nonce, string key)

Applies the crypto_stream_xor operation to a message with nonce and key.

crypto_stream_keygen

syntax string key = luasodium.crypto_stream_keygen()

Returns a new, random key (with length crypto_stream_KEYBYTES).

crypto_stream_xsalsa20

syntax: string pseudorandom = luasodium.crypto_stream_xsalsa20(number length, string nonce, string key)

Return a string of pseudo random bytes using the given nonce and key, using the XSalsa20 stream cipher.

crypto_stream_xsalsa20_xor

syntax: string result = luasodium.crypto_stream_xsalsa20_xor(string message, string nonce, string key)

Applies the crypto_stream_xsalsa20_xor operation to a message with nonce and key.

crypto_stream_xsalsa20_xor_ic

syntax: string result = luasodium.crypto_stream_xsalsa20_xor_ic(string message, string nonce, string key, number ic)

Applies the crypto_stream_xsalsa20_xor_ic operation to a message with nonce and key, with the initial value of the block counter set to ic.

crypto_stream_xsalsa20_keygen

syntax string key = luasodium.crypto_stream_xsalsa20_keygen()

Returns a new, random key (with length crypto_stream_xsalsa20_KEYBYTES).

crypto_stream_salsa20

syntax: string pseudorandom = luasodium.crypto_stream_salsa20(number length, string nonce, string key)

Return a string of pseudo random bytes using the given nonce and key, using the Salsa20 stream cipher.

crypto_stream_salsa20_xor

syntax: string result = luasodium.crypto_stream_salsa20_xor(string message, string nonce, string key)

Applies the crypto_stream_salsa20_xor operation to a message with nonce and key.

crypto_stream_salsa20_xor_ic

syntax: string result = luasodium.crypto_stream_salsa20_xor_ic(string message, string nonce, string key, number ic)

Applies the crypto_stream_salsa20_xor_ic operation to a message with nonce and key, with the initial value of the block counter set to ic.

crypto_stream_salsa20_keygen

syntax string key = luasodium.crypto_stream_salsa20_keygen()

Returns a new, random key (with length crypto_stream_salsa20_KEYBYTES).

crypto_stream_salsa2012

syntax: string pseudorandom = luasodium.crypto_stream_salsa2012(number length, string nonce, string key)

Return a string of pseudo random bytes using the given nonce and key, using the Salsa20 stream cipher.

crypto_stream_salsa2012_xor

syntax: string result = luasodium.crypto_stream_salsa2012_xor(string message, string nonce, string key)

Applies the crypto_stream_salsa2012_xor operation to a message with nonce and key.

crypto_stream_salsa2012_keygen

syntax string key = luasodium.crypto_stream_salsa2012_keygen()

Returns a new, random key (with length crypto_stream_salsa2012_KEYBYTES).

crypto_stream_salsa208

syntax: string pseudorandom = luasodium.crypto_stream_salsa208(number length, string nonce, string key)

Return a string of pseudo random bytes using the given nonce and key, using the Salsa20 stream cipher.

crypto_stream_salsa208_xor

syntax: string result = luasodium.crypto_stream_salsa208_xor(string message, string nonce, string key)

Applies the crypto_stream_salsa208_xor operation to a message with nonce and key.

crypto_stream_salsa208_keygen

syntax string key = luasodium.crypto_stream_salsa208_keygen()

Returns a new, random key (with length crypto_stream_salsa208_KEYBYTES).

crypto_stream_xchacha20

syntax: string pseudorandom = luasodium.crypto_stream_xchacha20(number length, string nonce, string key)

Return a string of pseudo random bytes using the given nonce and key, using the XChaCha20 stream cipher.

crypto_stream_xchacha20_xor

syntax: string result = luasodium.crypto_stream_xchacha20_xor(string message, string nonce, string key)

Applies the crypto_stream_xchacha20_xor operation to a message with nonce and key.

crypto_stream_xchacha20_xor_ic

syntax: string result = luasodium.crypto_stream_xchacha20_xor_ic(string message, string nonce, string key, number ic)

Applies the crypto_stream_salsa20_xor_ic operation to a message with nonce and key, with the initial value of the block counter set to ic.

crypto_stream_xchacha20_keygen

syntax string key = luasodium.crypto_stream_xchacha20_keygen()

Returns a new, random key (with length crypto_stream_xchacha20_KEYBYTES).

crypto_stream_chacha20

syntax: string pseudorandom = luasodium.crypto_stream_chacha20(number length, string nonce, string key)

Return a string of pseudo random bytes using the given nonce and key, using the ChaCha20 stream cipher.

crypto_stream_chacha20_xor

syntax: string result = luasodium.crypto_stream_chacha20_xor(string message, string nonce, string key)

Applies the crypto_stream_chacha20_xor operation to a message with nonce and key.

crypto_stream_chacha20_xor_ic

syntax: string result = luasodium.crypto_stream_chacha20_xor_ic(string message, string nonce, string key, number ic)

Applies the crypto_stream_salsa20_xor_ic operation to a message with nonce and key, with the initial value of the block counter set to ic.

crypto_stream_chacha20_keygen

syntax string key = luasodium.crypto_stream_chacha20_keygen()

Returns a new, random key (with length crypto_stream_chacha20_KEYBYTES).

crypto_stream_chacha20_ietf

syntax: string pseudorandom = luasodium.crypto_stream_chacha20_ietf(number length, string nonce, string key)

Return a string of pseudo random bytes using the given nonce and key, using the ChaCha20 stream cipher (IETF variant).

crypto_stream_chacha20_ietf_xor

syntax: string result = luasodium.crypto_stream_chacha20_ietf_xor(string message, string nonce, string key)

Applies the crypto_stream_chacha20_ietf_xor operation to a message with nonce and key.

crypto_stream_chacha20_ietf_xor_ic

syntax: string result = luasodium.crypto_stream_chacha20_ietf_xor_ic(string message, string nonce, string key, number ic)

Applies the crypto_stream_salsa20_ietf_xor_ic operation to a message with nonce and key, with the initial value of the block counter set to ic.

crypto_stream_chacha20_ietf_keygen

syntax string key = luasodium.crypto_stream_chacha20_ietf_keygen()

Returns a new, random key (with length crypto_stream_chacha20_ietf_KEYBYTES).