ripemd128.h
Go to the documentation of this file.
1 /**
2  * @file ripemd128.h
3  * @brief RIPEMD-128 hash function
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 _RIPEMD128_H
32 #define _RIPEMD128_H
33 
34 //Dependencies
35 #include "core/crypto.h"
36 
37 //RIPEMD-128 block size
38 #define RIPEMD128_BLOCK_SIZE 64
39 //RIPEMD-128 digest size
40 #define RIPEMD128_DIGEST_SIZE 16
41 //Minimum length of the padding string
42 #define RIPEMD128_MIN_PAD_SIZE 9
43 //Common interface for hash algorithms
44 #define RIPEMD128_HASH_ALGO (&ripemd128HashAlgo)
45 
46 //C++ guard
47 #ifdef __cplusplus
48 extern "C" {
49 #endif
50 
51 
52 /**
53  * @brief RIPEMD-128 algorithm context
54  **/
55 
56 typedef struct
57 {
58  union
59  {
60  uint32_t h[4];
61  uint8_t digest[16];
62  };
63  union
64  {
65  uint32_t x[16];
66  uint8_t buffer[64];
67  };
68  size_t size;
69  uint64_t totalSize;
71 
72 
73 //RIPEMD-128 related constants
74 extern const uint8_t RIPEMD128_OID[5];
75 extern const HashAlgo ripemd128HashAlgo;
76 
77 //RIPEMD-128 related functions
78 error_t ripemd128Compute(const void *data, size_t length, uint8_t *digest);
79 void ripemd128Init(Ripemd128Context *context);
80 void ripemd128Update(Ripemd128Context *context, const void *data, size_t length);
81 void ripemd128Final(Ripemd128Context *context, uint8_t *digest);
83 
84 //C++ guard
85 #ifdef __cplusplus
86 }
87 #endif
88 
89 #endif
uint8_t x
Definition: lldp_ext_med.h:211
uint8_t data[]
Definition: ethernet.h:222
void ripemd128ProcessBlock(Ripemd128Context *context)
Process message in 16-word blocks.
Definition: ripemd128.c:250
uint8_t h
Definition: ndp.h:302
void ripemd128Final(Ripemd128Context *context, uint8_t *digest)
Finish the RIPEMD-128 message digest.
Definition: ripemd128.c:202
error_t
Error codes.
Definition: error.h:43
General definitions for cryptographic algorithms.
const uint8_t RIPEMD128_OID[5]
Definition: ripemd128.c:67
uint8_t length
Definition: tcp.h:368
void ripemd128Init(Ripemd128Context *context)
Initialize RIPEMD-128 message digest context.
Definition: ripemd128.c:141
uint64_t totalSize
Definition: ripemd128.h:69
void ripemd128Update(Ripemd128Context *context, const void *data, size_t length)
Update the RIPEMD-128 context with a portion of the message being hashed.
Definition: ripemd128.c:163
const HashAlgo ripemd128HashAlgo
Definition: ripemd128.c:70
error_t ripemd128Compute(const void *data, size_t length, uint8_t *digest)
Digest a message using RIPEMD-128.
Definition: ripemd128.c:96
RIPEMD-128 algorithm context.
Definition: ripemd128.h:57
Common interface for hash algorithms.
Definition: crypto.h:1046