Skip to content

crypto_onetimeauth

John Regan edited this page Jan 3, 2021 · 1 revision

Wrapper for the crypto_onetimeauth functions.

Synopsis

local luasodium = require'luasodium'

local key = luasodium.crypto_onetimeauth_keygen()

local auth = luasodium.crypto_onetimeauth('a message',key)
assert(luasodium.crypto_onetimeauth_verify(auth,'a message',key) == true)

Constants

  • luasodium.crypto_onetimeauth_BYTES
  • luasodium.crypto_onetimeauth_KEYBYTES

Functions

crypto_onetimeauth

syntax: string auth = luasodium.crypto_onetimeauth(string message, string key)

Generates a new authenticator for a given message and key.

crypto_onetimeauth_verify

syntax: boolean success = luasodium.crypto_onetimeauth_verify(string auth, string message, string key)

Verifies that a given auth is valid for a given message and key.

Returns true on success.

crypto_onetimeauth_keygen

syntax: string key = luasodium.crypto_onetimeauth_keygen()

Generates a new, random key.

crypto_onetimeauth_init

syntax: userdata state = luasodium.crypto_onetimeauth_init(string key)

Creates a new state userdata for computing a onetimeauth in chunks, with key.

Returned userdata has a metatable allowing object-oriented usage - methods are available for:

  • crypto_onetimeauth_update(state,message) as state:update(message)
  • crypto_onetimeauth_final(state) as state:final()

crypto_onetimeauth_update

syntax: boolean success = crypto_onetimeauth_update(userdata state, string message)

Updates state with the contents of message.

crypto_onetimeauth_final

syntax: string auth = crypto_onetimeauth_final(userdata state)

Returns the final authenticator for a given state.