Improve/extend docs of `default_fips_provider()`

This commit is contained in:
Joseph Birr-Pixton 2024-02-09 15:24:47 +00:00 committed by Joe Birr-Pixton
parent 7415b5ff3d
commit 8e4afc6d14
1 changed files with 14 additions and 5 deletions

View File

@ -500,7 +500,20 @@ impl From<&[u8]> for SharedSecret {
/// This function returns a [`CryptoProvider`] that uses
/// FIPS140-3-approved cryptography.
///
/// You can use this like:
/// Using this function expresses in your code that you require
/// FIPS-approved cryptography, and will not compile if you make
/// a mistake with cargo features.
///
/// Install this as the process-default provider, like:
///
/// ```rust
/// # #[cfg(feature = "fips")] {
/// rustls::crypto::default_fips_provider().install_default()
/// .expect("default provider already set elsewhere");
/// # }
/// ```
///
/// You can also use this explicitly, like:
///
/// ```rust
/// # #[cfg(feature = "fips")] {
@ -514,10 +527,6 @@ impl From<&[u8]> for SharedSecret {
/// .with_no_client_auth();
/// # }
/// ```
///
/// This expresses in your code that you require FIPS-approved
/// cryptography, and will not compile if you make a mistake
/// with cargo features.
#[cfg(feature = "fips")]
pub fn default_fips_provider() -> CryptoProvider {
crate::crypto::aws_lc_rs::default_provider()