pegasus/authentication

Types

A cryptographic key used for authentication

This is just a wrapper around a BitArray to provide type safety

pub type HashKey {
  HashKey(data: BitArray)
}

Constructors

  • HashKey(data: BitArray)

Functions

pub fn authenticate(
  data: BitArray,
  key: HashKey,
) -> Result(BitArray, Error)

Create an authentication tag for data using the provided key

pub fn key_from_bitarray(key_data: BitArray) -> HashKey

Create a new authentication key from raw bytes

Note: For proper security, keys should be randomly generated

pub fn verify(
  data: BitArray,
  key: HashKey,
  expected_tag: BitArray,
) -> Result(Nil, Error)

Verify that data matches an expected authentication tag using the same key

Search Document