in reply to Why applying MD5 hash twice?
One simple solution is to include the length of the message in hash computation: H(K, L, M). This protects the length from being tampered with. MD5 puts the length at the end where it is vulnerable.
Another solution is to validate the message by parsing it. If the parsing find random junk at the end, then you know it has been tampered with. However, the important authentication data is safe.
Finally, you can compute the hash twice. The best construction is: H(K, H(K, M)). The simplest solution is to use Digest::HMAC. This isn't expensive to compute because the second hash is done over a small amount of data.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Why applying MD5 hash twice?
by huguei (Scribe) on Sep 10, 2003 at 20:57 UTC |