Monocypher

Boring crypto that simply works

HChacha20

HChacha20 special-purpose hashing.

Synopsis

#include <monocypher.h>

void crypto_chacha20_H(uint8_t       out[32],
                       const uint8_t key[32],
                       const uint8_t in [16]);

Description

crypto_chacha20_H() provides a not-so-cryptographic hash. It may be used for some specific purposes, such as X25519 key derivation, or XChacha20 initialisation. If in doubt, do not use directly. Use Blake2b instead.

The arguments are:

Return values

This function returns nothing.

Examples

Simple hash:

const uint8_t key[32]; /* Must have enough entropy           */
const uint8_t in [16]; /* Does not have to be random         */
uint8_t       out[32]; /* Will be random iff the above holds */
crypto_chacha20_H(out, key, in);
/* Wipe secrets if they are no longer needed */
crypto_wipe(key, 32);
crypto_wipe(in , 16);

Standards

This function implements HChacha20. HChacha20 derives from Chacha20 the same way HSalsa20 derives from Salsa20.

Caveats

This is not a general-purpose cryptographic hash function.