TLS 1.3 does not work in FIPS mode
Categories
(NSS :: Libraries, defect, P2)
Tracking
(Not tracked)
People
(Reporter: hkario, Assigned: rrelyea)
Details
(Whiteboard: [tls13])
Attachments
(2 files)
When NSS is switched to FIPS mode, TLS 1.3 doesn't work.
This is because NSS implements HKDF using the PKCS#11 functions prohibited under FIPS mode, namely PK11_ExtractKeyValue and PK11_ImportSymKey.
Reporter | ||
Comment 1•5 years ago
|
||
see also bug 1552767
Comment 2•5 years ago
|
||
Also relevant: https://docs.google.com/document/d/1vNkQcZ_yAVtzh1JZPULVqtQbqVYHKWkZf2-WCBHvsv8/edit?usp=sharing
We had a discussion about this a few years back, but never really concluded anything. Driving the process through PKCS#11 was not something I had the time to pursue.
Reporter | ||
Comment 3•5 years ago
|
||
AFAIK, Bob did push it through OASIS so HKDF is part of PKCS#11 v3.0 (same for TLS PRFs), but it now needs to be implemented in NSS using official PKCS#11 mechanisms
Comment 4•5 years ago
|
||
https://docs.oasis-open.org/pkcs11/pkcs11-curr/v3.0/csprd01/pkcs11-curr-v3.0-csprd01.html#_Toc10561290 looks workable, if complex. Credit then to Bob for working this out.
The typo on CKM_HKDF_DATA is unfortunate:
All tokens must minimally support bExtract set to true and bInfo values which start with the value “tls1.3 vi”.
Comment 5•5 years ago
|
||
I definitely agree this needs to get done, but the Mozilla team probably can't get to it in the next 16 weeks (2 cycles), so marking as a P2. We'd happily help review the patches, however.
Assignee | ||
Comment 6•5 years ago
|
||
Patches coming as part of the PKCS #11 v3.0 work.
Assignee | ||
Comment 7•5 years ago
|
||
Patch 1 of 2.
This patch updates softoken and helper functions with the new PKCS #11 v3 HKDF,
which handles all the correct key management so that we can work in FIPS mode
- Salts can be passed in as data, as and explicit NULL (which per spec means
a zero filled buffer of length of the underlying HMAC), or through a key handle - A Data object can be used as a key (explicitly allowed for this mechanism by
the spec). - A special mechansism produces a data object rather than a key, the latter
which can be exported. Softoken does not do the optional validation on the pInfo
to verify that the requested values are supposed to be data rather than keys.
Some other tokens may.
The old hkdf mechanism has been retained for compatibility (well namely until
patch 2 is created, tls is still using it). The hkdf function has been broken
off into it's own function rather than inline in the derive function.
Note: because the base key and/or the export key could really be a data object,
our explicit handling of sensitive and extractable are adjusted to take into
account that those flags do not exist in data objects.
Comment 8•5 years ago
|
||
This is great stuff. Bob, do you have any sense on how long you think we should keep the old mechanisms so that people can use a newer softoken with old TLS code? My impression is that the TLS code is unlikely to lag softoken by much, if anything, so the old proprietary stuff can be removed in fairly short order, if not immediately.
Assignee | ||
Comment 9•5 years ago
|
||
I think it depends on the mechanism. Even though TLS uses HKDF, it's also a generic mechanism, so people could be using it in other protocols. OTOH, it's an NSS specific mechanism, so that's less likely. On the 3rd hand, it's really sharing the code with the real PKCS #11 mechanism. so it's not an expensive mechanism to maintain.
We should check the rest of Firefox. Kevin found direct uses of AES_GCM inside firefox (beyond SSL or the experimental interface). HKDF could be the same. Probably the deprecation model could be #ifdef around the switch statement (based on if CKM_NSS_HKDF is defined), then move CKM_NSS_HKDF into the PKCS11_v_2_0 section. We'll likely turn PKCS11 v2.0 on in RHEL 7 and RHEL 8 rebases and not in Fedora (or any future RHEL). That means it can go away when we finally make PKCS 11_V2_0 go away.
bob
Assignee | ||
Comment 10•5 years ago
|
||
Part 2 of 2
Use the official PKCS #11 HKDF mechanism to implement tls 1.3.
-
The new mechanism is a single derive mechanism, so we no longer need to
pick it based on the underlying hmac (Note, we still need to know the
underlying hmac, which is passed in as a mechanism parameter). -
Use the new keygen to generate CKK_HKDF keys rather than doing it by hand
with the random number generator (never was really the best way of doing this). -
modify tls13hkdf.c to use the new mechanisms:
- Extract: use the new key handle in the mechanism parameters to pass the
salt when the salt is a key handle.
Extract: use the explicit NULL salt parameter if for the hash len salt of
zeros. - Expand: Expand is mostly a helper function which takes a mechanism. For
regular expand, the mechanism is the normal _Derive, for the Raw version
its the _Data function. That creates a data object, which is extractable
in FIPS mode.
- Extract: use the new key handle in the mechanism parameters to pass the
-
update slot handling in tls13hkdf.c:
- we need to make sure that the key and the salt key are in the same
slot. Provide a PK11wrap function to make that guarrentee (and use that
function in PK11_WrapKey, which already has to do the same function). - When importing a 'data' key for the zero key case, make sure we import
into the salt key's slot. If there is no salt key, use PK11_GetBestSlot()
rather than PK11_GetInternal slot.
- we need to make sure that the key and the salt key are in the same
Comment 11•5 years ago
|
||
Description
•