-
Notifications
You must be signed in to change notification settings - Fork 1k
Crypto layer: Add missing input validation #10819
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
3bae119
460d5d0
4851d26
cd6b282
8a51b31
dceb591
a39ac0e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -98,14 +98,21 @@ struct Cmac { | |||||||||||||||||
|
|
||||||||||||||||||
|
|
||||||||||||||||||
|
|
||||||||||||||||||
|
|
||||||||||||||||||
| #ifndef NO_AES | ||||||||||||||||||
| #define WC_CMAC_TAG_MAX_SZ WC_AES_BLOCK_SIZE | ||||||||||||||||||
| #define WC_CMAC_TAG_MIN_SZ (WC_AES_BLOCK_SIZE/4) | ||||||||||||||||||
| #else | ||||||||||||||||||
| /* Reasonable defaults */ | ||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 [Medium] WC_CMAC_TAG_MAX_SZ made user-overridable without bounding it to the 16-byte digest buffer The macro was previously hard-tied to the AES block size ( Suggestion:
Suggested change
|
||||||||||||||||||
| #define WC_CMAC_TAG_MAX_SZ 16 | ||||||||||||||||||
| #define WC_CMAC_TAG_MIN_SZ 4 | ||||||||||||||||||
| #ifndef WC_CMAC_TAG_MAX_SZ | ||||||||||||||||||
| #define WC_CMAC_TAG_MAX_SZ 16 | ||||||||||||||||||
| #endif | ||||||||||||||||||
|
|
||||||||||||||||||
| #if !defined(NO_AES) && (WC_CMAC_TAG_MAX_SZ > 16) | ||||||||||||||||||
| #error WC_CMAC_TAG_MAX_SZ cannot exceed WC_AES_BLOCK_SIZE | ||||||||||||||||||
| #endif | ||||||||||||||||||
|
|
||||||||||||||||||
| /* SP800-38b recommends a minimum tag length of 64-bits */ | ||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔵 [Low] WC_CMAC_TAG_MIN_SZ redefined without #undef in the FIPS >= 7 branch The Suggestion:
Suggested change
|
||||||||||||||||||
| #if FIPS_VERSION3_GE(7,0,0) | ||||||||||||||||||
| #undef WC_CMAC_TAG_MIN_SZ | ||||||||||||||||||
| #define WC_CMAC_TAG_MIN_SZ 8 | ||||||||||||||||||
| #elif !defined(WC_CMAC_TAG_MIN_SZ) | ||||||||||||||||||
| #define WC_CMAC_TAG_MIN_SZ 4 | ||||||||||||||||||
| #endif | ||||||||||||||||||
|
|
||||||||||||||||||
| #if FIPS_VERSION3_GE(6,0,0) | ||||||||||||||||||
|
|
||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -3892,10 +3892,32 @@ | |||||||||||||||||||||||||||||||||||||||||||||||
| #error WOLFSSL_MIN_AUTH_TAG_SZ must be at least 1 | ||||||||||||||||||||||||||||||||||||||||||||||||
| #endif | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| #if defined(HAVE_FIPS) && FIPS_VERSION3_GE(7, 0, 0) | ||||||||||||||||||||||||||||||||||||||||||||||||
| /* No short (<96 bit) tags per SP 800-38D 2026 revision in process. */ | ||||||||||||||||||||||||||||||||||||||||||||||||
| #if WOLFSSL_MIN_AUTH_TAG_SZ < 12 | ||||||||||||||||||||||||||||||||||||||||||||||||
| #error WOLFSSL_MIN_AUTH_TAG_SZ must be >= 12 per SP 800-38D Rev 1 | ||||||||||||||||||||||||||||||||||||||||||||||||
| #if defined(HAVE_FIPS) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟠 [High] FIPS gate narrowed from <7.0.0 to ==5.2.4 raises min GCM tag to 12 for kernel FIPS 6.x, breaking RFC 4106 8-byte ICV The block moved out of the Suggestion:
Suggested change
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 [Medium] FIPS 5.2.4 branch force-lowers WOLFSSL_MIN_AUTH_TAG_SZ to 8 for user-space builds and overrides an explicit user setting Before this PR the whole adjustment block lived inside the Suggestion:
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||
| #if FIPS_VERSION3_EQ(5, 2, 4) || (FIPS_VERSION3_LT(7, 0, 0) && \ | ||||||||||||||||||||||||||||||||||||||||||||||||
| defined(WOLFSSL_LINUXKM)) | ||||||||||||||||||||||||||||||||||||||||||||||||
| /* support RFC 4106 IPsec ESP 64 bit tags */ | ||||||||||||||||||||||||||||||||||||||||||||||||
| #undef WOLFSSL_MIN_AUTH_TAG_SZ | ||||||||||||||||||||||||||||||||||||||||||||||||
| #define WOLFSSL_MIN_AUTH_TAG_SZ 8 | ||||||||||||||||||||||||||||||||||||||||||||||||
| #else | ||||||||||||||||||||||||||||||||||||||||||||||||
| /* No short (<96 bit) tags per SP 800-38D 2026 revision in process. */ | ||||||||||||||||||||||||||||||||||||||||||||||||
| #if WOLFSSL_MIN_AUTH_TAG_SZ < 12 | ||||||||||||||||||||||||||||||||||||||||||||||||
| #undef WOLFSSL_MIN_AUTH_TAG_SZ | ||||||||||||||||||||||||||||||||||||||||||||||||
| #define WOLFSSL_MIN_AUTH_TAG_SZ 12 | ||||||||||||||||||||||||||||||||||||||||||||||||
| #endif | ||||||||||||||||||||||||||||||||||||||||||||||||
| #endif | ||||||||||||||||||||||||||||||||||||||||||||||||
| #elif defined(WOLFSSL_LINUXKM) && (defined(CONFIG_CRYPTO_MANAGER_EXTRA_TESTS) \ | ||||||||||||||||||||||||||||||||||||||||||||||||
| || defined(CONFIG_CRYPTO_SELFTESTS_FULL)) | ||||||||||||||||||||||||||||||||||||||||||||||||
| /* The Linux kernel native crypto fuzzer expects small AES-GCM tag | ||||||||||||||||||||||||||||||||||||||||||||||||
| * sizes to succeed. */ | ||||||||||||||||||||||||||||||||||||||||||||||||
| #if WOLFSSL_MIN_AUTH_TAG_SZ > 4 | ||||||||||||||||||||||||||||||||||||||||||||||||
| #undef WOLFSSL_MIN_AUTH_TAG_SZ | ||||||||||||||||||||||||||||||||||||||||||||||||
| #define WOLFSSL_MIN_AUTH_TAG_SZ 4 | ||||||||||||||||||||||||||||||||||||||||||||||||
| #endif | ||||||||||||||||||||||||||||||||||||||||||||||||
| #elif defined(WOLFSSL_LINUXKM) | ||||||||||||||||||||||||||||||||||||||||||||||||
| /* support RFC 4106 IPsec ESP */ | ||||||||||||||||||||||||||||||||||||||||||||||||
| #if WOLFSSL_MIN_AUTH_TAG_SZ > 8 | ||||||||||||||||||||||||||||||||||||||||||||||||
| #undef WOLFSSL_MIN_AUTH_TAG_SZ | ||||||||||||||||||||||||||||||||||||||||||||||||
| #define WOLFSSL_MIN_AUTH_TAG_SZ 8 | ||||||||||||||||||||||||||||||||||||||||||||||||
| #endif | ||||||||||||||||||||||||||||||||||||||||||||||||
| #endif | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -4371,32 +4393,6 @@ | |||||||||||||||||||||||||||||||||||||||||||||||
| #undef HAVE_PUBLIC_FFDHE | ||||||||||||||||||||||||||||||||||||||||||||||||
| #endif | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| #if defined(HAVE_FIPS) | ||||||||||||||||||||||||||||||||||||||||||||||||
| #if FIPS_VERSION3_LT(7, 0, 0) | ||||||||||||||||||||||||||||||||||||||||||||||||
| /* support RFC 4106 IPsec ESP 64 bit tags */ | ||||||||||||||||||||||||||||||||||||||||||||||||
| #undef WOLFSSL_MIN_AUTH_TAG_SZ | ||||||||||||||||||||||||||||||||||||||||||||||||
| #define WOLFSSL_MIN_AUTH_TAG_SZ 8 | ||||||||||||||||||||||||||||||||||||||||||||||||
| #else | ||||||||||||||||||||||||||||||||||||||||||||||||
| /* No short (<96 bit) tags per SP 800-38D 2026 revision in process. */ | ||||||||||||||||||||||||||||||||||||||||||||||||
| #if WOLFSSL_MIN_AUTH_TAG_SZ < 12 | ||||||||||||||||||||||||||||||||||||||||||||||||
| #undef WOLFSSL_MIN_AUTH_TAG_SZ | ||||||||||||||||||||||||||||||||||||||||||||||||
| #define WOLFSSL_MIN_AUTH_TAG_SZ 12 | ||||||||||||||||||||||||||||||||||||||||||||||||
| #endif | ||||||||||||||||||||||||||||||||||||||||||||||||
| #endif | ||||||||||||||||||||||||||||||||||||||||||||||||
| #elif defined(CONFIG_CRYPTO_MANAGER_EXTRA_TESTS) || defined(CONFIG_CRYPTO_SELFTESTS_FULL) | ||||||||||||||||||||||||||||||||||||||||||||||||
| /* The Linux kernel native crypto fuzzer expects small AES-GCM tag sizes to succeed. */ | ||||||||||||||||||||||||||||||||||||||||||||||||
| #if WOLFSSL_MIN_AUTH_TAG_SZ > 4 | ||||||||||||||||||||||||||||||||||||||||||||||||
| #undef WOLFSSL_MIN_AUTH_TAG_SZ | ||||||||||||||||||||||||||||||||||||||||||||||||
| #define WOLFSSL_MIN_AUTH_TAG_SZ 4 | ||||||||||||||||||||||||||||||||||||||||||||||||
| #endif | ||||||||||||||||||||||||||||||||||||||||||||||||
| #else | ||||||||||||||||||||||||||||||||||||||||||||||||
| /* support RFC 4106 IPsec ESP */ | ||||||||||||||||||||||||||||||||||||||||||||||||
| #if WOLFSSL_MIN_AUTH_TAG_SZ > 8 | ||||||||||||||||||||||||||||||||||||||||||||||||
| #undef WOLFSSL_MIN_AUTH_TAG_SZ | ||||||||||||||||||||||||||||||||||||||||||||||||
| #define WOLFSSL_MIN_AUTH_TAG_SZ 8 | ||||||||||||||||||||||||||||||||||||||||||||||||
| #endif | ||||||||||||||||||||||||||||||||||||||||||||||||
| #endif | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| #if defined(LINUXKM_LKCAPI_REGISTER) && !defined(WOLFSSL_ASN_INT_LEAD_0_ANY) | ||||||||||||||||||||||||||||||||||||||||||||||||
| /* kernel 5.10 crypto manager tests key(s) that fail unless leading | ||||||||||||||||||||||||||||||||||||||||||||||||
| * zero bytes are tolerated in GetASN_Integer(). | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.