OTP Google Acc。兼容

问题描述:

我正在执行OTP Google Acc。兼容。OTP Google Acc。兼容

到目前为止,我一直在使用

-RFC2104(http://www.ietf.org/rfc/rfc2104.txt),

-RFC4226(http://www.ietf.org/rfc/rfc4226.txt),

-RFC6238(https://tools.ietf.org/html/rfc6238),并按照这个模式:

[伪代码时间OTP](http://en.wikipedia.org/wiki/Google_Authenticator#Pseudocode_for_Time_OTP

​​

直到“hash:= HMAC-SHA1(key,message)”一切正常。我通过其他HMAC-SHA1转换器检查了多次结果。 (嗯,我认为是)。

但是,然后,我认为必须出问题...因为显然我没有得到与我的谷歌验证器应用程序(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 

可能有人给我这个更详细的解释?

感谢,

我的猜测是,你可以采取的offset值不正确。如果你没有位和字节排序的适当定义哈希

的最后四位的 声明

价值是相当模糊的。 引用维基百科页面有链接到许多实现的,我觉得this Java implementation东西来检查你的代码反对:

byte[] hash = ... 

// Dynamically truncate the hash 
// OffsetBits are the low order bits of the last byte of the hash 
int offset = hash[hash.length - 1] & 0xF;