Cryptography OTP谷歌Acc兼容
我正在致力于一个OTP谷歌Acc兼容的实现 到目前为止,我一直在使用 -RFC2104 -RFC4226 -RFC6238,并遵循此模式: [伪码时间OTP] 在hash:=HMAC-SHA1key之前,消息一切正常。我通过其他HMAC-SHA1转换器多次检查结果。嗯,我想是的 但是,我想一定是出了问题。。。因为很明显,我得到的代码与我的谷歌验证器应用程序android不一样。至少它仍然是一个6位数的值 我不太清楚的是:Cryptography OTP谷歌Acc兼容,cryptography,hmacsha1,google-authenticator,one-time-password,Cryptography,Hmacsha1,Google Authenticator,One Time Password,我正在致力于一个OTP谷歌Acc兼容的实现 到目前为止,我一直在使用 -RFC2104 -RFC4226 -RFC6238,并遵循此模式: [伪码时间OTP] 在hash:=HMAC-SHA1key之前,消息一切正常。我通过其他HMAC-SHA1转换器多次检查结果。嗯,我想是的 但是,我想一定是出了问题。。。因为很明显,我得到的代码与我的谷歌验证器应用程序android不一样。至少它仍然是一个6位数的值 我不太清楚的是: offset := value of last nibble of ha
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
有人能给我一个更详细的解释吗
谢谢,我的猜测是,您可能会错误地使用偏移量的值。 声明 哈希最后一个半字节的值 如果对位和字节顺序没有一个正确的定义,那么它是相当模糊的。 引用的wikipedia页面有许多实现的链接,我认为需要检查代码:
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;
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;