ripemd160.c
Go to the documentation of this file.
1 /**
2  * @file ripemd160.c
3  * @brief RIPEMD-160 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.0
29  **/
30 
31 //Switch to the appropriate trace level
32 #define TRACE_LEVEL CRYPTO_TRACE_LEVEL
33 
34 //Dependencies
35 #include "core/crypto.h"
36 #include "hash/ripemd160.h"
37 
38 //Check crypto library configuration
39 #if (RIPEMD160_SUPPORT == ENABLED)
40 
41 //RIPEMD-160 auxiliary functions
42 #define F(x, y, z) ((x) ^ (y) ^ (z))
43 #define G(x, y, z) (((x) & (y)) | (~(x) & (z)))
44 #define H(x, y, z) (((x) | ~(y)) ^ (z))
45 #define I(x, y, z) (((x) & (z)) | ((y) & ~(z)))
46 #define J(x, y, z) ((x) ^ ((y) | ~(z)))
47 
48 #define FF(a, b, c, d, e, x, s) a += F(b, c, d) + (x), a = ROL32(a, s) + (e), c = ROL32(c, 10)
49 #define GG(a, b, c, d, e, x, s) a += G(b, c, d) + (x) + 0x5A827999, a = ROL32(a, s) + (e), c = ROL32(c, 10)
50 #define HH(a, b, c, d, e, x, s) a += H(b, c, d) + (x) + 0x6ED9EBA1, a = ROL32(a, s) + (e), c = ROL32(c, 10)
51 #define II(a, b, c, d, e, x, s) a += I(b, c, d) + (x) + 0x8F1BBCDC, a = ROL32(a, s) + (e), c = ROL32(c, 10)
52 #define JJ(a, b, c, d, e, x, s) a += J(b, c, d) + (x) + 0xA953FD4E, a = ROL32(a, s) + (e), c = ROL32(c, 10)
53 
54 #define FFF(a, b, c, d, e, x, s) a += F(b, c, d) + (x), a = ROL32(a, s) + (e), c = ROL32(c, 10)
55 #define GGG(a, b, c, d, e, x, s) a += G(b, c, d) + (x) + 0x7A6D76E9, a = ROL32(a, s) + (e), c = ROL32(c, 10)
56 #define HHH(a, b, c, d, e, x, s) a += H(b, c, d) + (x) + 0x6D703EF3, a = ROL32(a, s) + (e), c = ROL32(c, 10)
57 #define III(a, b, c, d, e, x, s) a += I(b, c, d) + (x) + 0x5C4DD124, a = ROL32(a, s) + (e), c = ROL32(c, 10)
58 #define JJJ(a, b, c, d, e, x, s) a += J(b, c, d) + (x) + 0x50A28BE6, a = ROL32(a, s) + (e), c = ROL32(c, 10)
59 
60 //RIPEMD-160 padding
61 static const uint8_t padding[64] =
62 {
63  0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
64  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
65  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
66  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
67 };
68 
69 //RIPEMD-160 object identifier (1.3.36.3.2.1)
70 const uint8_t RIPEMD160_OID[5] = {0x2B, 0x24, 0x03, 0x02, 0x01};
71 
72 //Common interface for hash algorithms
74 {
75  "RIPEMD-160",
77  sizeof(RIPEMD160_OID),
78  sizeof(Ripemd160Context),
82  FALSE,
87  NULL
88 };
89 
90 
91 /**
92  * @brief Digest a message using RIPEMD-160
93  * @param[in] data Pointer to the message being hashed
94  * @param[in] length Length of the message
95  * @param[out] digest Pointer to the calculated digest
96  * @return Error code
97  **/
98 
99 error_t ripemd160Compute(const void *data, size_t length, uint8_t *digest)
100 {
101 #if (CRYPTO_STATIC_MEM_SUPPORT == DISABLED)
102  Ripemd160Context *context;
103 #else
104  Ripemd160Context context[1];
105 #endif
106 
107  //Check parameters
108  if(data == NULL && length != 0)
110 
111  if(digest == NULL)
113 
114 #if (CRYPTO_STATIC_MEM_SUPPORT == DISABLED)
115  //Allocate a memory buffer to hold the RIPEMD-160 context
116  context = cryptoAllocMem(sizeof(Ripemd160Context));
117  //Failed to allocate memory?
118  if(context == NULL)
119  return ERROR_OUT_OF_MEMORY;
120 #endif
121 
122  //Initialize the RIPEMD-160 context
123  ripemd160Init(context);
124  //Digest the message
125  ripemd160Update(context, data, length);
126  //Finalize the RIPEMD-160 message digest
127  ripemd160Final(context, digest);
128 
129 #if (CRYPTO_STATIC_MEM_SUPPORT == DISABLED)
130  //Free previously allocated memory
131  cryptoFreeMem(context);
132 #endif
133 
134  //Successful operation
135  return NO_ERROR;
136 }
137 
138 
139 /**
140  * @brief Initialize RIPEMD-160 message digest context
141  * @param[in] context Pointer to the RIPEMD-160 context to initialize
142  **/
143 
145 {
146  //Set initial hash value
147  context->h[0] = 0x67452301;
148  context->h[1] = 0xEFCDAB89;
149  context->h[2] = 0x98BADCFE;
150  context->h[3] = 0x10325476;
151  context->h[4] = 0xC3D2E1F0;
152 
153  //Number of bytes in the buffer
154  context->size = 0;
155  //Total length of the message
156  context->totalSize = 0;
157 }
158 
159 
160 /**
161  * @brief Update the RIPEMD-160 context with a portion of the message being hashed
162  * @param[in] context Pointer to the RIPEMD-160 context
163  * @param[in] data Pointer to the buffer being hashed
164  * @param[in] length Length of the buffer
165  **/
166 
167 void ripemd160Update(Ripemd160Context *context, const void *data, size_t length)
168 {
169  size_t n;
170 
171  //Process the incoming data
172  while(length > 0)
173  {
174  //The buffer can hold at most 64 bytes
175  n = MIN(length, 64 - context->size);
176 
177  //Copy the data to the buffer
178  osMemcpy(context->buffer + context->size, data, n);
179 
180  //Update the RIPEMD-160 context
181  context->size += n;
182  context->totalSize += n;
183  //Advance the data pointer
184  data = (uint8_t *) data + n;
185  //Remaining bytes to process
186  length -= n;
187 
188  //Process message in 16-word blocks
189  if(context->size == 64)
190  {
191  //Transform the 16-word block
192  ripemd160ProcessBlock(context);
193  //Empty the buffer
194  context->size = 0;
195  }
196  }
197 }
198 
199 
200 /**
201  * @brief Finish the RIPEMD-160 message digest
202  * @param[in] context Pointer to the RIPEMD-160 context
203  * @param[out] digest Calculated digest (optional parameter)
204  **/
205 
206 void ripemd160Final(Ripemd160Context *context, uint8_t *digest)
207 {
208  uint_t i;
209  size_t paddingSize;
210  uint64_t totalSize;
211 
212  //Length of the original message (before padding)
213  totalSize = context->totalSize * 8;
214 
215  //Pad the message so that its length is congruent to 56 modulo 64
216  if(context->size < 56)
217  {
218  paddingSize = 56 - context->size;
219  }
220  else
221  {
222  paddingSize = 64 + 56 - context->size;
223  }
224 
225  //Append padding
226  ripemd160Update(context, padding, paddingSize);
227 
228  //Append the length of the original message
229  context->x[14] = htole32((uint32_t) totalSize);
230  context->x[15] = htole32((uint32_t) (totalSize >> 32));
231 
232  //Calculate the message digest
233  ripemd160ProcessBlock(context);
234 
235  //Convert from host byte order to little-endian byte order
236  for(i = 0; i < 5; i++)
237  {
238  context->h[i] = htole32(context->h[i]);
239  }
240 
241  //Copy the resulting digest
242  if(digest != NULL)
243  {
244  osMemcpy(digest, context->digest, RIPEMD160_DIGEST_SIZE);
245  }
246 }
247 
248 
249 /**
250  * @brief Process message in 16-word blocks
251  * @param[in] context Pointer to the RIPEMD-160 context
252  **/
253 
255 {
256  uint_t i;
257 
258  //Initialize the working registers
259  uint32_t aa= context->h[0];
260  uint32_t bb = context->h[1];
261  uint32_t cc = context->h[2];
262  uint32_t dd = context->h[3];
263  uint32_t ee = context->h[4];
264  uint32_t aaa = context->h[0];
265  uint32_t bbb = context->h[1];
266  uint32_t ccc = context->h[2];
267  uint32_t ddd = context->h[3];
268  uint32_t eee = context->h[4];
269 
270  //Process message in 16-word blocks
271  uint32_t *x = context->x;
272 
273  //Convert from little-endian byte order to host byte order
274  for(i = 0; i < 16; i++)
275  {
276  x[i] = letoh32(x[i]);
277  }
278 
279  //Round 1
280  FF(aa, bb, cc, dd, ee, x[0], 11);
281  FF(ee, aa, bb, cc, dd, x[1], 14);
282  FF(dd, ee, aa, bb, cc, x[2], 15);
283  FF(cc, dd, ee, aa, bb, x[3], 12);
284  FF(bb, cc, dd, ee, aa, x[4], 5);
285  FF(aa, bb, cc, dd, ee, x[5], 8);
286  FF(ee, aa, bb, cc, dd, x[6], 7);
287  FF(dd, ee, aa, bb, cc, x[7], 9);
288  FF(cc, dd, ee, aa, bb, x[8], 11);
289  FF(bb, cc, dd, ee, aa, x[9], 13);
290  FF(aa, bb, cc, dd, ee, x[10], 14);
291  FF(ee, aa, bb, cc, dd, x[11], 15);
292  FF(dd, ee, aa, bb, cc, x[12], 6);
293  FF(cc, dd, ee, aa, bb, x[13], 7);
294  FF(bb, cc, dd, ee, aa, x[14], 9);
295  FF(aa, bb, cc, dd, ee, x[15], 8);
296 
297  //Round 2
298  GG(ee, aa, bb, cc, dd, x[7], 7);
299  GG(dd, ee, aa, bb, cc, x[4], 6);
300  GG(cc, dd, ee, aa, bb, x[13], 8);
301  GG(bb, cc, dd, ee, aa, x[1], 13);
302  GG(aa, bb, cc, dd, ee, x[10], 11);
303  GG(ee, aa, bb, cc, dd, x[6], 9);
304  GG(dd, ee, aa, bb, cc, x[15], 7);
305  GG(cc, dd, ee, aa, bb, x[3], 15);
306  GG(bb, cc, dd, ee, aa, x[12], 7);
307  GG(aa, bb, cc, dd, ee, x[0], 12);
308  GG(ee, aa, bb, cc, dd, x[9], 15);
309  GG(dd, ee, aa, bb, cc, x[5], 9);
310  GG(cc, dd, ee, aa, bb, x[2], 11);
311  GG(bb, cc, dd, ee, aa, x[14], 7);
312  GG(aa, bb, cc, dd, ee, x[11], 13);
313  GG(ee, aa, bb, cc, dd, x[8], 12);
314 
315  //Round 3
316  HH(dd, ee, aa, bb, cc, x[3], 11);
317  HH(cc, dd, ee, aa, bb, x[10], 13);
318  HH(bb, cc, dd, ee, aa, x[14], 6);
319  HH(aa, bb, cc, dd, ee, x[4], 7);
320  HH(ee, aa, bb, cc, dd, x[9], 14);
321  HH(dd, ee, aa, bb, cc, x[15], 9);
322  HH(cc, dd, ee, aa, bb, x[8], 13);
323  HH(bb, cc, dd, ee, aa, x[1], 15);
324  HH(aa, bb, cc, dd, ee, x[2], 14);
325  HH(ee, aa, bb, cc, dd, x[7], 8);
326  HH(dd, ee, aa, bb, cc, x[0], 13);
327  HH(cc, dd, ee, aa, bb, x[6], 6);
328  HH(bb, cc, dd, ee, aa, x[13], 5);
329  HH(aa, bb, cc, dd, ee, x[11], 12);
330  HH(ee, aa, bb, cc, dd, x[5], 7);
331  HH(dd, ee, aa, bb, cc, x[12], 5);
332 
333  //Round 4
334  II(cc, dd, ee, aa, bb, x[1], 11);
335  II(bb, cc, dd, ee, aa, x[9], 12);
336  II(aa, bb, cc, dd, ee, x[11], 14);
337  II(ee, aa, bb, cc, dd, x[10], 15);
338  II(dd, ee, aa, bb, cc, x[0], 14);
339  II(cc, dd, ee, aa, bb, x[8], 15);
340  II(bb, cc, dd, ee, aa, x[12], 9);
341  II(aa, bb, cc, dd, ee, x[4], 8);
342  II(ee, aa, bb, cc, dd, x[13], 9);
343  II(dd, ee, aa, bb, cc, x[3], 14);
344  II(cc, dd, ee, aa, bb, x[7], 5);
345  II(bb, cc, dd, ee, aa, x[15], 6);
346  II(aa, bb, cc, dd, ee, x[14], 8);
347  II(ee, aa, bb, cc, dd, x[5], 6);
348  II(dd, ee, aa, bb, cc, x[6], 5);
349  II(cc, dd, ee, aa, bb, x[2], 12);
350 
351  //Round 5
352  JJ(bb, cc, dd, ee, aa, x[4], 9);
353  JJ(aa, bb, cc, dd, ee, x[0], 15);
354  JJ(ee, aa, bb, cc, dd, x[5], 5);
355  JJ(dd, ee, aa, bb, cc, x[9], 11);
356  JJ(cc, dd, ee, aa, bb, x[7], 6);
357  JJ(bb, cc, dd, ee, aa, x[12], 8);
358  JJ(aa, bb, cc, dd, ee, x[2], 13);
359  JJ(ee, aa, bb, cc, dd, x[10], 12);
360  JJ(dd, ee, aa, bb, cc, x[14], 5);
361  JJ(cc, dd, ee, aa, bb, x[1], 12);
362  JJ(bb, cc, dd, ee, aa, x[3], 13);
363  JJ(aa, bb, cc, dd, ee, x[8], 14);
364  JJ(ee, aa, bb, cc, dd, x[11], 11);
365  JJ(dd, ee, aa, bb, cc, x[6], 8);
366  JJ(cc, dd, ee, aa, bb, x[15], 5);
367  JJ(bb, cc, dd, ee, aa, x[13], 6);
368 
369  //Parallel round 1
370  JJJ(aaa, bbb, ccc, ddd, eee, x[5], 8);
371  JJJ(eee, aaa, bbb, ccc, ddd, x[14], 9);
372  JJJ(ddd, eee, aaa, bbb, ccc, x[7], 9);
373  JJJ(ccc, ddd, eee, aaa, bbb, x[0], 11);
374  JJJ(bbb, ccc, ddd, eee, aaa, x[9], 13);
375  JJJ(aaa, bbb, ccc, ddd, eee, x[2], 15);
376  JJJ(eee, aaa, bbb, ccc, ddd, x[11], 15);
377  JJJ(ddd, eee, aaa, bbb, ccc, x[4], 5);
378  JJJ(ccc, ddd, eee, aaa, bbb, x[13], 7);
379  JJJ(bbb, ccc, ddd, eee, aaa, x[6], 7);
380  JJJ(aaa, bbb, ccc, ddd, eee, x[15], 8);
381  JJJ(eee, aaa, bbb, ccc, ddd, x[8], 11);
382  JJJ(ddd, eee, aaa, bbb, ccc, x[1], 14);
383  JJJ(ccc, ddd, eee, aaa, bbb, x[10], 14);
384  JJJ(bbb, ccc, ddd, eee, aaa, x[3], 12);
385  JJJ(aaa, bbb, ccc, ddd, eee, x[12], 6);
386 
387  //Parallel round 2
388  III(eee, aaa, bbb, ccc, ddd, x[6], 9);
389  III(ddd, eee, aaa, bbb, ccc, x[11], 13);
390  III(ccc, ddd, eee, aaa, bbb, x[3], 15);
391  III(bbb, ccc, ddd, eee, aaa, x[7], 7);
392  III(aaa, bbb, ccc, ddd, eee, x[0], 12);
393  III(eee, aaa, bbb, ccc, ddd, x[13], 8);
394  III(ddd, eee, aaa, bbb, ccc, x[5], 9);
395  III(ccc, ddd, eee, aaa, bbb, x[10], 11);
396  III(bbb, ccc, ddd, eee, aaa, x[14], 7);
397  III(aaa, bbb, ccc, ddd, eee, x[15], 7);
398  III(eee, aaa, bbb, ccc, ddd, x[8], 12);
399  III(ddd, eee, aaa, bbb, ccc, x[12], 7);
400  III(ccc, ddd, eee, aaa, bbb, x[4], 6);
401  III(bbb, ccc, ddd, eee, aaa, x[9], 15);
402  III(aaa, bbb, ccc, ddd, eee, x[1], 13);
403  III(eee, aaa, bbb, ccc, ddd, x[2], 11);
404 
405  //Parallel round 3
406  HHH(ddd, eee, aaa, bbb, ccc, x[15], 9);
407  HHH(ccc, ddd, eee, aaa, bbb, x[5], 7);
408  HHH(bbb, ccc, ddd, eee, aaa, x[1], 15);
409  HHH(aaa, bbb, ccc, ddd, eee, x[3], 11);
410  HHH(eee, aaa, bbb, ccc, ddd, x[7], 8);
411  HHH(ddd, eee, aaa, bbb, ccc, x[14], 6);
412  HHH(ccc, ddd, eee, aaa, bbb, x[6], 6);
413  HHH(bbb, ccc, ddd, eee, aaa, x[9], 14);
414  HHH(aaa, bbb, ccc, ddd, eee, x[11], 12);
415  HHH(eee, aaa, bbb, ccc, ddd, x[8], 13);
416  HHH(ddd, eee, aaa, bbb, ccc, x[12], 5);
417  HHH(ccc, ddd, eee, aaa, bbb, x[2], 14);
418  HHH(bbb, ccc, ddd, eee, aaa, x[10], 13);
419  HHH(aaa, bbb, ccc, ddd, eee, x[0], 13);
420  HHH(eee, aaa, bbb, ccc, ddd, x[4], 7);
421  HHH(ddd, eee, aaa, bbb, ccc, x[13], 5);
422 
423  //Parallel round 4
424  GGG(ccc, ddd, eee, aaa, bbb, x[8], 15);
425  GGG(bbb, ccc, ddd, eee, aaa, x[6], 5);
426  GGG(aaa, bbb, ccc, ddd, eee, x[4], 8);
427  GGG(eee, aaa, bbb, ccc, ddd, x[1], 11);
428  GGG(ddd, eee, aaa, bbb, ccc, x[3], 14);
429  GGG(ccc, ddd, eee, aaa, bbb, x[11], 14);
430  GGG(bbb, ccc, ddd, eee, aaa, x[15], 6);
431  GGG(aaa, bbb, ccc, ddd, eee, x[0], 14);
432  GGG(eee, aaa, bbb, ccc, ddd, x[5], 6);
433  GGG(ddd, eee, aaa, bbb, ccc, x[12], 9);
434  GGG(ccc, ddd, eee, aaa, bbb, x[2], 12);
435  GGG(bbb, ccc, ddd, eee, aaa, x[13], 9);
436  GGG(aaa, bbb, ccc, ddd, eee, x[9], 12);
437  GGG(eee, aaa, bbb, ccc, ddd, x[7], 5);
438  GGG(ddd, eee, aaa, bbb, ccc, x[10], 15);
439  GGG(ccc, ddd, eee, aaa, bbb, x[14], 8);
440 
441  //Parallel round 5
442  FFF(bbb, ccc, ddd, eee, aaa, x[12], 8);
443  FFF(aaa, bbb, ccc, ddd, eee, x[15], 5);
444  FFF(eee, aaa, bbb, ccc, ddd, x[10], 12);
445  FFF(ddd, eee, aaa, bbb, ccc, x[4], 9);
446  FFF(ccc, ddd, eee, aaa, bbb, x[1], 12);
447  FFF(bbb, ccc, ddd, eee, aaa, x[5], 5);
448  FFF(aaa, bbb, ccc, ddd, eee, x[8], 14);
449  FFF(eee, aaa, bbb, ccc, ddd, x[7], 6);
450  FFF(ddd, eee, aaa, bbb, ccc, x[6], 8);
451  FFF(ccc, ddd, eee, aaa, bbb, x[2], 13);
452  FFF(bbb, ccc, ddd, eee, aaa, x[13], 6);
453  FFF(aaa, bbb, ccc, ddd, eee, x[14], 5);
454  FFF(eee, aaa, bbb, ccc, ddd, x[0], 15);
455  FFF(ddd, eee, aaa, bbb, ccc, x[3], 13);
456  FFF(ccc, ddd, eee, aaa, bbb, x[9], 11);
457  FFF(bbb, ccc, ddd, eee, aaa, x[11], 11);
458 
459  //Combine results
460  ddd = context->h[1] + cc + ddd;
461  context->h[1] = context->h[2] + dd + eee;
462  context->h[2] = context->h[3] + ee + aaa;
463  context->h[3] = context->h[4] + aa + bbb;
464  context->h[4] = context->h[0] + bb + ccc;
465  context->h[0] = ddd;
466 }
467 
468 #endif
unsigned int uint_t
Definition: compiler_port.h:50
#define htole32(value)
Definition: cpu_endian.h:430
#define letoh32(value)
Definition: cpu_endian.h:438
General definitions for cryptographic algorithms.
error_t(* HashAlgoCompute)(const void *data, size_t length, uint8_t *digest)
Definition: crypto.h:956
void(* HashAlgoFinal)(void *context, uint8_t *digest)
Definition: crypto.h:963
void(* HashAlgoUpdate)(void *context, const void *data, size_t length)
Definition: crypto.h:961
#define cryptoAllocMem(size)
Definition: crypto.h:765
#define cryptoFreeMem(p)
Definition: crypto.h:770
void(* HashAlgoInit)(void *context)
Definition: crypto.h:959
uint8_t n
uint8_t aa
Definition: dns_common.h:187
error_t
Error codes.
Definition: error.h:43
@ NO_ERROR
Success.
Definition: error.h:44
@ ERROR_OUT_OF_MEMORY
Definition: error.h:63
@ ERROR_INVALID_PARAMETER
Invalid parameter.
Definition: error.h:47
uint8_t data[]
Definition: ethernet.h:222
uint8_t x
Definition: lldp_ext_med.h:211
#define osMemcpy(dest, src, length)
Definition: os_port.h:141
#define MIN(a, b)
Definition: os_port.h:63
#define FALSE
Definition: os_port.h:46
#define GG(a, b, c, d, e, x, s)
Definition: ripemd160.c:49
#define JJJ(a, b, c, d, e, x, s)
Definition: ripemd160.c:58
#define III(a, b, c, d, e, x, s)
Definition: ripemd160.c:57
#define JJ(a, b, c, d, e, x, s)
Definition: ripemd160.c:52
void ripemd160Init(Ripemd160Context *context)
Initialize RIPEMD-160 message digest context.
Definition: ripemd160.c:144
#define HH(a, b, c, d, e, x, s)
Definition: ripemd160.c:50
#define II(a, b, c, d, e, x, s)
Definition: ripemd160.c:51
const HashAlgo ripemd160HashAlgo
Definition: ripemd160.c:73
#define HHH(a, b, c, d, e, x, s)
Definition: ripemd160.c:56
void ripemd160Update(Ripemd160Context *context, const void *data, size_t length)
Update the RIPEMD-160 context with a portion of the message being hashed.
Definition: ripemd160.c:167
void ripemd160ProcessBlock(Ripemd160Context *context)
Process message in 16-word blocks.
Definition: ripemd160.c:254
error_t ripemd160Compute(const void *data, size_t length, uint8_t *digest)
Digest a message using RIPEMD-160.
Definition: ripemd160.c:99
#define FF(a, b, c, d, e, x, s)
Definition: ripemd160.c:48
#define GGG(a, b, c, d, e, x, s)
Definition: ripemd160.c:55
void ripemd160Final(Ripemd160Context *context, uint8_t *digest)
Finish the RIPEMD-160 message digest.
Definition: ripemd160.c:206
const uint8_t RIPEMD160_OID[5]
Definition: ripemd160.c:70
#define FFF(a, b, c, d, e, x, s)
Definition: ripemd160.c:54
RIPEMD-160 hash function.
#define RIPEMD160_BLOCK_SIZE
Definition: ripemd160.h:38
#define RIPEMD160_DIGEST_SIZE
Definition: ripemd160.h:40
#define RIPEMD160_MIN_PAD_SIZE
Definition: ripemd160.h:42
Common interface for hash algorithms.
Definition: crypto.h:1014
RIPEMD-160 algorithm context.
Definition: ripemd160.h:57
uint8_t digest[20]
Definition: ripemd160.h:61
uint64_t totalSize
Definition: ripemd160.h:69
uint32_t h[5]
Definition: ripemd160.h:60
uint8_t buffer[64]
Definition: ripemd160.h:66
uint32_t x[16]
Definition: ripemd160.h:65
uint8_t length
Definition: tcp.h:368