blake2s.h
Go to the documentation of this file.
1 /**
2  * @file blake2s.h
3  * @brief BLAKE2 cryptographic hash and MAC (BLAKE2s variant)
4  *
5  * @section License
6  *
7  * SPDX-License-Identifier: GPL-2.0-or-later
8  *
9  * Copyright (C) 2010-2025 Oryx Embedded SARL. All rights reserved.
10  *
11  * This file is part of CycloneCRYPTO Open.
12  *
13  * This program is free software; you can redistribute it and/or
14  * modify it under the terms of the GNU General Public License
15  * as published by the Free Software Foundation; either version 2
16  * of the License, or (at your option) any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with this program; if not, write to the Free Software Foundation,
25  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
26  *
27  * @author Oryx Embedded SARL (www.oryx-embedded.com)
28  * @version 2.5.0
29  **/
30 
31 #ifndef _BLAKE2S_H
32 #define _BLAKE2S_H
33 
34 //Dependencies
35 #include "core/crypto.h"
36 
37 //BLAKE2s block size
38 #define BLAKE2S_BLOCK_SIZE 64
39 
40 //C++ guard
41 #ifdef __cplusplus
42 extern "C" {
43 #endif
44 
45 
46 /**
47  * @brief BLAKE2s algorithm context
48  **/
49 
50 typedef struct
51 {
52  uint32_t h[8];
53  union
54  {
55  uint32_t m[16];
56  uint8_t buffer[64];
57  };
58  size_t size;
59  uint32_t totalSize[2];
60  size_t digestSize;
62 
63 
64 //BLAKE2s related functions
65 error_t blake2sCompute(const void *key, size_t keyLen, const void *data,
66  size_t dataLen, uint8_t *digest, size_t digestLen);
67 
68 error_t blake2sInit(Blake2sContext *context, const void *key,
69  size_t keyLen, size_t digestLen);
70 
71 void blake2sUpdate(Blake2sContext *context, const void *data, size_t length);
72 void blake2sFinal(Blake2sContext *context, uint8_t *digest);
74 
75 //C++ guard
76 #ifdef __cplusplus
77 }
78 #endif
79 
80 #endif
int bool_t
Definition: compiler_port.h:61
uint8_t data[]
Definition: ethernet.h:222
uint16_t last
Definition: ipv4_frag.h:105
size_t digestSize
Definition: blake2s.h:60
void blake2sUpdate(Blake2sContext *context, const void *data, size_t length)
Update the BLAKE2s context with a portion of the message being hashed.
Definition: blake2s.c:221
uint8_t h
Definition: ndp.h:302
size_t size
Definition: blake2s.h:58
error_t
Error codes.
Definition: error.h:43
void blake2sFinal(Blake2sContext *context, uint8_t *digest)
Finish the BLAKE2s message digest.
Definition: blake2s.c:259
General definitions for cryptographic algorithms.
void blake2sProcessBlock(Blake2sContext *context, bool_t last)
Compression function F.
Definition: blake2s.c:290
BLAKE2s algorithm context.
Definition: blake2s.h:51
uint8_t length
Definition: tcp.h:375
uint32_t dataLen
Definition: sftp_common.h:229
error_t blake2sCompute(const void *key, size_t keyLen, const void *data, size_t dataLen, uint8_t *digest, size_t digestLen)
Digest a message using BLAKE2s.
Definition: blake2s.c:98
uint8_t m
Definition: ndp.h:304
error_t blake2sInit(Blake2sContext *context, const void *key, size_t keyLen, size_t digestLen)
Initialize BLAKE2s message digest context.
Definition: blake2s.c:154