History

crypto: api - allow algs only in specific constructions in FIPS mode

Currently we do not distinguish between algorithms that fail on the self-test vs. those which are disabled in FIPS mode (not allowed). Both are marked as having failed the self-test. Recently the need arose to allow the usage of certain algorithms only as arguments to specific template instantiations in FIPS mode. For example, standalone "dh" must be blocked, but e.g. "ffdhe2048(dh)" is allowed. Other potential use cases include "cbcmac(aes)", which must only be used with ccm(), or "ghash", which must be used only for gcm(). This patch allows this scenario by adding a new flag FIPS_INTERNAL to indicate those algorithms that are not FIPS-allowed. They can then be used as template arguments only, i.e. when looked up via crypto_grab_spawn() to be more specific. The FIPS_INTERNAL bit gets propagated upwards recursively into the surrounding template instances, until the construction eventually matches an explicit testmgr entry with ->fips_allowed being set, if any. The behaviour to skip !->fips_allowed self-test executions in FIPS mode will be retained. Note that this effectively means that FIPS_INTERNAL algorithms are handled very similarly to the INTERNAL ones in this regard. It is expected that the FIPS_INTERNAL algorithms will receive sufficient testing when the larger constructions they're a part of, if any, get exercised by testmgr. Note that as a side-effect of this patch algorithms which are not FIPS-allowed will now return ENOENT instead of ELIBBAD. Hopefully this is not an issue as some people were relying on this already.

Nicolai Stange committed 4 years ago

Commit d6097b81 parent c8e82365 files · +63 −10Browse files

Showing the changes to include (1 of 5 files). Show all

Unified · Split

include/linux/crypto.h+9−0
@@ -132,6 +132,15 @@ · 131 unmodified lines
132132 */
133133 #define CRYPTO_ALG_ALLOCATES_MEMORY 0x00010000
134134
135+/*
136+ * Mark an algorithm as a service implementation only usable by a
137+ * template and never by a normal user of the kernel crypto API.
138+ * This is intended to be used by algorithms that are themselves
139+ * not FIPS-approved but may instead be used to implement parts of
140+ * a FIPS-approved algorithm (e.g., dh vs. ffdhe2048(dh)).
141+ */
142+#define CRYPTO_ALG_FIPS_INTERNAL 0x00020000
143+
135144 /*
136145 * Transform masks and values (for crt_flags).
137146 */

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t