Skip to content

Commit

Permalink
minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
efer-ms committed Nov 27, 2024
1 parent 9ad112d commit 09e7a13
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
16 changes: 10 additions & 6 deletions src/crypto/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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!")
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 09e7a13

Please sign in to comment.