112 RIPEMD160::RIPEMD160()
122 void RIPEMD160::reset()
139 void RIPEMD160::finish()
141 uint32_t t, msb, lsb;
152 if ((lsb += count) < t)
162 ibuffer[count++] = 0x80;
164 ibuffer[count++] = 0;
168 ibuffer[count++] = 0x80;
170 ibuffer[count++] = 0;
172 memset(ibuffer, 0, 56);
176 ibuffer[57] = lsb >> 8;
177 ibuffer[58] = lsb >> 16;
178 ibuffer[59] = lsb >> 24;
180 ibuffer[61] = msb >> 8;
181 ibuffer[62] = msb >> 16;
182 ibuffer[63] = msb >> 24;
187 #if (LIBXCKS_BYTE_ORDER == LIBXCKS_BIG_ENDIAN)
188 #define X(a) do { *p++ = h##a ; *p++ = h##a >> 8; \
189 *p++ = h##a >> 16; *p++ = h##a >> 24; } while(0)
191 #define X(a) do { *(uint32_t*)p = h##a ; p += 4; } while(0)
206 void RIPEMD160::update(
const uint8_t* buf,
size_t len)
220 for (; len && count < 64; len--)
221 ibuffer[count++] = *buf++;
229 uint8_t tmpBuf[
sizeof(uint32_t) * 16];
230 memcpy(tmpBuf, buf,
sizeof(uint32_t) * 16);
238 for(; len && count < 64; len--)
239 ibuffer[count++] = *buf++;
247 void RIPEMD160::transform(uint8_t* data)
250 uint32_t aa,bb,cc,dd,ee,t;
253 #if (LIBXCKS_BYTE_ORDER == LIBXCKS_BIG_ENDIAN)
257 for (i = 0, p1 = data, p2 = (uint8_t*)x; i < 16; i++, p2 += 4)
277 #define K0 0x00000000
278 #define K1 0x5A827999
279 #define K2 0x6ED9EBA1
280 #define K3 0x8F1BBCDC
281 #define K4 0xA953FD4E
282 #define KK0 0x50A28BE6
283 #define KK1 0x5C4DD124
284 #define KK2 0x6D703EF3
285 #define KK3 0x7A6D76E9
286 #define KK4 0x00000000
287 #define F0(x,y,z) ( (x) ^ (y) ^ (z) )
288 #define F1(x,y,z) ( ((x) & (y)) | (~(x) & (z)) )
289 #define F2(x,y,z) ( ((x) | ~(y)) ^ (z) )
290 #define F3(x,y,z) ( ((x) & (z)) | ((y) & ~(z)) )
291 #define F4(x,y,z) ( (x) ^ ((y) | ~(z)) )
292 #define R(a,b,c,d,e,f,k,r,s) do { t = a + f(b,c,d) + k + x[r]; \
303 R(a, b, c, d, e,
F0,
K0, 0, 11);
304 R(e, a, b, c, d,
F0,
K0, 1, 14);
305 R(d, e, a, b, c,
F0,
K0, 2, 15);
306 R(c, d, e, a, b,
F0,
K0, 3, 12);
307 R(b, c, d, e, a,
F0,
K0, 4, 5);
308 R(a, b, c, d, e,
F0,
K0, 5, 8);
309 R(e, a, b, c, d,
F0,
K0, 6, 7);
310 R(d, e, a, b, c,
F0,
K0, 7, 9);
311 R(c, d, e, a, b,
F0,
K0, 8, 11);
312 R(b, c, d, e, a,
F0,
K0, 9, 13);
313 R(a, b, c, d, e,
F0,
K0, 10, 14);
314 R(e, a, b, c, d,
F0,
K0, 11, 15);
315 R(d, e, a, b, c,
F0,
K0, 12, 6);
316 R(c, d, e, a, b,
F0,
K0, 13, 7);
317 R(b, c, d, e, a,
F0,
K0, 14, 9);
318 R(a, b, c, d, e,
F0,
K0, 15, 8);
319 R(e, a, b, c, d,
F1,
K1, 7, 7);
320 R(d, e, a, b, c,
F1,
K1, 4, 6);
321 R(c, d, e, a, b,
F1,
K1, 13, 8);
322 R(b, c, d, e, a,
F1,
K1, 1, 13);
323 R(a, b, c, d, e,
F1,
K1, 10, 11);
324 R(e, a, b, c, d,
F1,
K1, 6, 9);
325 R(d, e, a, b, c,
F1,
K1, 15, 7);
326 R(c, d, e, a, b,
F1,
K1, 3, 15);
327 R(b, c, d, e, a,
F1,
K1, 12, 7);
328 R(a, b, c, d, e,
F1,
K1, 0, 12);
329 R(e, a, b, c, d,
F1,
K1, 9, 15);
330 R(d, e, a, b, c,
F1,
K1, 5, 9);
331 R(c, d, e, a, b,
F1,
K1, 2, 11);
332 R(b, c, d, e, a,
F1,
K1, 14, 7);
333 R(a, b, c, d, e,
F1,
K1, 11, 13);
334 R(e, a, b, c, d,
F1,
K1, 8, 12);
335 R(d, e, a, b, c,
F2,
K2, 3, 11);
336 R(c, d, e, a, b,
F2,
K2, 10, 13);
337 R(b, c, d, e, a,
F2,
K2, 14, 6);
338 R(a, b, c, d, e,
F2,
K2, 4, 7);
339 R(e, a, b, c, d,
F2,
K2, 9, 14);
340 R(d, e, a, b, c,
F2,
K2, 15, 9);
341 R(c, d, e, a, b,
F2,
K2, 8, 13);
342 R(b, c, d, e, a,
F2,
K2, 1, 15);
343 R(a, b, c, d, e,
F2,
K2, 2, 14);
344 R(e, a, b, c, d,
F2,
K2, 7, 8);
345 R(d, e, a, b, c,
F2,
K2, 0, 13);
346 R(c, d, e, a, b,
F2,
K2, 6, 6);
347 R(b, c, d, e, a,
F2,
K2, 13, 5);
348 R(a, b, c, d, e,
F2,
K2, 11, 12);
349 R(e, a, b, c, d,
F2,
K2, 5, 7);
350 R(d, e, a, b, c,
F2,
K2, 12, 5);
351 R(c, d, e, a, b,
F3,
K3, 1, 11);
352 R(b, c, d, e, a,
F3,
K3, 9, 12);
353 R(a, b, c, d, e,
F3,
K3, 11, 14);
354 R(e, a, b, c, d,
F3,
K3, 10, 15);
355 R(d, e, a, b, c,
F3,
K3, 0, 14);
356 R(c, d, e, a, b,
F3,
K3, 8, 15);
357 R(b, c, d, e, a,
F3,
K3, 12, 9);
358 R(a, b, c, d, e,
F3,
K3, 4, 8);
359 R(e, a, b, c, d,
F3,
K3, 13, 9);
360 R(d, e, a, b, c,
F3,
K3, 3, 14);
361 R(c, d, e, a, b,
F3,
K3, 7, 5);
362 R(b, c, d, e, a,
F3,
K3, 15, 6);
363 R(a, b, c, d, e,
F3,
K3, 14, 8);
364 R(e, a, b, c, d,
F3,
K3, 5, 6);
365 R(d, e, a, b, c,
F3,
K3, 6, 5);
366 R(c, d, e, a, b,
F3,
K3, 2, 12);
367 R(b, c, d, e, a,
F4,
K4, 4, 9);
368 R(a, b, c, d, e,
F4,
K4, 0, 15);
369 R(e, a, b, c, d,
F4,
K4, 5, 5);
370 R(d, e, a, b, c,
F4,
K4, 9, 11);
371 R(c, d, e, a, b,
F4,
K4, 7, 6);
372 R(b, c, d, e, a,
F4,
K4, 12, 8);
373 R(a, b, c, d, e,
F4,
K4, 2, 13);
374 R(e, a, b, c, d,
F4,
K4, 10, 12);
375 R(d, e, a, b, c,
F4,
K4, 14, 5);
376 R(c, d, e, a, b,
F4,
K4, 1, 12);
377 R(b, c, d, e, a,
F4,
K4, 3, 13);
378 R(a, b, c, d, e,
F4,
K4, 8, 14);
379 R(e, a, b, c, d,
F4,
K4, 11, 11);
380 R(d, e, a, b, c,
F4,
K4, 6, 8);
381 R(c, d, e, a, b,
F4,
K4, 15, 5);
382 R(b, c, d, e, a,
F4,
K4, 13, 6);
384 aa = a; bb = b; cc = c; dd = d; ee = e;
392 R(a, b, c, d, e,
F4,
KK0, 5, 8);
393 R(e, a, b, c, d,
F4,
KK0, 14, 9);
394 R(d, e, a, b, c,
F4,
KK0, 7, 9);
395 R(c, d, e, a, b,
F4,
KK0, 0, 11);
396 R(b, c, d, e, a,
F4,
KK0, 9, 13);
397 R(a, b, c, d, e,
F4,
KK0, 2, 15);
398 R(e, a, b, c, d,
F4,
KK0, 11, 15);
399 R(d, e, a, b, c,
F4,
KK0, 4, 5);
400 R(c, d, e, a, b,
F4,
KK0, 13, 7);
401 R(b, c, d, e, a,
F4,
KK0, 6, 7);
402 R(a, b, c, d, e,
F4,
KK0, 15, 8);
403 R(e, a, b, c, d,
F4,
KK0, 8, 11);
404 R(d, e, a, b, c,
F4,
KK0, 1, 14);
405 R(c, d, e, a, b,
F4,
KK0, 10, 14);
406 R(b, c, d, e, a,
F4,
KK0, 3, 12);
407 R(a, b, c, d, e,
F4,
KK0, 12, 6);
408 R(e, a, b, c, d,
F3,
KK1, 6, 9);
409 R(d, e, a, b, c,
F3,
KK1, 11, 13);
410 R(c, d, e, a, b,
F3,
KK1, 3, 15);
411 R(b, c, d, e, a,
F3,
KK1, 7, 7);
412 R(a, b, c, d, e,
F3,
KK1, 0, 12);
413 R(e, a, b, c, d,
F3,
KK1, 13, 8);
414 R(d, e, a, b, c,
F3,
KK1, 5, 9);
415 R(c, d, e, a, b,
F3,
KK1, 10, 11);
416 R(b, c, d, e, a,
F3,
KK1, 14, 7);
417 R(a, b, c, d, e,
F3,
KK1, 15, 7);
418 R(e, a, b, c, d,
F3,
KK1, 8, 12);
419 R(d, e, a, b, c,
F3,
KK1, 12, 7);
420 R(c, d, e, a, b,
F3,
KK1, 4, 6);
421 R(b, c, d, e, a,
F3,
KK1, 9, 15);
422 R(a, b, c, d, e,
F3,
KK1, 1, 13);
423 R(e, a, b, c, d,
F3,
KK1, 2, 11);
424 R(d, e, a, b, c,
F2,
KK2, 15, 9);
425 R(c, d, e, a, b,
F2,
KK2, 5, 7);
426 R(b, c, d, e, a,
F2,
KK2, 1, 15);
427 R(a, b, c, d, e,
F2,
KK2, 3, 11);
428 R(e, a, b, c, d,
F2,
KK2, 7, 8);
429 R(d, e, a, b, c,
F2,
KK2, 14, 6);
430 R(c, d, e, a, b,
F2,
KK2, 6, 6);
431 R(b, c, d, e, a,
F2,
KK2, 9, 14);
432 R(a, b, c, d, e,
F2,
KK2, 11, 12);
433 R(e, a, b, c, d,
F2,
KK2, 8, 13);
434 R(d, e, a, b, c,
F2,
KK2, 12, 5);
435 R(c, d, e, a, b,
F2,
KK2, 2, 14);
436 R(b, c, d, e, a,
F2,
KK2, 10, 13);
437 R(a, b, c, d, e,
F2,
KK2, 0, 13);
438 R(e, a, b, c, d,
F2,
KK2, 4, 7);
439 R(d, e, a, b, c,
F2,
KK2, 13, 5);
440 R(c, d, e, a, b,
F1,
KK3, 8, 15);
441 R(b, c, d, e, a,
F1,
KK3, 6, 5);
442 R(a, b, c, d, e,
F1,
KK3, 4, 8);
443 R(e, a, b, c, d,
F1,
KK3, 1, 11);
444 R(d, e, a, b, c,
F1,
KK3, 3, 14);
445 R(c, d, e, a, b,
F1,
KK3, 11, 14);
446 R(b, c, d, e, a,
F1,
KK3, 15, 6);
447 R(a, b, c, d, e,
F1,
KK3, 0, 14);
448 R(e, a, b, c, d,
F1,
KK3, 5, 6);
449 R(d, e, a, b, c,
F1,
KK3, 12, 9);
450 R(c, d, e, a, b,
F1,
KK3, 2, 12);
451 R(b, c, d, e, a,
F1,
KK3, 13, 9);
452 R(a, b, c, d, e,
F1,
KK3, 9, 12);
453 R(e, a, b, c, d,
F1,
KK3, 7, 5);
454 R(d, e, a, b, c,
F1,
KK3, 10, 15);
455 R(c, d, e, a, b,
F1,
KK3, 14, 8);
456 R(b, c, d, e, a,
F0,
KK4, 12, 8);
457 R(a, b, c, d, e,
F0,
KK4, 15, 5);
458 R(e, a, b, c, d,
F0,
KK4, 10, 12);
459 R(d, e, a, b, c,
F0,
KK4, 4, 9);
460 R(c, d, e, a, b,
F0,
KK4, 1, 12);
461 R(b, c, d, e, a,
F0,
KK4, 5, 5);
462 R(a, b, c, d, e,
F0,
KK4, 8, 14);
463 R(e, a, b, c, d,
F0,
KK4, 7, 6);
464 R(d, e, a, b, c,
F0,
KK4, 6, 8);
465 R(c, d, e, a, b,
F0,
KK4, 2, 13);
466 R(b, c, d, e, a,
F0,
KK4, 13, 6);
467 R(a, b, c, d, e,
F0,
KK4, 14, 5);
468 R(e, a, b, c, d,
F0,
KK4, 0, 15);
469 R(d, e, a, b, c,
F0,
KK4, 3, 13);
470 R(c, d, e, a, b,
F0,
KK4, 9, 11);
471 R(b, c, d, e, a,
F0,
KK4, 11, 11);
486 uint8_t* RIPEMD160::getValue(uint8_t* buffer)
const
491 memcpy(buffer, rmd160.
ibuffer, getSize());
Computes the RIPE-MD160 hash from a byte stream.
uint8_t ibuffer[64]
Input buffer.
void finish()
Process the remaining bytes in the internal buffer and the usual prolog according to the standard.
#define K0
Helper value for RIPE-MD160's computing.
#define F1(x, y, z)
Helper value for RIPE-MD160's computing.
#define KK2
Helper value for RIPE-MD160's computing.
#define R(a, b, c, d, e, f, k, r, s)
Helper value for RIPE-MD160's computing.
#define KK1
Helper value for RIPE-MD160's computing.
#define F4(x, y, z)
Helper value for RIPE-MD160's computing.
#define KK4
Helper value for RIPE-MD160's computing.
#define F3(x, y, z)
Helper value for RIPE-MD160's computing.
#define K3
Helper value for RIPE-MD160's computing.
#define K1
Helper value for RIPE-MD160's computing.
#define KK0
Helper value for RIPE-MD160's computing.
#define F0(x, y, z)
Helper value for RIPE-MD160's computing.
#define K4
Helper value for RIPE-MD160's computing.
#define KK3
Helper value for RIPE-MD160's computing.
#define K2
Helper value for RIPE-MD160's computing.
#define X(a)
Helper value for RIPE-MD160's computing.
#define F2(x, y, z)
Helper value for RIPE-MD160's computing.
std::vector< std::string > ArrayString
Array of strings.