tuweni / org.apache.tuweni.crypto.sodium / Auth

Auth

class Auth (source)

Secret-key authentication.

These operations computes an authentication tag for a message and a secret key, and provides a way to verify that a given tag is valid for a given message and a key.

The function computing the tag is deterministic: the same (message, key) tuple will always produce the same output.

However, even if the message is public, knowing the key is required in order to be able to compute a valid tag. Therefore, the key should remain confidential. The tag, however, can be public.

A typical use case is:

This operation does not encrypt the message. It only computes and verifies an authentication tag.

Types

Key

class Key : Destroyable

An Auth key.

Functions

auth

static fun auth(input: Bytes, key: Key): Bytes
static fun auth(input: ByteArray, key: Key): ByteArray

Create an authentication tag for a given input.

verify

static fun verify(tag: Bytes, input: Bytes, key: Key): Boolean
static fun verify(tag: ByteArray, input: ByteArray, key: Key): Boolean

Verify an input using an authentication tag.