freebsd-dev/sys/opencrypto
Conrad Meyer 3693b18840 opencrypto: Loosen restriction on HMAC key sizes
Theoretically, HMACs do not actually have any limit on key sizes.
Transforms should compact input keys larger than the HMAC block size by
using the transform (hash) on the input key.

(Short input keys are padded out with zeros to the HMAC block size.)

Still, not all FreeBSD crypto drivers that provide HMAC functionality
handle longer-than-blocksize keys appropriately, so enforce a "maximum" key
length in the crypto API for auth_hashes that previously expressed a
requirement.  (The "maximum" is the size of a single HMAC block for the
given transform.)  Unconstrained auth_hashes are left as-is.

I believe the previous hardcoded sizes were committed in the original
import of opencrypto from OpenBSD and are due to specific protocol
details of IPSec.  Note that none of the previous sizes actually matched
the appropriate HMAC block size.

The previous hardcoded sizes made the SHA tests in cryptotest.py
useless for testing FreeBSD crypto drivers; none of the NIST-KAT example
inputs had keys sized to the previous expectations.

The following drivers were audited to check that they handled keys up to
the block size of the HMAC safely:

  Software HMAC:
    * padlock(4)
    * cesa
    * glxsb
    * safe(4)
    * ubsec(4)

  Hardware accelerated HMAC:
    * ccr(4)
    * hifn(4)
    * sec(4) (Only supports up to 64 byte keys despite claiming to
      support SHA2 HMACs, but validates input key sizes)
    * cryptocteon (MIPS)
    * nlmsec (MIPS)
    * rmisec (MIPS) (Amusingly, does not appear to use key material at
      all -- presumed broken)

Reviewed by:	jhb (previous version), rlibby (previous version)
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D12437
2017-09-26 16:18:10 +00:00
..
cast.c
cast.h
castsb.h
criov.c Use const with some read-only buffers in opencrypto APIs. 2017-05-09 18:28:42 +00:00
crypto.c crypto(9): Use a more specific error code when a capable driver is not found 2017-09-26 01:31:49 +00:00
cryptodeflate.c
cryptodev_if.m
cryptodev.c opencrypto: Loosen restriction on HMAC key sizes 2017-09-26 16:18:10 +00:00
cryptodev.h opencrypto: Loosen restriction on HMAC key sizes 2017-09-26 16:18:10 +00:00
cryptosoft.c Don't leak a session and lock if a GMAC key has an invalid length. 2017-04-05 01:46:41 +00:00
cryptosoft.h
deflate.h
gfmult.c
gfmult.h
gmac.c
gmac.h
rmd160.c
rmd160.h
skipjack.c
skipjack.h
xform_aes_icm.c opencrypto AES-ICM: Fix heap corruption typo 2016-08-01 22:57:03 +00:00
xform_aes_xts.c
xform_auth.h
xform_blf.c
xform_cast5.c
xform_cml.c
xform_comp.h
xform_deflate.c
xform_des1.c
xform_des3.c
xform_enc.h
xform_gmac.c
xform_md5.c opencrypto: Loosen restriction on HMAC key sizes 2017-09-26 16:18:10 +00:00
xform_null.c opencrypto: Loosen restriction on HMAC key sizes 2017-09-26 16:18:10 +00:00
xform_rijndael.c
xform_rmd160.c opencrypto: Loosen restriction on HMAC key sizes 2017-09-26 16:18:10 +00:00
xform_sha1.c opencrypto: Loosen restriction on HMAC key sizes 2017-09-26 16:18:10 +00:00
xform_sha2.c opencrypto: Loosen restriction on HMAC key sizes 2017-09-26 16:18:10 +00:00
xform_skipjack.c
xform_userland.h
xform.c
xform.h