Skip to content

Commit

Permalink
Merge pull request #2258 from sfackler/init-md
Browse files Browse the repository at this point in the history
Initialize OpenSSL in MD constructors
  • Loading branch information
sfackler authored Jul 6, 2024
2 parents c38bc2f + 9de3794 commit 22ffa9a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions openssl/src/hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
2 changes: 2 additions & 0 deletions openssl/src/md.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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());

Expand Down

0 comments on commit 22ffa9a

Please sign in to comment.