blake2b.c File Reference

BLAKE2 cryptographic hash and MAC (BLAKE2b variant) More...

#include "core/crypto.h"
#include "hash/blake2b.h"

Go to the source code of this file.

Macros

#define TRACE_LEVEL   CRYPTO_TRACE_LEVEL
 
#define G(a, b, c, d, x, y)
 

Functions

error_t blake2bCompute (const void *key, size_t keyLen, const void *data, size_t dataLen, uint8_t *digest, size_t digestLen)
 Digest a message using BLAKE2b. More...
 
error_t blake2bInit (Blake2bContext *context, const void *key, size_t keyLen, size_t digestLen)
 Initialize BLAKE2b message digest context. More...
 
void blake2bUpdate (Blake2bContext *context, const void *data, size_t length)
 Update the BLAKE2b context with a portion of the message being hashed. More...
 
void blake2bFinal (Blake2bContext *context, uint8_t *digest)
 Finish the BLAKE2b message digest. More...
 
void blake2bProcessBlock (Blake2bContext *context, bool_t last)
 Compression function F. More...
 

Detailed Description

BLAKE2 cryptographic hash and MAC (BLAKE2b variant)

License

Copyright (C) 2010-2018 Oryx Embedded SARL. All rights reserved.

This file is part of CycloneCrypto Open.

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

Description

BLAKE2b is cryptographic hash function optimized for 64-bit platforms that produces digests of any size between 1 and 64 bytes. Refer to RFC 7693 for more details

Author
Oryx Embedded SARL (www.oryx-embedded.com)
Version
1.9.0

Definition in file blake2b.c.

Macro Definition Documentation

◆ G

#define G (   a,
  b,
  c,
  d,
  x,
 
)
Value:
{ \
a += b + x; \
d ^= a; \
d = ROR64(d, 32); \
c += d; \
b ^= c; \
b = ROR64(b, 24); \
a += b + y; \
d ^= a; \
d = ROR64(d, 16); \
c += d; \
b ^= c; \
b = ROR64(b, 63); \
}
uint8_t c
Definition: ndp.h:510
uint8_t a
Definition: ndp.h:407
#define ROR64(a, n)
Definition: crypto.h:856
uint8_t b[6]
Definition: dtls_misc.h:130

Definition at line 46 of file blake2b.c.

◆ TRACE_LEVEL

#define TRACE_LEVEL   CRYPTO_TRACE_LEVEL

Definition at line 36 of file blake2b.c.

Function Documentation

◆ blake2bCompute()

error_t blake2bCompute ( const void *  key,
size_t  keyLen,
const void *  data,
size_t  dataLen,
uint8_t *  digest,
size_t  digestLen 
)

Digest a message using BLAKE2b.

Parameters
[in]keyPointer to the key
[in]keyLenLength of the key
[in]dataPointer to the message being hashed
[in]dataLenLength of the message
[out]digestPointer to the calculated digest
[in]digestLenExpected length of the digest
Returns
Error code

Definition at line 98 of file blake2b.c.

◆ blake2bFinal()

void blake2bFinal ( Blake2bContext context,
uint8_t *  digest 
)

Finish the BLAKE2b message digest.

Parameters
[in]contextPointer to the BLAKE2b context
[out]digestCalculated digest (optional parameter)

Definition at line 243 of file blake2b.c.

◆ blake2bInit()

error_t blake2bInit ( Blake2bContext context,
const void *  key,
size_t  keyLen,
size_t  digestLen 
)

Initialize BLAKE2b message digest context.

Parameters
[in]contextPointer to the BLAKE2b context to initialize
[in]keyPointer to the key
[in]keyLenLength of the key
[in]digestLenExpected length of the digest
Returns
Error code

Definition at line 145 of file blake2b.c.

◆ blake2bProcessBlock()

void blake2bProcessBlock ( Blake2bContext context,
bool_t  last 
)

Compression function F.

Parameters
[in]contextPointer to the BLAKE2b context
[in]lastFlag indicating the last block

Definition at line 276 of file blake2b.c.

◆ blake2bUpdate()

void blake2bUpdate ( Blake2bContext context,
const void *  data,
size_t  length 
)

Update the BLAKE2b context with a portion of the message being hashed.

Parameters
[in]contextPointer to the BLAKE2b context
[in]dataPointer to the buffer being hashed
[in]lengthLength of the buffer

Definition at line 205 of file blake2b.c.