Unverified Commit 22ffa9ad authored by Steven Fackler's avatar Steven Fackler Committed by GitHub
Browse files

Merge pull request #2258 from sfackler/init-md

Initialize OpenSSL in MD constructors
parents c38bc2f8 9de37944
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -70,6 +70,7 @@ impl MessageDigest {
    ///
    /// [`EVP_get_digestbynid`]: https://www.openssl.org/docs/manmaster/crypto/EVP_DigestInit.html
    pub fn from_nid(type_: Nid) -> Option<MessageDigest> {
        ffi::init();
        unsafe {
            let ptr = ffi::EVP_get_digestbynid(type_.as_raw());
            if ptr.is_null() {
+2 −0
Original line number Diff line number Diff line
@@ -80,6 +80,7 @@ impl Md {
    /// Returns the `Md` corresponding to an [`Nid`].
    #[corresponds(EVP_get_digestbynid)]
    pub fn from_nid(type_: Nid) -> Option<&'static MdRef> {
        ffi::init();
        unsafe {
            let ptr = ffi::EVP_get_digestbynid(type_.as_raw());
            if ptr.is_null() {
@@ -100,6 +101,7 @@ impl Md {
        algorithm: &str,
        properties: Option<&str>,
    ) -> Result<Self, ErrorStack> {
        ffi::init();
        let algorithm = CString::new(algorithm).unwrap();
        let properties = properties.map(|s| CString::new(s).unwrap());