diff options
author | Steven Fackler <sfackler@gmail.com> | 2021-03-08 21:14:29 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-08 21:14:29 -0500 |
commit | ff94c7f5030a0fa012a37e76cd2fa2d8896360dc (patch) | |
tree | ae3b8a36ac7f52c7414cd9fd72af9f5a047d903b /openssl/src/hash.rs | |
parent | ad741f88f2136a82c0557179fb420cd6283b610a (diff) | |
parent | fb5f94e0346135540dab354311f31561d84a5dee (diff) | |
download | rust-openssl-master.zip |
Add sm3 cryptographic hash support
Diffstat (limited to 'openssl/src/hash.rs')
-rw-r--r-- | openssl/src/hash.rs | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/openssl/src/hash.rs b/openssl/src/hash.rs index 317d20e2..666022c7 100644 --- a/openssl/src/hash.rs +++ b/openssl/src/hash.rs @@ -128,6 +128,11 @@ impl MessageDigest { unsafe { MessageDigest(ffi::EVP_ripemd160()) } } + #[cfg(all(any(ossl111, libressl291), not(osslconf = "OPENSSL_NO_SM3")))] + pub fn sm3() -> MessageDigest { + unsafe { MessageDigest(ffi::EVP_sm3()) } + } + #[allow(clippy::trivially_copy_pass_by_ref)] pub fn as_ptr(&self) -> *const ffi::EVP_MD { self.0 @@ -626,6 +631,19 @@ mod tests { } } + #[cfg(all(any(ossl111, libressl291), not(osslconf = "OPENSSL_NO_SM3")))] + #[test] + fn test_sm3() { + let tests = [( + "616263", + "66c7f0f462eeedd9d1f2d46bdc10e4e24167c4875cf2f7a2297da02b8f4ba8e0", + )]; + + for test in tests.iter() { + hash_test(MessageDigest::sm3(), test); + } + } + #[test] fn from_nid() { assert_eq!( |