ascon_hash256.h
Go to the documentation of this file.
1 /**
2  * @file ascon_hash256.h
3  * @brief Ascon-Hash256 hash function
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 _ASCON_HASH256_H
32 #define _ASCON_HASH256_H
33 
34 //Dependencies
35 #include "core/crypto.h"
36 #include "lwc/ascon.h"
37 
38 //Application specific context
39 #ifndef ASCON_HASH256_PRIVATE_CONTEXT
40  #define ASCON_HASH256_PRIVATE_CONTEXT
41 #endif
42 
43 //Ascon-Hash256 block size
44 #define ASCON_HASH256_BLOCK_SIZE 8
45 //Ascon-Hash256 digest size
46 #define ASCON_HASH256_DIGEST_SIZE 32
47 //Minimum length of the padding string
48 #define ASCON_HASH256_MIN_PAD_SIZE 0
49 //Common interface for hash algorithms
50 #define ASCON_HASH256_HASH_ALGO (&asconHash256HashAlgo)
51 
52 //C++ guard
53 #ifdef __cplusplus
54 extern "C" {
55 #endif
56 
57 
58 /**
59  * @brief Ascon-Hash256 algorithm context
60  **/
61 
62 typedef struct
63 {
65  uint8_t buffer[8];
66  size_t length;
68 
69 
70 //Ascon-Hash256 related constants
71 extern const uint8_t ASCON_HASH256_OID[1];
72 extern const HashAlgo asconHash256HashAlgo;
73 
74 //Ascon-Hash256 related functions
75 error_t asconHash256Compute(const void *data, size_t length, uint8_t *digest);
77 void asconHash256Update(AsconHash256Context *context, const void *data, size_t length);
78 void asconHash256Final(AsconHash256Context *context, uint8_t *digest);
79 
80 //C++ guard
81 #ifdef __cplusplus
82 }
83 #endif
84 
85 #endif
Ascon state.
Definition: ascon.h:48
uint8_t data[]
Definition: ethernet.h:222
void asconHash256Final(AsconHash256Context *context, uint8_t *digest)
Finish the Ascon-Hash256 message digest.
const HashAlgo asconHash256HashAlgo
Definition: ascon_hash256.c:50
error_t
Error codes.
Definition: error.h:43
Ascon-Based lightweight cryptography.
void asconHash256Init(AsconHash256Context *context)
Initialize Ascon-Hash256 message digest context.
Ascon-Hash256 algorithm context.
Definition: ascon_hash256.h:63
General definitions for cryptographic algorithms.
void asconHash256Update(AsconHash256Context *context, const void *data, size_t length)
Update the Ascon-Hash256 context with a portion of the message being hashed.
uint8_t length
Definition: tcp.h:375
Common interface for hash algorithms.
Definition: crypto.h:1082
error_t asconHash256Compute(const void *data, size_t length, uint8_t *digest)
Digest a message using Ascon-Hash256.
Definition: ascon_hash256.c:76
const uint8_t ASCON_HASH256_OID[1]
Definition: ascon_hash256.c:47