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?
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
BitConverterclass to get the binary representation of the integer: