Note: This bug is displayed in read-only format because
the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Description of problem:
According to NIST Special Publication 800-131Ar2, Section 8: Deriving Additional Keys from a Cryptographic Key, "[t]he length of the key-derivation key [i.e., the input key] shall be at least 112 bits". Additionally, for HMAC-based KDFs the document says: "The use of HMAC-based KDFs is acceptable using a hash function specified in FIPS 180 or FIPS 202 with a key whose length is at least 112 bits." This seems to refer to the output key length.
We should require lengths >= 112 bits for both key-derivation keys and derived keys and either reject shorter keys with an error message, or provide an explicit indicator that short keys are not FIPS-approved.
Version-Release number of selected component (if applicable):
3.0.1-43.el9_0
How reproducible:
Run the attached reproducer with values other than the permitted ones.
Steps to Reproduce:
1. cc -std=c99 -Wall -Werror -pedantic -D_XOPEN_SOURCE=600 -o kdf kdf.c -lcrypto
2. ./kdf sha256 16 $(( 112 / 8 )) $(( 112 / 8 )) (./kdf digest saltlen inkeylen outkeylen)
Actual results:
OK: 0x7afa9824958c5c1bcd6b7 (or some other derived key, salt and key-derivation key are randomly generated)
Expected results:
Failure because a short key was used.
See also https://bugzilla.redhat.com/show_bug.cgi?id=2136250, which imposes the same limit on HMAC keys.
Re-reading "The use of HMAC-based KDFs is acceptable using a hash function specified in FIPS 180 or FIPS 202 with a key whose length is at least 112 bits", this obviously refers to the length of the key used for HMAC, not the length of the derived secret.
The attached reproducer tested HKDF, which is only approved for use in TLS anyway. The restriction in SP 800-131Ar2 section 8 refers to KDFs defined in SP 800-108, which OpenSSL calls "key-based KDFs" and implements in EVP_KDF-KB(7), see https://www.openssl.org/docs/man3.0/man7/EVP_KDF-KB.html.
I am attaching an updated reproducer that correctly uses KBKDF (in HMAC mode) and prints the indicator state, if supported. I verified that this correctly detects unapproved key lengths:
$> $(head -n1 kdf.c | sed -E 's#^// ##g') && ./kdf sha256 16 $(( 112 / 8 )) $(( 112 / 8 ))
OK (indicator: approved): 0xb7dfff7bf89bce1ecbb2eb979e
$> $(head -n1 kdf.c | sed -E 's#^// ##g') && ./kdf sha256 16 $(( 112 / 8 - 1 )) $(( 112 / 8 ))
OK (indicator: unapproved): 0x5e294ba2fd908be0c58fb8b86bb1
Note that testing with CMAC does not seem to be necessary, since CMAC requires a cipher that expects a fixed key length (e.g., 128 bits for AES-128 or 256 bits for AES-256).
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.
For information on the advisory (Low: openssl security and bug fix update), and where to find the updated
files, follow the link below.
If the solution does not work for you, open a new bug report.
https://access.redhat.com/errata/RHSA-2023:2523