将整数八位字节添加到字节数组
我正在尝试实施 Salted 质询响应身份验证机制 (RFC 5802) 并且我正在运行陷入了一点问题。
Hi(str, salt, i):
U1 := HMAC(str, salt + INT(1))
U2 := HMAC(str, U1)
...
Ui-1 := HMAC(str, Ui-2)
Ui := HMAC(str, Ui-1)
Hi := U1 XOR U2 XOR ... XOR Ui
where "i" is the iteration count, "+" is the string concatenation
operator, and INT(g) is a 4-octet encoding of the integer g, most
significant octet first.
我不确定如何添加 INT(1)。我有一个盐字节数组。我需要做的就是对 1 进行位移位并将其添加到数组的末尾吗?
I am trying to implement Salted Challenge Response Authentication Mechanism (RFC 5802) and I am running into a bit of a problem.
Hi(str, salt, i):
U1 := HMAC(str, salt + INT(1))
U2 := HMAC(str, U1)
...
Ui-1 := HMAC(str, Ui-2)
Ui := HMAC(str, Ui-1)
Hi := U1 XOR U2 XOR ... XOR Ui
where "i" is the iteration count, "+" is the string concatenation
operator, and INT(g) is a 4-octet encoding of the integer g, most
significant octet first.
I am unsure of how to add the INT(1). I have a byte array for salt. Do all I need to do is bit shift the 1 and add it to the end of the array?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您无法向数组添加任何内容。由于数组的大小是固定的,因此您需要为结果创建一个新数组。使用 BitConverter 类获取整数的二进制表示形式:
You can't add anything to an array. As arrays are fixed size you need to create a new array for the result. Use the
BitConverter
class to get the binary representation of the integer: