libsodium-bindings-0.0.1.1: FFI bindings to libsodium
Copyright(C) Hécate Moonlight
LicenseBSD-3-Clause
MaintainerThe Haskell Cryptography Group
StabilityStable
PortabilityGHC only
Safe HaskellNone
LanguageHaskell2010

LibSodium.Bindings.CryptoAuth

Description

 
Synopsis

Introduction

Compute an authentication tag for a message and a secret key, and 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.

The operations of this module are backed by the HMAC-SHA512-256 algorithm.

Usage

A typical use case is:

  • A prepares a message, adds an authentication tag, sends it to B
  • A doesn't store the message
  • Later on, B sends the message and the authentication tag to A
  • A uses the authentication tag to verify that it created this message.

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

Functions

cryptoAuth Source #

Arguments

:: Ptr CUChar

Buffer that will hold the computed authenticated tag, of size cryptoAuthBytes

-> Ptr CUChar

Buffer that holds the input message

-> CULLong

Length of the message

-> Ptr CUChar

Buffer that holds the secret key of size cryptoAuthKeyBytes

-> IO CInt 

Compute a tag for the provided message and key.

See: crypto_auth()

Since: 0.0.1.0

cryptoAuthVerify Source #

Arguments

:: Ptr CUChar

Buffer that holds the tag

-> Ptr CUChar

Buffer that holds the message

-> CULLong

Length of the message

-> Ptr CUChar

Buffer that holds the secret key of size cryptoAuthKeyBytes

-> IO CInt

Returns -1 if the verification fails, and 0 if it passes.

Verify that the tag is valid for the provided message and secret key.

See: crypto_auth_verify()

Since: 0.0.1.0

cryptoAuthKeygen Source #

Arguments

:: Ptr CUChar

Buffer that holds the secret key of size cryptoAuthKeyBytes

-> IO () 

Create a random secret key of size cryptoAuthKeyBytes

It is equivalent to calling randombytesBuf but improves code clarity and can prevent misuse by ensuring that the provided key length is always be correct.

See: crypto_auth_keygen()

Since: 0.0.1.0

Constants

cryptoAuthKeyBytes :: CSize Source #

Size of the secret key

See: crypto_auth_KEYBYTES

Since: 0.0.1.0

cryptoAuthBytes :: CSize Source #

Size of the tag

See: crypto_auth_BYTES

Since: 0.0.1.0