blake2b.h
Go to the documentation of this file.
1 /**
2  * @file blake2b.h
3  * @brief BLAKE2 cryptographic hash and MAC (BLAKE2b variant)
4  *
5  * @section License
6  *
7  * Copyright (C) 2010-2018 Oryx Embedded SARL. All rights reserved.
8  *
9  * This file is part of CycloneCrypto Open.
10  *
11  * This program is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU General Public License
13  * as published by the Free Software Foundation; either version 2
14  * of the License, or (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, write to the Free Software Foundation,
23  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
24  *
25  * @author Oryx Embedded SARL (www.oryx-embedded.com)
26  * @version 1.9.0
27  **/
28 
29 #ifndef _BLAKE2B_H
30 #define _BLAKE2B_H
31 
32 //Dependencies
33 #include "core/crypto.h"
34 
35 //BLAKE2b block size
36 #define BLAKE2B_BLOCK_SIZE 128
37 
38 //C++ guard
39 #ifdef __cplusplus
40  extern "C" {
41 #endif
42 
43 
44 /**
45  * @brief BLAKE2b algorithm context
46  **/
47 
48 typedef struct
49 {
50  union
51  {
52  uint64_t h[8];
53  uint8_t digest[64];
54  };
55  union
56  {
57  uint64_t m[16];
58  uint8_t buffer[128];
59  };
60  size_t size;
61  uint64_t totalSize[2];
62  size_t digestSize;
64 
65 
66 //BLAKE2b related functions
67 error_t blake2bCompute(const void *key, size_t keyLen, const void *data,
68  size_t dataLen, uint8_t *digest, size_t digestLen);
69 
70 error_t blake2bInit(Blake2bContext *context, const void *key,
71  size_t keyLen, size_t digestLen);
72 
73 void blake2bUpdate(Blake2bContext *context, const void *data, size_t length);
74 void blake2bFinal(Blake2bContext *context, uint8_t *digest);
76 
77 //C++ guard
78 #ifdef __cplusplus
79  }
80 #endif
81 
82 #endif
void blake2bUpdate(Blake2bContext *context, const void *data, size_t length)
Update the BLAKE2b context with a portion of the message being hashed.
Definition: blake2b.c:205
General definitions for cryptographic algorithms.
size_t size
Definition: blake2b.h:60
uint8_t m
Definition: ndp.h:299
error_t blake2bInit(Blake2bContext *context, const void *key, size_t keyLen, size_t digestLen)
Initialize BLAKE2b message digest context.
Definition: blake2b.c:145
uint32_t totalSize
void blake2bFinal(Blake2bContext *context, uint8_t *digest)
Finish the BLAKE2b message digest.
Definition: blake2b.c:243
uint16_t last
Definition: ipv4_frag.h:94
size_t digestSize
Definition: blake2b.h:62
void blake2bProcessBlock(Blake2bContext *context, bool_t last)
Compression function F.
Definition: blake2b.c:276
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.
Definition: blake2b.c:98
error_t
Error codes.
Definition: error.h:40
uint8_t data[]
Definition: dtls_misc.h:167
BLAKE2b algorithm context.
Definition: blake2b.h:48
uint8_t length
Definition: dtls_misc.h:140
uint8_t h
Definition: ndp.h:297
int bool_t
Definition: compiler_port.h:47