| 1 |
RIPEMD-160 |
| 2 |
========== |
| 3 |
|
| 4 |
RIPEMD-160_ produces the 160 bit digest of a message. |
| 5 |
For example:: |
| 6 |
|
| 7 |
>>> from Crypto.Hash import RIPEMD160 |
| 8 |
>>> |
| 9 |
>>> h = RIPEMD160.new() |
| 10 |
>>> h.update(b'Hello') |
| 11 |
>>> print h.hexdigest() |
| 12 |
|
| 13 |
RIPEMD-160 stands for RACE Integrity Primitives Evaluation Message Digest |
| 14 |
with a 160 bit digest. It was invented by Dobbertin, Bosselaers, and Preneel. |
| 15 |
|
| 16 |
.. warning:: |
| 17 |
This algorithm is not considered secure. Do not use it for new designs. |
| 18 |
|
| 19 |
.. warning:: |
| 20 |
RIPEMD-160 is vulnerable to `length-extension attacks <https://crypto.stackexchange.com/questions/3978/understanding-the-length-extension-attack>`_, |
| 21 |
which are relevant if you are computing the hash of a secret message. |
| 22 |
|
| 23 |
For instance, let's say you were planning to build a cheap MAC by concatenating a secret *key* to |
| 24 |
a public message *m* (bad idea!): |
| 25 |
|
| 26 |
.. math:: |
| 27 |
h = \text{RIPEMD-160}(m || k) |
| 28 |
|
| 29 |
By only knowing the digest *h* and the length of *m* and *k*, the attacker can easily compute a second digest *h'*: |
| 30 |
|
| 31 |
.. math:: |
| 32 |
h' = \text{RIPEMD-160}(m || p || z) |
| 33 |
|
| 34 |
where *p* is a well-known bit string and the attacker can pick a bit string *z* at will. |
| 35 |
|
| 36 |
.. _RIPEMD-160: http://homes.esat.kuleuven.be/~bosselae/ripemd160.html |
| 37 |
|
| 38 |
.. automodule:: Crypto.Hash.RIPEMD160 |
| 39 |
:members: |