libsec: fix hmac for keys bigger then 64 byte block size

RFC2104 defines HMAC for keys bigger than the 64 byte block
size as follows:

Applications that use keys longer than B (64) bytes will
first hash the key using H (the hash function) and then
use the resultant L byte string as the actual key to HMAC.
This commit is contained in:
cinap_lenrek 2014-09-14 02:26:26 +02:00
parent 69fab298be
commit 4cf00ca6cb

View file

@ -11,8 +11,13 @@ hmac_x(uchar *p, ulong len, uchar *key, ulong klen, uchar *digest, DigestState *
if(xlen > sizeof(innerdigest))
return nil;
if(klen > Hmacblksz)
return nil;
if(klen > Hmacblksz){
if(xlen > Hmacblksz)
return nil;
(*x)(key, klen, innerdigest, nil);
key = innerdigest;
klen = xlen;
}
/* first time through */
if(s == nil || s->seeded == 0){