From 09e7a13a129f053e0a61da3ab8b4ea878dffde45 Mon Sep 17 00:00:00 2001 From: Eduardo Fernandez Date: Wed, 27 Nov 2024 15:03:29 -0800 Subject: [PATCH] minor changes --- src/crypto/mod.rs | 16 ++++++++++------ src/lib.rs | 3 ++- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/crypto/mod.rs b/src/crypto/mod.rs index 248373b4..53b98c1a 100644 --- a/src/crypto/mod.rs +++ b/src/crypto/mod.rs @@ -43,24 +43,28 @@ pub enum CryptoError { Io(#[from] io::Error), } +/// An ID specifying which Crypto implementation to use. #[derive(Clone, Copy, Debug, PartialEq)] pub enum CryptoProviderId { #[cfg(feature = "openssl")] + /// Use OpenSSL OpenSsl, #[cfg(all(feature = "openssl", feature = "sha1"))] + /// Use OpenSSL for most ciphers, but use sha1 crate for SHA1 hashes. OpenSslWithSha1Crate, #[cfg(feature = "wincrypto")] + /// Use Windows Cryptography APIs WinCrypto, } -#[cfg(feature = "openssl")] impl Default for CryptoProviderId { + #[allow(unreachable_code)] fn default() -> Self { - if cfg!(feature = "sha1") { - CryptoProviderId::OpenSslWithSha1Crate - } else { - CryptoProviderId::OpenSsl - } + #[cfg(all(feature = "openssl", feature = "sha1"))] + return CryptoProviderId::OpenSslWithSha1Crate; + #[cfg(feature = "openssl")] + return CryptoProviderId::OpenSsl; + panic!("No default for CryptoProviderId!") } } diff --git a/src/lib.rs b/src/lib.rs index ebcffc46..88cd4f92 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -596,7 +596,8 @@ use thiserror::Error; use util::InstantExt; mod crypto; -use crypto::{CryptoProvider, CryptoProviderId, Fingerprint}; +pub use crypto::CryptoProviderId; +use crypto::{CryptoProvider, Fingerprint}; mod dtls; use dtls::DtlsCert;