Oi galera.
Precisava de uma ajudinha para fazer um trabalho da universidade sobre o HMAC com SHA1 em java
Aqui esta com tudo ao promenor :
[color=red]
HMAC(K,m) is mathematically defined by
HMAC(K,m) = H((K XOR opad) || H((K XOR ipad) || m)).
H(·) be a cryptographic hash function
K be a secret key padded to the right with extra zeros to the block size of the hash function
m be the message to be authenticated
|| denote concatenation
opad be the outer padding (0x5c5c5c…5c5c, one-block-long hexadecimal constant)
ipad be the inner padding (0x363636…3636, one-block-long hexadecimal constant)
The following pseudocode demonstrates how HMAC may be implemented.
function hmac (key, message)
if (length(key) > blocksize) then
key = hash(key) // keys longer than blocksize are shortened
end if
if (length(key) < blocksize) then
key = key || zeroes(blocksize - length(key)) //keys shorter than blocksize are zero-padded
end if
o_key_pad = [0x5c * blocksize] XOR key // Where blocksize is that of the underlying hash function
i_key_pad = [0x36 * blocksize] XOR key // Where ⊕ is exclusive or (XOR)
return hash(o_key_pad || hash(i_key_pad || message)) // Where || is concatenation
end function [/color]
Eu não sei como implementar esse pseudocodigo.
Obrigado
Cumprimentos
