Skip to content

refactor: Use strong libcrypto randomness instead of custom random#5726

Merged
kaukabrizvi merged 23 commits intoaws:mainfrom
kaukabrizvi:drbg_removal
Feb 25, 2026
Merged

refactor: Use strong libcrypto randomness instead of custom random#5726
kaukabrizvi merged 23 commits intoaws:mainfrom
kaukabrizvi:drbg_removal

Conversation

@kaukabrizvi
Copy link
Copy Markdown
Contributor

@kaukabrizvi kaukabrizvi commented Feb 9, 2026

Goal

This change brings us one step closer to deprecating s2n's custom DRBG by sourcing entropy from strong backend libcrypto's randomness implementation when available.

Why

Over the years, maintaining our own custom DBRG implementation has led to several issues, most of which relate to portability concerns. See #4348 and docs/design/DRBG.md in this PR for more.

How

We currently gate libcrypto backend delegation for randomness based on wether or not s2n is built in FIPS mode. This PR refactors the logic to delegate randomness based on libcrypto feature detection.

With these changes, we delegate randomness to the libcrypto if it supports a seperate public/private module for randomness. This is required to uphold our security guarantee that public entropy which is visible on the wire cannot be used to leak information about the private entropy.

As part of this PR, I modified tests which previously exercised the "backend randomness in use" path by observing FIPS mode to now gate based on the random_uses_libcrypto indicator instead. I also added fixes to typos in two randomness tests as part of this PR which I noticed when looking over the files.

Callouts

This PR does not completely remove the DRBG module in s2n-tls because there are still two libcrypto cases that do not meet our standard: OpenSSL 1.0.2 and versions of AWS-LC prior to aws/aws-lc#2963 do not support public/private random. These cases will be handled in a follow-up PR alongside full deprecation of the DRBG module.

Testing

Since this PR re-factors existing randomness branching, I updated tests that relied on previous assertions as to when the backend libcrypto randomness was being utilized.
#4348

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@kaukabrizvi kaukabrizvi changed the title refactor: Use strong libcrypto randomness instead of custom random. refactor: Use strong libcrypto randomness instead of custom random Feb 9, 2026
@github-actions github-actions bot added the s2n-core team label Feb 9, 2026
@kaukabrizvi kaukabrizvi marked this pull request as ready for review February 16, 2026 22:02
@kaukabrizvi kaukabrizvi marked this pull request as draft February 16, 2026 22:02
@kaukabrizvi kaukabrizvi marked this pull request as ready for review February 16, 2026 22:30
@kaukabrizvi
Copy link
Copy Markdown
Contributor Author

@maddeleine @CarolYeh910 thank you for the feedback. After reviewing this more closely, I determined that the chunking logic is unnecessary because libcrypto already handles large request sizes internally. I’ve removed that logic. With chunking removed, we’re also no longer passing RAND_*bytes through a generic function pointer, so the adapter logic is no longer needed either.

@kaukabrizvi kaukabrizvi added this pull request to the merge queue Feb 25, 2026
Merged via the queue into aws:main with commit 6dc7efb Feb 25, 2026
54 checks passed
@kaukabrizvi kaukabrizvi deleted the drbg_removal branch February 25, 2026 19:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants