|
360 |
#if DIGESTLEN != 20 |
360 |
#if DIGESTLEN != 20 |
361 |
#error must have a digest length of 20 for ripe-md-160 |
361 |
#error must have a digest length of 20 for ripe-md-160 |
362 |
#endif |
362 |
#endif |
363 |
/* loop over the pool */ |
363 |
/* pool -> pool' */ |
364 |
pend = pool + POOLSIZE; |
364 |
pend = pool + POOLSIZE; |
365 |
memcpy(hashbuf, pend - DIGESTLEN, DIGESTLEN ); |
365 |
memcpy(hashbuf, pend - DIGESTLEN, DIGESTLEN ); |
366 |
memcpy(hashbuf+DIGESTLEN, pool, BLOCKLEN-DIGESTLEN); |
366 |
memcpy(hashbuf+DIGESTLEN, pool, BLOCKLEN-DIGESTLEN); |
367 |
rmd160_mixblock( &md, hashbuf); |
367 |
rmd160_mixblock( &md, hashbuf); |
368 |
memcpy(pool, hashbuf, 20 ); |
368 |
memcpy(pool, hashbuf, 20 ); |
369 |
|
369 |
|
|
|
370 |
/* Loop for the remaining iterations. */ |
370 |
p = pool; |
371 |
p = pool; |
371 |
for( n=1; n < POOLBLOCKS; n++ ) { |
372 |
for( n=1; n < POOLBLOCKS; n++ ) { |
372 |
memcpy(hashbuf, p, DIGESTLEN ); |
373 |
if( p + BLOCKLEN < pend ) |
373 |
|
374 |
memcpy(hashbuf, p, BLOCKLEN); |
374 |
p += DIGESTLEN; |
|
|
375 |
if( p+DIGESTLEN+BLOCKLEN < pend ) |
376 |
memcpy(hashbuf+DIGESTLEN, p+DIGESTLEN, BLOCKLEN-DIGESTLEN); |
377 |
else { |
375 |
else { |
378 |
char *pp = p+DIGESTLEN; |
376 |
char *pp = p; |
379 |
for(i=DIGESTLEN; i < BLOCKLEN; i++ ) { |
377 |
for(i=0; i < BLOCKLEN; i++ ) { |
380 |
if( pp >= pend ) |
378 |
if( pp >= pend ) |
381 |
pp = pool; |
379 |
pp = pool; |
382 |
hashbuf[i] = *pp++; |
380 |
hashbuf[i] = *pp++; |
|
384 |
} |
382 |
} |
385 |
|
383 |
|
386 |
rmd160_mixblock( &md, hashbuf); |
384 |
rmd160_mixblock( &md, hashbuf); |
|
|
385 |
p += DIGESTLEN; |
387 |
memcpy(p, hashbuf, 20 ); |
386 |
memcpy(p, hashbuf, 20 ); |
388 |
} |
387 |
} |
389 |
burn_stack (384); /* for the rmd160_mixblock() */ |
388 |
burn_stack (384); /* for the rmd160_mixblock() */ |
390 |
- |
|
|