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

crypto_provider: expose a way to get CSRNG data #458

Merged
merged 3 commits into from
Sep 10, 2024
Merged

Conversation

cpu
Copy link
Member

@cpu cpu commented Sep 9, 2024

This branch adds a rustls_crypto_provider_random() fn for filling a buffer with cryptographically secure random data using a specific rustls_crypto_provider, and rustls_default_crypto_provider_random() for the same with the process-wide default. Doing so requires adding a try_slice_mut! macro to accompany the existing try_slice! macro. It's similar in function but returns a &mut slice using slice::from_raw_parts_mut() instead of slice::from_raw_parts().

This should help with downstream issues like curl/curl#14770 where rustls-ffi stands out as the only TLS vtls backend in curl that can't provide this functionality.

@cpu cpu self-assigned this Sep 9, 2024
src/rustls.h Outdated Show resolved Hide resolved
@cpu cpu force-pushed the cpu-crypto-rand branch 3 times, most recently from 0b34c76 to e6deb8b Compare September 9, 2024 20:30
src/lib.rs Outdated Show resolved Hide resolved
This is a companion to the existing `try_slice!` macro, but returning
a `&mut` slice using `slice::from_raw_parts_mut()` instead of
`slice::from_raw_parts()`.

Two existing callers to `slice::from_raw_parts_mut()` in `connection.rs`
are converted to use the macro.
Prevent unsafety from using with incorrect argument type. Assume
`$count` is already a `usize` and let the compiler err otherwise.
This commit adds a `rustls_crypto_provider_random()` fn for filling
a buffer with cryptographically secure random data using
a specific `rustls_crypto_provider`, and
`rustls_default_crypto_provider_random()` for doing the same with the
process-wide default.
@cpu
Copy link
Member Author

cpu commented Sep 10, 2024

This feels small enough to not merit blocking on a review from Jsha.

@cpu cpu merged commit 99f40a2 into rustls:main Sep 10, 2024
39 checks passed
@cpu cpu deleted the cpu-crypto-rand branch September 10, 2024 12:09
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