RFC 的测试值指定:
Appendix D - HOTP Algorithm: Test Values
The following test data uses the ASCII string
"12345678901234567890" for the secret:
Secret = 0x3132333435363738393031323334353637383930
Table 1 details for each count, the intermediate HMAC value.
Count Hexadecimal HMAC-SHA-1(secret, count)
0 cc93cf18508d94934c64b65d8ba7667fb7cde4b0
1 75a48a19d4cbe100644e8ac1397eea747a2d33ab
因此,如果我尝试在 ruby 中获得 0 的 HMAC,我会得到:
[20] pry(AuthyOTP)> secret_key = "12345678901234567890"
=> "12345678901234567890"
[22] pry(AuthyOTP)> OpenSSL::HMAC.hexdigest(digest, secret_key, "0")
=> "32a67f374525d32d0ce13e3db42b5b4a3f370cce"
我被期望得到cc93cf18508d94934c64b65d8ba7667fb7cde4b0
所以我用java写了一个实现,我得到了同样的结果:
Calculation OTP for movingFactor = 0
2. Calculate Hash =
32a67f374525d32d0ce13e3db42b5b4a3f370cce
那么当秘密是“12345678901234567890”时,“0”的十六进制 SHA1-HMAC 是什么?