CRYPTO-C v1.1.3
C/C++ Documentation
blake2b.h File Reference

Go to the source code of this file.

#include "utildev.h"

Detailed Description

Blake2b hash function support.

This file is based on Dr. Markku-Juhani O. Saarinen's "somewhat smaller" BLAKE2 implemetation...

https://github.com/mjosaarinen/blake2_mjosref

... which was released into the Public Domain under the Creative Commons Zero v1.0 Universal license.

Macros

#define BLAKE2BLEN256   32
 256-bit Blake2b digest length in bytes
 
#define BLAKE2BLEN384   48
 384-bit Blake2b digest length in bytes
 
#define BLAKE2BLEN512   64
 512-bit Blake2b digest length in bytes
 

Data Structures

struct  BLAKE2B_CTX
 

Functions

int blake2b_init (BLAKE2B_CTX *ctx, const void *key, int keylen, int outlen)
 Initialize a Blake2b context with optional key. More...
 
void blake2b_update (BLAKE2B_CTX *ctx, const void *in, size_t inlen)
 Add inlen bytes from in to a Blake2b context for hashing. More...
 
void blake2b_final (BLAKE2B_CTX *ctx, void *out)
 Finalize a Blake2b message digest. More...
 
int blake2b (const void *in, size_t inlen, const void *key, int keylen, void *out, int outlen)
 Convenient all-in-one Blake2b computation. More...
 

Function Documentation

◆ blake2b()

int blake2b ( const void *  in,
size_t  inlen,
const void *  key,
int  keylen,
void *  out,
int  outlen 
)

Convenient all-in-one Blake2b computation.

Performs blake2b_init(), blake2b_update() and blake2b_final(), and places the resulting hash in out.

Parameters
inPointer to data to hash
inlenLength of in data, in bytes
keyPointer to optional "key" input
keylenLength of optional key input, in bytes
outPointer to location to place the message digest
outlenLength* of desired message digest, in bytes
*compatible message digest lengths are 32, 48 and 64

◆ blake2b_final()

void blake2b_final ( BLAKE2B_CTX ctx,
void *  out 
)

Finalize a Blake2b message digest.

Generate the Blake2b message digest and place in out.

Parameters
ctxPointer to Blake2b context
outPointer to location to place the message digest

◆ blake2b_init()

int blake2b_init ( BLAKE2B_CTX ctx,
const void *  key,
int  keylen,
int  outlen 
)

Initialize a Blake2b context with optional key.

To hash without a key, specify NULL and 0 for key and keylen, respectively.

Parameters
ctxPointer to Blake2b context
keyPointer to optional "key" input
keylenLength of optional key input, in bytes
outlenByte length of desired digest
Returns
0 on success, else if initialization fails (-1).
Note
Blake2b initialization can fail if keylen is greater than 64 or outlen is not a supported digest length. Supported lengths include: 32 (256-bits), 48 (384-bits) or 64 (512-bits).

◆ blake2b_update()

void blake2b_update ( BLAKE2B_CTX ctx,
const void *  in,
size_t  inlen 
)

Add inlen bytes from in to a Blake2b context for hashing.

Parameters
ctxPointer to Blake2b context
inPointer to data to hash
inlenLength of in data, in bytes