简体   繁体   中英

What is the testbench process for hashing algorithms?

Suppose that I wrote an implementation of a standard algorithm such as an MD* or a SHA*: How I know that it's correct ? Different implementations of the same algorithm must produce the same digest ?

The reference documents themselves contain a small number of example cases, which can be used. (The hash of "abc" is in all of the reference documents, for example.) In addition, Aaron Gifford has made a number of test cases available at http://www.adg.us/computers/sha.html . In particular, he has tests for some of the border cases (where the text is exactly the length of a block, or one less, and a couple of other special lengths. If your implementation calculates the correct value for all of these, there is a good chance that it is correct.

Yes this is the case. However some hash algorithms come with variations/settings, so you will need to match those if that is the case.

A good example is how an MD5 is often given to allow you to verify your download was correct. In order for this to work the MD5 hash implementation needs to produce the same result for all implementations.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM