testing - What tests would you write to verify an MD5 implementation's correctness? -


assume have access "oracle" implementation output trust correct.

the obvious way seems to run set of known plaintext/hash combinations through implementation , see if come out expected. arbitrary number of these cases constructed generating random plaintexts (using static seed keep deterministic) , using oracle find hashes.

the major problem see it's not guaranteed hit possible corner cases. generating more cases reduce likelihood of missing corner cases, how many cases enough?

there's side issue of specifying lengths of these random plaintexts because md5 takes arbitrary-length string input. purposes, don't care long inputs (say, longer 16 bytes), can use fact "special purpose" md5 implementation in answer if makes things simpler or can answer general case if it's same.

if have algorithmic error, it's extremely every hash wrong. hashes unforgiving nature.

since majority of possible errors exposed quickly, won't need many tests. main things cover edge cases:

  • length=0 (input empty)
  • length=1
  • length=16
  • input contains @ least 1 byte value 0
  • repeated patterns of bytes in input (would meaningful edge case md5?)

if pass, perhaps along tests 1 or 2 more representative inputs, pretty confident in algorithm. there aren't many edge cases (unless more familiar algorithm's details can think of more).


Comments

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -