Blake2b#

BLAKE2b is optimized for 64-bit platforms and produces digests of any size between 1 and 64 bytes. It also has a build-in keying mechanism so that it can be used to replace HMAC-based constructions.

Example#

The following example shows how to use the one-shot API with the base implementation (32) of BLAKE2b.

#include "Hacl_Hash_Blake2.h"
void
print_hex_ln(size_t bytes_len, uint8_t* bytes)
{
  for (int i = 0; i < bytes_len; ++i) {
    printf("%02x", bytes[i]);
  }

  printf("\n");
}
// Reserve memory for a 64 byte digest, i.e.,
// for a BLAKE2B run with full 512-bit output.
uint32_t output_len = 64;
uint8_t output[64];

// The message we want to hash.
const char* message = "Hello, HACL Packages!";
uint32_t message_len = strlen(message);

// BLAKE2B can be used as an HMAC, i.e., with a key.
// We don't want to use a key here and thus provide a zero-sized key.
uint32_t key_len = 0;
uint8_t* key = 0;

Hacl_Blake2b_32_blake2b(
  output_len, output, message_len, (uint8_t*)message, key_len, key);

print_hex_ln(output_len, output);

API Reference#

One-Shot#

#include "Hacl_Hash_Blake2.h"

Warning

doxygenfunction: Cannot find function “Hacl_Blake2b_32_blake2b” in doxygen xml output for project “HACL Packages” from directory: ../../build/doxygen/xml/

Streaming (without key)#

#include "Hacl_Streaming_Blake2.h"

Warning

doxygentypedef: Cannot find typedef “Hacl_Streaming_Blake2_blake2b_32_state” in doxygen xml output for project “HACL Packages” from directory: ../../build/doxygen/xml/

Warning

doxygenfunction: Cannot find function “Hacl_Streaming_Blake2_blake2b_32_no_key_create_in” in doxygen xml output for project “HACL Packages” from directory: ../../build/doxygen/xml/

Warning

doxygenfunction: Cannot find function “Hacl_Streaming_Blake2_blake2b_32_no_key_init” in doxygen xml output for project “HACL Packages” from directory: ../../build/doxygen/xml/

Warning

doxygenfunction: Cannot find function “Hacl_Streaming_Blake2_blake2b_32_no_key_update” in doxygen xml output for project “HACL Packages” from directory: ../../build/doxygen/xml/

Warning

doxygenfunction: Cannot find function “Hacl_Streaming_Blake2_blake2b_32_no_key_finish” in doxygen xml output for project “HACL Packages” from directory: ../../build/doxygen/xml/

Warning

doxygenfunction: Cannot find function “Hacl_Streaming_Blake2_blake2b_32_no_key_free” in doxygen xml output for project “HACL Packages” from directory: ../../build/doxygen/xml/