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-2024 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.4.4
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  union
53  {
54  uint32_t h[8];
55  uint8_t digest[32];
56  };
57  union
58  {
59  uint32_t m[16];
60  uint8_t buffer[64];
61  };
62  size_t size;
63  uint32_t totalSize[2];
64  size_t digestSize;
66 
67 
68 //BLAKE2s related functions
69 error_t blake2sCompute(const void *key, size_t keyLen, const void *data,
70  size_t dataLen, uint8_t *digest, size_t digestLen);
71 
72 error_t blake2sInit(Blake2sContext *context, const void *key,
73  size_t keyLen, size_t digestLen);
74 
75 void blake2sUpdate(Blake2sContext *context, const void *data, size_t length);
76 void blake2sFinal(Blake2sContext *context, uint8_t *digest);
78 
79 //C++ guard
80 #ifdef __cplusplus
81 }
82 #endif
83 
84 #endif
int bool_t
Definition: compiler_port.h:53
uint8_t data[]
Definition: ethernet.h:222
uint16_t last
Definition: ipv4_frag.h:105
size_t digestSize
Definition: blake2s.h:64
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:62
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:292
BLAKE2s algorithm context.
Definition: blake2s.h:51
uint8_t length
Definition: tcp.h:368
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