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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

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
@dgarske
Copy link
Contributor

dgarske commented Nov 21, 2024

Retest this please. CRL issues

src/ssl.c Outdated
@@ -10420,6 +10802,10 @@ int wolfSSL_Cleanup(void)

WOLFSSL_ENTER("wolfSSL_Cleanup");

#if defined(WOLFSSL_SYS_CRYPTO_POLICY)
wolfSSL_crypto_policy_disable();
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the policy disable should only happen on a full free. After the initRefCount is 0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants