From db6d924d4b7ced9a535943b06622942535f71d1e Mon Sep 17 00:00:00 2001 From: David Garske Date: Wed, 2 Feb 2022 08:29:05 -0800 Subject: [PATCH 1/6] User settings template for FIPS v5. --- examples/configs/README.md | 1 + examples/configs/include.am | 1 + examples/configs/user_settings_fipsv5.h | 145 ++++++++++++++++++++++++ 3 files changed, 147 insertions(+) create mode 100644 examples/configs/user_settings_fipsv5.h diff --git a/examples/configs/README.md b/examples/configs/README.md index ddde95d69..dadfa45ec 100644 --- a/examples/configs/README.md +++ b/examples/configs/README.md @@ -9,6 +9,7 @@ Example wolfSSL configuration file templates for use when autoconf is not availa * `user_settings_min_ecc.h`: This is ECC and SHA-256 only. For ECC verify only add `BUILD_VERIFY_ONLY`. * `user_settings_wolfboot_keytools.h`: This from wolfBoot tools/keytools and is ECC, RSA, ED25519 and ChaCha20. * `user_settings_fipsv2.h`: The FIPS v2 (3389) 140-2 certificate build options. +* `user_settings_fipsv5.h`: The FIPS v5 (ready) 140-3 build options. Equivalent to `./configure --enable-fips=v5-dev`. * `user_settings_stm32.h`: Example configuration file generated from the wolfSSL STM32 Cube pack. ## Usage diff --git a/examples/configs/include.am b/examples/configs/include.am index 9568c9536..a74fe24ef 100644 --- a/examples/configs/include.am +++ b/examples/configs/include.am @@ -7,4 +7,5 @@ EXTRA_DIST += examples/configs/user_settings_min_ecc.h EXTRA_DIST += examples/configs/user_settings_wolfboot_keytools.h EXTRA_DIST += examples/configs/user_settings_template.h EXTRA_DIST += examples/configs/user_settings_fipsv2.h +EXTRA_DIST += examples/configs/user_settings_fipsv5.h EXTRA_DIST += examples/configs/user_settings_stm32.h diff --git a/examples/configs/user_settings_fipsv5.h b/examples/configs/user_settings_fipsv5.h new file mode 100644 index 000000000..8cf0b5302 --- /dev/null +++ b/examples/configs/user_settings_fipsv5.h @@ -0,0 +1,145 @@ +/* user_settings_fipsv5.h + * + * Copyright (C) 2006-2022 wolfSSL Inc. + * + * This file is part of wolfSSL. + * + * wolfSSL is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * wolfSSL is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA + */ + +/* should be renamed to user_settings.h for customer use + * generated from configure options: + * ./fips-check.sh linuxv5-dev keep + * XXX-fips-test\wolfssl\options.h + * ./configure --enable-fips=v5-dev + * + * Cleaned up by David Garske + */ + + +#ifndef WOLFSSL_USER_SETTINGS_H +#define WOLFSSL_USER_SETTINGS_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* FIPS Version 5.3 */ +#define HAVE_FIPS +#define HAVE_FIPS_VERSION 5 +#define HAVE_FIPS_VERSION_MINOR 3 + +#define HAVE_HASHDRBG /* NIST Certified DRBG - SHA256 based */ +#define HAVE_THREAD_LS + +/* Math */ +#define USE_FAST_MATH +#define FP_MAX_BITS 16384 +#define SP_INT_BITS 8192 + +/* Timing Resistance */ +#define TFM_TIMING_RESISTANT +#define ECC_TIMING_RESISTANT +#define WC_RSA_BLINDING + +/* FIPS Features */ +#define WC_RNG_SEED_CB +#define WOLFSSL_VALIDATE_ECC_IMPORT +#define WOLFSSL_VALIDATE_ECC_KEYGEN +#define WOLFSSL_VALIDATE_FFC_IMPORT + +/* TLS Features */ +#define WOLFSSL_TLS13 +#define WOLFSSL_BASE64_ENCODE +#define WOLFSSL_USE_ALIGN +#define WOLFSSL_PUBLIC_MP +#define HAVE_ENCRYPT_THEN_MAC +#define HAVE_TLS_EXTENSIONS +#define HAVE_SUPPORTED_CURVES +#define HAVE_EXTENDED_MASTER +//#define HAVE_SERVER_RENEGOTIATION_INFO + +#undef WOLFSSL_WOLFSSH +#define WOLFSSL_WOLFSSH + +/* DH */ +#undef NO_DH +#define HAVE_FFDHE_Q +#define HAVE_FFDHE_2048 +#define HAVE_FFDHE_3072 +#define HAVE_FFDHE_4096 +#define HAVE_FFDHE_6144 +#define HAVE_FFDHE_8192 +#define HAVE_DH_DEFAULT_PARAMS +#define HAVE_PUBLIC_FFDHE + +/* ECC */ +#define HAVE_ECC +#define TFM_ECC256 +#define ECC_SHAMIR +#define HAVE_ECC_CDH +#define ECC_USER_CURVES +#define HAVE_ECC192 +#define HAVE_ECC224 +#define HAVE_ECC256 +#define HAVE_ECC384 +#define HAVE_ECC521 +#define WOLFSSL_ECDSA_SET_K + +/* RSA */ +#undef NO_RSA +#define WC_RSA_PSS +#define WOLFSSL_KEY_GEN +#define WC_RSA_NO_PADDING + +/* AES */ +#define WOLFSSL_AES_COUNTER +#define HAVE_AESCCM +#define HAVE_AES_ECB +#define WOLFSSL_AES_COUNTER +#define WOLFSSL_AES_DIRECT +#define WOLFSSL_AES_OFB +#define HAVE_AESGCM +#define GCM_TABLE_4BIT +#define WOLFSSL_CMAC + +/* Hashing */ +#undef NO_SHA +#undef NO_SHA256 +#define WOLFSSL_SHA224 +#define WOLFSSL_SHA512 +#define WOLFSSL_SHA384 +#define WOLFSSL_NO_SHAKE256 +#define WOLFSSL_NOSHA512_224 +#define WOLFSSL_NOSHA512_256 +#define WOLFSSL_SHA3 +#define HAVE_HKDF + +/* Disabled Algorithms */ +#define NO_OLD_TLS +#define NO_RC4 +#define NO_MD4 +#define NO_MD5 +#define NO_DES3 +#define NO_PSK +#define NO_DSA +#define NO_PWDBASED +#define WOLFSSL_NO_SHAKE256 + +#ifdef __cplusplus +} +#endif + +#endif /* WOLFSSL_USER_SETTINGS_H */ From 50700c3c28a798172e60766ac96da2e83ee2c04f Mon Sep 17 00:00:00 2001 From: David Garske Date: Thu, 3 Feb 2022 14:53:11 -0800 Subject: [PATCH 2/6] Make sure Rabbit and HC128 are disabled when building FIPS against older wolfSSL. --- examples/configs/user_settings_fipsv2.h | 3 ++- examples/configs/user_settings_fipsv5.h | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/examples/configs/user_settings_fipsv2.h b/examples/configs/user_settings_fipsv2.h index ed8aa6db9..9526890a1 100644 --- a/examples/configs/user_settings_fipsv2.h +++ b/examples/configs/user_settings_fipsv2.h @@ -105,7 +105,8 @@ extern "C" { #define NO_PWDBASED #define NO_RC4 #define WOLFSSL_NO_SHAKE256 - +#define NO_RABBIT +#define NO_HC128 #ifdef __cplusplus } diff --git a/examples/configs/user_settings_fipsv5.h b/examples/configs/user_settings_fipsv5.h index 8cf0b5302..90d773fb9 100644 --- a/examples/configs/user_settings_fipsv5.h +++ b/examples/configs/user_settings_fipsv5.h @@ -137,6 +137,8 @@ extern "C" { #define NO_DSA #define NO_PWDBASED #define WOLFSSL_NO_SHAKE256 +#define NO_RABBIT +#define NO_HC128 #ifdef __cplusplus } From 5169a3cf89acf44f25186b2f488e55754764c0d1 Mon Sep 17 00:00:00 2001 From: David Garske Date: Mon, 7 Feb 2022 15:58:10 -0800 Subject: [PATCH 3/6] Improve header comments and logic. Remove `NO_PWDBASED` and added CRL. --- examples/configs/user_settings_fipsv5.h | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/examples/configs/user_settings_fipsv5.h b/examples/configs/user_settings_fipsv5.h index 90d773fb9..d2d5b0114 100644 --- a/examples/configs/user_settings_fipsv5.h +++ b/examples/configs/user_settings_fipsv5.h @@ -69,10 +69,17 @@ extern "C" { #define HAVE_TLS_EXTENSIONS #define HAVE_SUPPORTED_CURVES #define HAVE_EXTENDED_MASTER -//#define HAVE_SERVER_RENEGOTIATION_INFO +#define HAVE_CRL -#undef WOLFSSL_WOLFSSH +#if 0 + #define HAVE_SECURE_RENEGOTIATION + #define HAVE_SERVER_RENEGOTIATION_INFO +#endif + +#ifndef WOLFSSL_WOLFSSH /* ifndef check required due to configure already generating flag */ #define WOLFSSL_WOLFSSH +#endif + /* DH */ #undef NO_DH @@ -135,7 +142,6 @@ extern "C" { #define NO_DES3 #define NO_PSK #define NO_DSA -#define NO_PWDBASED #define WOLFSSL_NO_SHAKE256 #define NO_RABBIT #define NO_HC128 From 7ec1e69dbaf203b394fe7fd55ace7c4b1cb6724e Mon Sep 17 00:00:00 2001 From: David Garske Date: Tue, 8 Feb 2022 10:18:41 -0800 Subject: [PATCH 4/6] Fixes for supporting the openssl compatibility layer. Adds ChaCha/Poly, DH extra and verify callbacks. --- examples/configs/user_settings_fipsv5.h | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/examples/configs/user_settings_fipsv5.h b/examples/configs/user_settings_fipsv5.h index d2d5b0114..35df7179e 100644 --- a/examples/configs/user_settings_fipsv5.h +++ b/examples/configs/user_settings_fipsv5.h @@ -48,6 +48,7 @@ extern "C" { #define USE_FAST_MATH #define FP_MAX_BITS 16384 #define SP_INT_BITS 8192 +#define WOLFSSL_PUBLIC_MP /* expose the mp_ math API's */ /* Timing Resistance */ #define TFM_TIMING_RESISTANT @@ -64,12 +65,16 @@ extern "C" { #define WOLFSSL_TLS13 #define WOLFSSL_BASE64_ENCODE #define WOLFSSL_USE_ALIGN -#define WOLFSSL_PUBLIC_MP #define HAVE_ENCRYPT_THEN_MAC #define HAVE_TLS_EXTENSIONS #define HAVE_SUPPORTED_CURVES #define HAVE_EXTENDED_MASTER +#define HAVE_ONE_TIME_AUTH /* TLS extension used with Poly1305 */ #define HAVE_CRL +#define HAVE_EXT_CACHE +#define WOLFSSL_VERIFY_CB_ALL_CERTS +#define WOLFSSL_ALWAYS_VERIFY_CB +#define WOLFSSL_DH_EXTRA /* DHE ASN.1 key import/export support */ #if 0 #define HAVE_SECURE_RENEGOTIATION @@ -80,6 +85,10 @@ extern "C" { #define WOLFSSL_WOLFSSH #endif +/* Compatibility Layer */ +#if 0 + #define OPENSSL_ALL +#endif /* DH */ #undef NO_DH @@ -122,6 +131,10 @@ extern "C" { #define GCM_TABLE_4BIT #define WOLFSSL_CMAC +/* ChaCha/Poly */ +#define HAVE_CHACHA +#define HAVE_POLY1305 + /* Hashing */ #undef NO_SHA #undef NO_SHA256 @@ -146,6 +159,7 @@ extern "C" { #define NO_RABBIT #define NO_HC128 + #ifdef __cplusplus } #endif From 40b171124f3f7bec1ff04c847af5f7e3e0b916fe Mon Sep 17 00:00:00 2001 From: David Garske Date: Fri, 11 Feb 2022 15:20:25 -0800 Subject: [PATCH 5/6] Fixes to resolve a few make check issues. --- examples/configs/user_settings_fipsv5.h | 34 +++++++++++++++---------- examples/sctp/sctp-client-dtls.c | 4 ++- examples/sctp/sctp-client.c | 4 ++- examples/sctp/sctp-server-dtls.c | 4 ++- examples/sctp/sctp-server.c | 4 ++- 5 files changed, 33 insertions(+), 17 deletions(-) diff --git a/examples/configs/user_settings_fipsv5.h b/examples/configs/user_settings_fipsv5.h index 35df7179e..b4a3340b1 100644 --- a/examples/configs/user_settings_fipsv5.h +++ b/examples/configs/user_settings_fipsv5.h @@ -63,29 +63,32 @@ extern "C" { /* TLS Features */ #define WOLFSSL_TLS13 -#define WOLFSSL_BASE64_ENCODE -#define WOLFSSL_USE_ALIGN -#define HAVE_ENCRYPT_THEN_MAC #define HAVE_TLS_EXTENSIONS +#define HAVE_ENCRYPT_THEN_MAC #define HAVE_SUPPORTED_CURVES #define HAVE_EXTENDED_MASTER #define HAVE_ONE_TIME_AUTH /* TLS extension used with Poly1305 */ -#define HAVE_CRL + +/* TLS Resumption */ +#define HAVE_SECURE_RENEGOTIATION +#define HAVE_SERVER_RENEGOTIATION_INFO +#define HAVE_SESSION_TICKET + +/* Other Features */ +#define WOLFSSL_USE_ALIGN +#define WOLFSSL_BASE64_ENCODE +//#define HAVE_CRL #define HAVE_EXT_CACHE #define WOLFSSL_VERIFY_CB_ALL_CERTS #define WOLFSSL_ALWAYS_VERIFY_CB #define WOLFSSL_DH_EXTRA /* DHE ASN.1 key import/export support */ -#if 0 - #define HAVE_SECURE_RENEGOTIATION - #define HAVE_SERVER_RENEGOTIATION_INFO -#endif - -#ifndef WOLFSSL_WOLFSSH /* ifndef check required due to configure already generating flag */ +#ifndef WOLFSSL_WOLFSSH /* ifndef check required due to configure already generating flag */ #define WOLFSSL_WOLFSSH #endif /* Compatibility Layer */ +#define OPENSSL_EXTRA #if 0 #define OPENSSL_ALL #endif @@ -147,18 +150,23 @@ extern "C" { #define WOLFSSL_SHA3 #define HAVE_HKDF -/* Disabled Algorithms */ +/* Disabled Features */ #define NO_OLD_TLS +#define NO_PSK + +/* Disabled Algorithms */ #define NO_RC4 #define NO_MD4 #define NO_MD5 #define NO_DES3 -#define NO_PSK #define NO_DSA -#define WOLFSSL_NO_SHAKE256 #define NO_RABBIT #define NO_HC128 +#define WOLFSSL_NO_SHAKE256 +#if 0 + #define DEBUG_WOLFSSL +#endif #ifdef __cplusplus } diff --git a/examples/sctp/sctp-client-dtls.c b/examples/sctp/sctp-client-dtls.c index 8022e50ed..8db65a185 100644 --- a/examples/sctp/sctp-client-dtls.c +++ b/examples/sctp/sctp-client-dtls.c @@ -49,8 +49,10 @@ static int err_sys(const char* msg) } #endif /* WOLFSSL_SCTP && WOLFSSL_DTLS */ -int main() +int main(int argc, char **argv) { + (void)argc; + (void)argv; #if defined(WOLFSSL_SCTP) && defined(WOLFSSL_DTLS) int sd = socket(PF_INET, SOCK_STREAM, IPPROTO_SCTP); diff --git a/examples/sctp/sctp-client.c b/examples/sctp/sctp-client.c index 9a55cd210..fe365e3a0 100644 --- a/examples/sctp/sctp-client.c +++ b/examples/sctp/sctp-client.c @@ -38,8 +38,10 @@ #include #endif /* WOLFSSL_SCTP */ -int main() +int main(int argc, char **argv) { + (void)argc; + (void)argv; #ifdef WOLFSSL_SCTP int sd = socket(PF_INET, SOCK_STREAM, IPPROTO_SCTP); diff --git a/examples/sctp/sctp-server-dtls.c b/examples/sctp/sctp-server-dtls.c index 5d14ca872..24b0ad9e9 100644 --- a/examples/sctp/sctp-server-dtls.c +++ b/examples/sctp/sctp-server-dtls.c @@ -49,8 +49,10 @@ static int err_sys(const char* msg) } #endif /* WOLFSSL_SCTP && WOLFSSL_DTLS */ -int main() +int main(int argc, char **argv) { + (void)argc; + (void)argv; #if defined(WOLFSSL_SCTP) && defined(WOLFSSL_DTLS) int sd = socket(PF_INET, SOCK_STREAM, IPPROTO_SCTP); diff --git a/examples/sctp/sctp-server.c b/examples/sctp/sctp-server.c index 75034caaf..a829c40aa 100644 --- a/examples/sctp/sctp-server.c +++ b/examples/sctp/sctp-server.c @@ -36,8 +36,10 @@ #include #endif /* WOLFSSL_SCTP */ -int main() +int main(int argc, char **argv) { + (void)argc; + (void)argv; #ifdef WOLFSSL_SCTP int sd = socket(PF_INET, SOCK_STREAM, IPPROTO_SCTP); From 194466c35a0f47cf8ec0596a8213e6dfd5d76cc5 Mon Sep 17 00:00:00 2001 From: David Garske Date: Tue, 22 Feb 2022 15:22:27 -0800 Subject: [PATCH 6/6] Peer review fixes. --- examples/configs/user_settings_fipsv5.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/examples/configs/user_settings_fipsv5.h b/examples/configs/user_settings_fipsv5.h index b4a3340b1..441b5a847 100644 --- a/examples/configs/user_settings_fipsv5.h +++ b/examples/configs/user_settings_fipsv5.h @@ -77,7 +77,9 @@ extern "C" { /* Other Features */ #define WOLFSSL_USE_ALIGN #define WOLFSSL_BASE64_ENCODE -//#define HAVE_CRL +#if 0 /* optionally enable CRL (Certificate Revocation List) */ + #define HAVE_CRL +#endif #define HAVE_EXT_CACHE #define WOLFSSL_VERIFY_CB_ALL_CERTS #define WOLFSSL_ALWAYS_VERIFY_CB @@ -89,7 +91,7 @@ extern "C" { /* Compatibility Layer */ #define OPENSSL_EXTRA -#if 0 +#if 0 /* if full suite of compatibility API's are needed */ #define OPENSSL_ALL #endif @@ -124,6 +126,7 @@ extern "C" { #define WC_RSA_NO_PADDING /* AES */ +#undef NO_AES #define WOLFSSL_AES_COUNTER #define HAVE_AESCCM #define HAVE_AES_ECB @@ -164,8 +167,11 @@ extern "C" { #define NO_HC128 #define WOLFSSL_NO_SHAKE256 +/* Debugging */ #if 0 #define DEBUG_WOLFSSL +#else + /* #define NO_ERROR_STRINGS */ #endif #ifdef __cplusplus