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:
parent
69fab298be
commit
4cf00ca6cb
1 changed files with 7 additions and 2 deletions
|
@ -11,8 +11,13 @@ hmac_x(uchar *p, ulong len, uchar *key, ulong klen, uchar *digest, DigestState *
|
||||||
|
|
||||||
if(xlen > sizeof(innerdigest))
|
if(xlen > sizeof(innerdigest))
|
||||||
return nil;
|
return nil;
|
||||||
if(klen > Hmacblksz)
|
if(klen > Hmacblksz){
|
||||||
|
if(xlen > Hmacblksz)
|
||||||
return nil;
|
return nil;
|
||||||
|
(*x)(key, klen, innerdigest, nil);
|
||||||
|
key = innerdigest;
|
||||||
|
klen = xlen;
|
||||||
|
}
|
||||||
|
|
||||||
/* first time through */
|
/* first time through */
|
||||||
if(s == nil || s->seeded == 0){
|
if(s == nil || s->seeded == 0){
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue