diff options
| author | Steven Fackler <[email protected]> | 2018-03-16 22:00:59 -0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2018-03-16 22:00:59 -0700 |
| commit | cf658e4c5c564cf4dc794a00a7bb20ceb0e425e3 (patch) | |
| tree | 21d9cf732de4edb4bf286c24478d030b441fda64 /openssl/src/ssl | |
| parent | Merge pull request #874 from rohit-lshift/priv-key-from-num (diff) | |
| parent | Expose additional cipher and digest accessors (diff) | |
| download | rust-openssl-cf658e4c5c564cf4dc794a00a7bb20ceb0e425e3.tar.xz rust-openssl-cf658e4c5c564cf4dc794a00a7bb20ceb0e425e3.zip | |
Merge pull request #875 from Ralith/hash-extras
Expose cipher digests and digest sizes
Diffstat (limited to 'openssl/src/ssl')
| -rw-r--r-- | openssl/src/ssl/mod.rs | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/openssl/src/ssl/mod.rs b/openssl/src/ssl/mod.rs index e2a0f156..f7f46a7f 100644 --- a/openssl/src/ssl/mod.rs +++ b/openssl/src/ssl/mod.rs @@ -96,6 +96,8 @@ use stack::{Stack, StackRef}; use ssl::bio::BioMethod; use ssl::error::InnerError; use ssl::callbacks::*; +use nid::Nid; +use hash::MessageDigest; pub use ssl::connector::{ConnectConfiguration, SslAcceptor, SslAcceptorBuilder, SslConnector, SslConnectorBuilder}; @@ -1814,6 +1816,30 @@ impl SslCipherRef { String::from_utf8(CStr::from_ptr(ptr as *const _).to_bytes().to_vec()).unwrap() } } + + /// Returns the handshake digest of the cipher. + /// + /// Available as of OpenSSL 1.1.1. This corresponds to [`SSL_CIPHER_get_handshake_digest`]. + /// + /// [`SSL_CIPHER_get_handshake_digest`]: https://www.openssl.org/docs/man1.1.1/man3/SSL_CIPHER_get_handshake_digest.html + #[cfg(all(feature = "v111", ossl111))] + pub fn handshake_digest(&self) -> Option<MessageDigest> { + unsafe { + let ptr = ffi::SSL_CIPHER_get_handshake_digest(self.as_ptr()); + if ptr.is_null() { None } else { Some(MessageDigest::from_ptr(ptr)) } + } + } + + /// Returns the NID corresponding to the cipher. + /// + /// Available as of OpenSSL 1.1.0. This corresponds to [`SSL_CIPHER_get_cipher_nid`] + /// + /// [`SSL_CIPHER_get_cipher_nid`]: https://www.openssl.org/docs/man1.1.0/ssl/SSL_CIPHER_get_cipher_nid.html + #[cfg(any(all(feature = "v110", ossl110), all(feature = "v111", ossl111)))] + pub fn cipher_nid(&self) -> Option<Nid> { + let n = unsafe { ffi::SSL_CIPHER_get_cipher_nid(self.as_ptr()) }; + if n == 0 { None } else { Some(Nid::from_raw(n)) } + } } foreign_type! { |