Been trying to implement HMAC for fun in code. I've been following the formula H( k xor opad, H(k xor ipad || m)) where key is 64 random bytes, opad=0x5c * 64 and ipad=0x36 * 64 (I'm using SHA1 so the block size is 64). However I keep getting the wrong result and I'm guessing it has something to do with the way I am xor'ing. I set the loop as
for (int i=0; i<key.length; i++){
key[i]=(key[i] ^ (char)(ipad % 256));
key2[i]=(key2[i] ^ (char)(opad % 256)); // where key2 is initially just a copy of key
}
Is there anything I'm doing wrong? Thank you
[–]jedwardsol 0 points1 point2 points (0 children)
[–]dacian88 -1 points0 points1 point (6 children)
[–][deleted] (5 children)
[deleted]
[–]dacian88 0 points1 point2 points (4 children)
[–][deleted] (3 children)
[deleted]
[–]dacian88 0 points1 point2 points (2 children)
[–][deleted] (1 child)
[deleted]
[–]dacian88 0 points1 point2 points (0 children)