Skip to content

Conversation

@ColtonWilley
Copy link
Contributor

Adds optional SEED-SRC provider algorithm that caches /dev/urandom file handle for fork-safe entropy, matching OpenSSL's default provider behavior. This enables wolfProvider to work in seccomp-sandboxed applications like OpenSSH where openat() is blocked after fork.

Key features:
Lazy /dev/urandom open on first entropy request
Thread-safe with mutex protection
Registers wolfSSL seed callback for fork detection
Disabled by default, enable with --enable-seed-src

@ColtonWilley ColtonWilley requested a review from SparkiDev January 7, 2026 21:07
Copy link
Contributor

@padelsbach padelsbach left a comment

Choose a reason for hiding this comment

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

first round of comments submitted ...

@@ -0,0 +1,484 @@
/* test_drbg_seed_src.c
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider naming this file test_rand_seed.c or similar for consistency with test_rand.c

BIO_METHOD *coreBioMethod;
} WOLFPROV_CTX;

#ifdef WP_HAVE_SEED_SRC
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we also need to gate this with WP_HAVE_RANDOM?

extern const OSSL_DISPATCH wp_tls1_prf_keyexch_functions[];

/* DRBG implementations. */
#ifdef WP_HAVE_SEED_SRC
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider naming this WP_HAVE_RANDOM_SEED or similar for consistency with WP_HAVE_RANDOM

/** Parent's clear_seed function. */
OSSL_FUNC_rand_clear_seed_fn* parentClearSeed;
/** Whether we have a parent DRBG. */
int hasParent;
Copy link
Contributor

Choose a reason for hiding this comment

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

hasParent is only used in one location. Can we use parentGetSeed != NULL instead?

*
* @param [in] provCtx Provider context.
* @param [in] provCtx Provider context.
* @param [in] parent Parent DRBG context for getting entropy.
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not seeing where the parent and parentDispatch params are passed in. Can you point me to that?


(void)os;

#ifndef WP_SINGLE_THREADED
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider a wrapper function to avoid the ifdefs

size_t seedLen)
{
(void)ctx;
OPENSSL_secure_clear_free(seed, seedLen);
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need to go back to EVP_RAND_STATE_UNINITIALISED here?

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.

2 participants