Skip to content

Commit

Permalink
Initialize OpenSSL in MD constructors
Browse files Browse the repository at this point in the history
  • Loading branch information
sfackler committed Jul 6, 2024
1 parent c38bc2f commit 9de3794
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 9de3794

Please sign in to comment.