One-Time Authentication
Bindings for the crypto_onetimeauth API. See the libsodium crypto_onetimeauth docs for more information.
Constants
Buffer lengths (integer)
crypto_onetimeauth_BYTEScrypto_onetimeauth_KEYBYTEScrypto_onetimeauth_STATEBYTES
String constants (string)
crypto_onetimeauth_PRIMITIVE
crypto_onetimeauth
sodium.crypto_onetimeauth(out, in, k)
Creates an authentication token based on a onetime k.
outshould be abufferof lengthcrypto_onetimauth_BYTESinshould be abufferof any sizekshould be abufferof lengthcrypto_onetimeauth_KEYBYTES
The generated token is stored in out.
crypto_onetimeauth_verify
var bool = sodium.crypto_onetimeauth_verify(out, in, k)
Verifies a token.
outshould be abufferof lengthcrypto_onetimeauth_BYTESinshould be abufferof any sizekshould be abufferof lengthcrypto_onetimeauth_KEYBYTES
Returns true if the token could be verified. Otherwise false.
Instance API
crypto_onetimeauth_instance
var instance = sodium.crypto_onetimeauth_instance(k)
Creates an instance that creates a token from a onetime k and a stream of in data.
kshould be abufferof lengthcrypto_onetimeauth_KEYBYTES
instance.update
instance.update(in)
Updates the instance with a new piece of data.
inshould be abufferof any length
instance.final
instance.final(out)
Finalizes the instance.
outshould be abufferof lengthcrypto_onetimeauth_BYTES
The generated hash is stored in out.
Stateful API
Replaces the above instance implementation in the N-API release
crypto_onetimeauth_init
var state = Buffer.alloc(crypto_onetimeauth_STATEBYTES)
sodium.crypto_onetimeauth_init(state, k)
Initialise a new auth state with a k.
statemust be a buffer of lengthcrypto_onetimeauth_STATEBYTESbyteskmust be a buffer of lengthcrypto_onetimeauth_STATEBYTESbytes
crypto_onetimeauth_update
sodium.crypto_onetimeauth_update(state, in)
Update a hash state with a given in.
statemust be a buffer of lengthcrypto_onetimeauth_STATEBYTESbytesinshould be a abufferof any length
crypto_onetimeauth_final(state, out)
sodium.crypto_onetimeauth_final(state, out)
Finalize a given hash state and write the digest to out buffer
statemust be a buffer of lengthcrypto_onetimeauth_STATEBYTESbytesoutmust be abufferof lengthcrypto_onetimeauth_BYTESbytes
