OTP Google Acc の実装に取り組んでいます。互換性。
これまで、私は使用してきた
-RFC2104( http://www.ietf.org/rfc/rfc2104.txt )、
-RFC4226( http://www.ietf.org/rfc/rfc4226.txt )、
-RFC6238 ( https://www.rfc-editor.org/rfc/rfc6238 )、および次のスキーマ:
[疑似コード時間 OTP] ( http://en.wikipedia.org/wiki/Google_Authenticator#Pseudocode_for_Time_OTP )
function GoogleAuthenticatorCode(string secret)
key := base32decode(secret)
message := floor(current Unix time / 30)
hash := HMAC-SHA1(key, message)
offset := value of last nibble of hash
truncatedHash := hash[offset..offset+3] //4 bytes starting at the offset
Set the first bit of truncatedHash to zero //remove the most significant bit
code := truncatedHash mod 1000000
pad code with 0 until length of code is 6
return code
" hash := HMAC-SHA1(key, message) " までは問題ありません。他のHMAC-SHA1コンバーターで結果を何度もチェックしました。(まあ、そう思います)。
しかし、その後、何かがうまくいかないと思います...明らかに、Google認証アプリ(Android)と同じコードを取得していないためです。(少なくとも、まだ 6 桁の値です)。
私がよく理解していると確信していない部分は次のとおりです。
offset := value of last nibble of hash
truncatedHash := hash[offset..offset+3] //4 bytes starting at the offset
Set the first bit of truncatedHash to zero //remove the most significant bit
誰かがこれについてより詳細な説明をしてもらえますか?
ありがとう、