0

While generating One Time Password, i used hmac-md5 algorithm(with respect to RFC 2104) and the hmac result is 128 bits. When hmac-SHA1 algorithm is used, the result will be 160 bits. I need to apply padding to my hmac-md5 result to make 20 byte. Which values should i use for padding?

Steve Vinoski
  • 19,847
  • 3
  • 31
  • 46
Emel Uras
  • 394
  • 2
  • 13

1 Answers1

1

I need to apply padding to my hmac-md5 result to make 20 byte. Which values should i use for padding?

Apply another iteration of the hash on the existing output. Then, use the leftmost l-bits needed. This is similar to moder KDFs when stretching is needed.

Visually, it might look like:

[            hash = HMAC(message)            ][ HMAC(hash) ]
jww
  • 97,681
  • 90
  • 411
  • 885