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  * 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 _RIPEMD128_H
30 #define _RIPEMD128_H
31 
32 //Dependencies
33 #include "core/crypto.h"
34 
35 //RIPEMD-128 block size
36 #define RIPEMD128_BLOCK_SIZE 64
37 //RIPEMD-128 digest size
38 #define RIPEMD128_DIGEST_SIZE 16
39 //RIPEMD-128 algorithm object identifier
40 #define RIPEMD128_OID ripemd128Oid
41 //Common interface for hash algorithms
42 #define RIPEMD128_HASH_ALGO (&ripemd128HashAlgo)
43 
44 //C++ guard
45 #ifdef __cplusplus
46  extern "C" {
47 #endif
48 
49 
50 /**
51  * @brief RIPEMD-128 algorithm context
52  **/
53 
54 typedef struct
55 {
56  union
57  {
58  uint32_t h[4];
59  uint8_t digest[16];
60  };
61  union
62  {
63  uint32_t x[16];
64  uint8_t buffer[64];
65  };
66  size_t size;
67  uint64_t totalSize;
69 
70 
71 //RIPEMD-128 related constants
72 extern const uint8_t ripemd128Oid[5];
73 extern const HashAlgo ripemd128HashAlgo;
74 
75 //RIPEMD-128 related functions
76 error_t ripemd128Compute(const void *data, size_t length, uint8_t *digest);
77 void ripemd128Init(Ripemd128Context *context);
78 void ripemd128Update(Ripemd128Context *context, const void *data, size_t length);
79 void ripemd128Final(Ripemd128Context *context, uint8_t *digest);
81 
82 //C++ guard
83 #ifdef __cplusplus
84  }
85 #endif
86 
87 #endif
error_t ripemd128Compute(const void *data, size_t length, uint8_t *digest)
Digest a message using RIPEMD-128.
Definition: ripemd128.c:91
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:140
void ripemd128ProcessBlock(Ripemd128Context *context)
Process message in 16-word blocks.
Definition: ripemd128.c:219
General definitions for cryptographic algorithms.
const HashAlgo ripemd128HashAlgo
Definition: ripemd128.c:68
void ripemd128Final(Ripemd128Context *context, uint8_t *digest)
Finish the RIPEMD-128 message digest.
Definition: ripemd128.c:179
const uint8_t ripemd128Oid[5]
Definition: ripemd128.c:65
void ripemd128Init(Ripemd128Context *context)
Initialize RIPEMD-128 message digest context.
Definition: ripemd128.c:118
error_t
Error codes.
Definition: error.h:40
uint8_t data[]
Definition: dtls_misc.h:167
RIPEMD-128 algorithm context.
Definition: ripemd128.h:54
Common interface for hash algorithms.
Definition: crypto.h:1054
uint8_t length
Definition: dtls_misc.h:140
uint8_t h
Definition: ndp.h:297
uint64_t totalSize
Definition: ripemd128.h:67