Skip to content
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

fedora crypto-policies: initial support. #8205

Merged
merged 1 commit into from
Dec 19, 2024

Conversation

philljj
Copy link
Contributor

@philljj philljj commented Nov 20, 2024

Description

Adds initial support for Fedora and Redhat system-wide crypto-policies.

The idea is at runtime, a system wide crypto-policy config file is loaded that sets minimum security limits on:

  • key sizes
  • tls methods
  • allowed ciphers

Fixes zd#18593.

Build with --with-sys-crypto-policy, or --with-sys-crypto-policy=<path>. If no arg is given, then /etc/crypto-policies/back-ends/wolfssl.config is used as default.

Requires enable-distro.

crypto-policy API

  • wolfSSL_crypto_policy_enable
  • wolfSSL_crypto_policy_enable_buffer
  • wolfSSL_crypto_policy_disable
  • wolfSSL_crypto_policy_is_enabled
  • wolfSSL_crypto_policy_get_ciphers
  • wolfSSL_crypto_policy_get_level

Enable with wolfSSL_crypto_policy_enable or wolfSSL_crypto_policy_enable_buffer. Once enabled, new instantiated WOLFSSL_CTX will inherit the policy's parameters. Trying to change the minimum downgrade version, or set key sizes smaller than allowed minimum will return CRYPTO_POLICY_FORBIDDEN.

The crypto_policy API are not thread safe, and should only be used during program init.

Testing

Added new unit tests:

  • test_wolfSSL_crypto_policy
  • test_wolfSSL_crypto_policy_certs_and_keys
  • test_wolfSSL_crypto_policy_tls_methods
  • test_wolfSSL_crypto_policy_ciphers

Added Jenkins test:

Config

Added three example crypto-policy configs here:

  • examples/crypto_policies/future/wolfssl.txt
  • examples/crypto_policies/default/wolfssl.txt
  • examples/crypto_policies/legacy/wolfssl.txt

Examples

The examples client and server were updated to take crypto-policy as an arg.

E.g. if you run the example with the future policy it will fail, because the future policy requires min 3072 RSA and DH key sizes (or 256 bit ecc keys):

./examples/client/client --crypto-policy examples/crypto_policies/future/wolfssl.txt 
wolfSSL Entering wolfSSL_Init
wolfSSL Entering wolfCrypt_Init
...

wolfSSL error: Error setting minimum DH key size

If you set the client to use larger keys, then it works again:

./examples/client/client --crypto-policy examples/crypto_policies/future/wolfssl.txt -Z 3072 \
 -k certs/ecc-client-key.pem \
-c certs/client-ecc-cert.pem \
-A certs/ca-ecc-cert.pem

@philljj philljj self-assigned this Nov 20, 2024
@philljj philljj force-pushed the fedora_crypto_policy branch from 2b8ae8b to d3b28ff Compare November 20, 2024 23:23
@dgarske
Copy link
Contributor

dgarske commented Nov 21, 2024

Retest this please. CRL issues

@philljj philljj force-pushed the fedora_crypto_policy branch from 0b8d992 to a29b79f Compare November 21, 2024 17:07
@philljj philljj assigned wolfSSL-Bot and unassigned philljj Nov 21, 2024
src/ssl.c Outdated Show resolved Hide resolved
@philljj philljj force-pushed the fedora_crypto_policy branch 2 times, most recently from 9535b80 to 8bc9faf Compare November 26, 2024 22:15
@philljj philljj assigned wolfSSL-Bot and unassigned philljj Nov 27, 2024
JacobBarthelmeh
JacobBarthelmeh previously approved these changes Dec 2, 2024
Copy link
Contributor

@JacobBarthelmeh JacobBarthelmeh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me. Is there feedback on use with Fedora?

Copy link
Contributor

@douzzer douzzer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The current code depends on OPENSSL_EXTRA, and you should add an error in configure.ac if someone attempts to use --with-sys-crypto-policy without ENABLED_OPENSSLEXTRA.

The other notable dependency is on stdio filesystem, so build fails if -DNO_FILESYSTEM. But wolfSSL_crypto_policy_enable() could be implemented to take a const char * instead of a path, eliminating that dependency. That could prove useful in embedded and kernel apps.

@philljj
Copy link
Contributor Author

philljj commented Dec 18, 2024

The combo --with-sys-crypto-policy --disable-filesystem works now. wolfSSL_crypto_policy_enable_buffer() lets you pass a mem buffer, and wolfSSL_crypto_policy_enable is gated behind !NO_FILESYSTEM:

#ifndef NO_FILESYSTEM
WOLFSSL_API int    wolfSSL_crypto_policy_enable(const char * policy);
#endif /* ! NO_FILESYSTEM */
WOLFSSL_API int    wolfSSL_crypto_policy_enable_buffer(const char * buf);

@philljj philljj force-pushed the fedora_crypto_policy branch from 02d70ba to b5c47d2 Compare December 18, 2024 23:07
@douzzer douzzer merged commit be2e779 into wolfSSL:master Dec 19, 2024
148 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants