sodium-native

sodium-native

  • Get Started
  • API
  • Github

›API

Get Started

  • Introduction
  • Projects using sodium-native

API

  • Compatibility
  • API
  • Memory Protection
  • Generating Random Data
  • Helpers
  • Padding
  • Signing
  • Generic Hashing
  • Public/Secret Key Box Encryption
  • Sealed Box Encryption
  • Secret Key Box Encryption
  • AEAD (Authenticated Encryption with Additional Data)
  • Non-Authenticated Streaming Encryption
  • Authentication
  • Stream Encryption
  • One-Time Authentication
  • Password Hashing
  • Key Exchange
  • Diffie-Hellman
  • Finite Field Arithmetic
  • Short Hashes
  • Key Derivation
  • SHA
  • License

One-Time Authentication

Bindings for the crypto_onetimeauth API. See the libsodium crypto_onetimeauth docs for more information.

Constants

Buffer lengths (integer)

  • crypto_onetimeauth_BYTES
  • crypto_onetimeauth_KEYBYTES
  • crypto_onetimeauth_STATEBYTES

String constants (string)

  • crypto_onetimeauth_PRIMITIVE

crypto_onetimeauth

sodium-native

sodium.crypto_onetimeauth(out, in, k)

Creates an authentication token based on a onetime k.

  • out should be a buffer of length crypto_onetimauth_BYTES
  • in should be a buffer of any size
  • k should be a buffer of length crypto_onetimeauth_KEYBYTES

The generated token is stored in out.


crypto_onetimeauth_verify

sodium-native

var bool = sodium.crypto_onetimeauth_verify(out, in, k)

Verifies a token.

  • out should be a buffer of length crypto_onetimeauth_BYTES
  • in should be a buffer of any size
  • k should be a buffer of length crypto_onetimeauth_KEYBYTES

Returns true if the token could be verified. Otherwise false.


Instance API

crypto_onetimeauth_instance

sodium-native

var instance = sodium.crypto_onetimeauth_instance(k)

Creates an instance that creates a token from a onetime k and a stream of in data.

  • k should be a buffer of length crypto_onetimeauth_KEYBYTES

instance.update

instance.update(in)

Updates the instance with a new piece of data.

  • in should be a buffer of any length

instance.final

instance.final(out)

Finalizes the instance.

  • out should be a buffer of length crypto_onetimeauth_BYTES

The generated hash is stored in out.

Stateful API

Replaces the above instance implementation in the N-API release

crypto_onetimeauth_init

sodium-native

var state = Buffer.alloc(crypto_onetimeauth_STATEBYTES)

sodium.crypto_onetimeauth_init(state, k)

Initialise a new auth state with a k.

  • state must be a buffer of length crypto_onetimeauth_STATEBYTES bytes
  • k must be a buffer of length crypto_onetimeauth_STATEBYTES bytes

crypto_onetimeauth_update

sodium-native

sodium.crypto_onetimeauth_update(state, in)

Update a hash state with a given in.

  • state must be a buffer of length crypto_onetimeauth_STATEBYTES bytes
  • in should be a a buffer of any length

crypto_onetimeauth_final(state, out)

sodium-native

sodium.crypto_onetimeauth_final(state, out)

Finalize a given hash state and write the digest to out buffer

  • state must be a buffer of length crypto_onetimeauth_STATEBYTES bytes
  • out must be a buffer of length crypto_onetimeauth_BYTES bytes
← Stream EncryptionPassword Hashing →
  • Constants
  • crypto_onetimeauth
  • crypto_onetimeauth_verify
  • Instance API
  • crypto_onetimeauth_instance
  • instance.update
  • instance.final
  • Stateful API
  • crypto_onetimeauth_init
  • crypto_onetimeauth_update
  • crypto_onetimeauth_final(state, out)
Docs
Get StartedAPI
Community
LibsodiumHyperdivisionHyperdivision on Twitter
More
GitHubStar
Copyright © 2020 Hyperdivision