Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable SHA-3 for LibreSSL 3.8.0 #2064

Merged
merged 1 commit into from Oct 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions openssl-sys/build/cfgs.rs
Expand Up @@ -53,6 +53,9 @@ pub fn get(openssl_version: Option<u64>, libressl_version: Option<u64>) -> Vec<&
if libressl_version >= 0x3_07_00_00_0 {
cfgs.push("libressl370");
}
if libressl_version >= 0x3_08_00_00_0 {
cfgs.push("libressl380");
}
if libressl_version >= 0x3_08_01_00_0 {
cfgs.push("libressl381");
}
Expand Down
8 changes: 4 additions & 4 deletions openssl-sys/src/handwritten/evp.rs
Expand Up @@ -294,13 +294,13 @@ extern "C" {
pub fn EVP_sha256() -> *const EVP_MD;
pub fn EVP_sha384() -> *const EVP_MD;
pub fn EVP_sha512() -> *const EVP_MD;
#[cfg(ossl111)]
#[cfg(any(ossl111, libressl380))]
pub fn EVP_sha3_224() -> *const EVP_MD;
#[cfg(ossl111)]
#[cfg(any(ossl111, libressl380))]
pub fn EVP_sha3_256() -> *const EVP_MD;
#[cfg(ossl111)]
#[cfg(any(ossl111, libressl380))]
pub fn EVP_sha3_384() -> *const EVP_MD;
#[cfg(ossl111)]
#[cfg(any(ossl111, libressl380))]
pub fn EVP_sha3_512() -> *const EVP_MD;
#[cfg(ossl111)]
pub fn EVP_shake128() -> *const EVP_MD;
Expand Down
8 changes: 8 additions & 0 deletions openssl-sys/src/obj_mac.rs
Expand Up @@ -976,12 +976,20 @@ pub const NID_sm4_ctr: c_int = 1139;
pub const NID_sm4_ctr: c_int = 979;
#[cfg(ossl111)]
pub const NID_sha3_224: c_int = 1096;
#[cfg(libressl380)]
pub const NID_sha3_224: c_int = 1031;
#[cfg(ossl111)]
pub const NID_sha3_256: c_int = 1097;
#[cfg(libressl380)]
pub const NID_sha3_256: c_int = 1032;
#[cfg(ossl111)]
pub const NID_sha3_384: c_int = 1098;
#[cfg(libressl380)]
pub const NID_sha3_384: c_int = 1033;
#[cfg(ossl111)]
pub const NID_sha3_512: c_int = 1099;
#[cfg(libressl380)]
pub const NID_sha3_512: c_int = 1034;
#[cfg(ossl111)]
pub const NID_shake128: c_int = 1100;
#[cfg(ossl111)]
Expand Down
3 changes: 3 additions & 0 deletions openssl/build.rs
Expand Up @@ -66,6 +66,9 @@ fn main() {
if version >= 0x3_07_00_00_0 {
println!("cargo:rustc-cfg=libressl370");
}
if version >= 0x3_08_00_00_0 {
println!("cargo:rustc-cfg=libressl380");
}
}

if let Ok(vars) = env::var("DEP_OPENSSL_CONF") {
Expand Down
16 changes: 8 additions & 8 deletions openssl/src/hash.rs
Expand Up @@ -127,22 +127,22 @@ impl MessageDigest {
unsafe { MessageDigest(ffi::EVP_sha512()) }
}

#[cfg(ossl111)]
#[cfg(any(ossl111, libressl380))]
pub fn sha3_224() -> MessageDigest {
unsafe { MessageDigest(ffi::EVP_sha3_224()) }
}

#[cfg(ossl111)]
#[cfg(any(ossl111, libressl380))]
pub fn sha3_256() -> MessageDigest {
unsafe { MessageDigest(ffi::EVP_sha3_256()) }
}

#[cfg(ossl111)]
#[cfg(any(ossl111, libressl380))]
pub fn sha3_384() -> MessageDigest {
unsafe { MessageDigest(ffi::EVP_sha3_384()) }
}

#[cfg(ossl111)]
#[cfg(any(ossl111, libressl380))]
pub fn sha3_512() -> MessageDigest {
unsafe { MessageDigest(ffi::EVP_sha3_512()) }
}
Expand Down Expand Up @@ -624,7 +624,7 @@ mod tests {
);
}

#[cfg(ossl111)]
#[cfg(any(ossl111, libressl380))]
#[test]
fn test_sha3_224() {
let tests = [(
Expand All @@ -644,7 +644,7 @@ mod tests {
);
}

#[cfg(ossl111)]
#[cfg(any(ossl111, libressl380))]
#[test]
fn test_sha3_256() {
let tests = [(
Expand All @@ -664,7 +664,7 @@ mod tests {
);
}

#[cfg(ossl111)]
#[cfg(any(ossl111, libressl380))]
#[test]
fn test_sha3_384() {
let tests = [("416c6c20796f75722062617365206172652062656c6f6e6720746f207573",
Expand All @@ -684,7 +684,7 @@ mod tests {
);
}

#[cfg(ossl111)]
#[cfg(any(ossl111, libressl380))]
#[test]
fn test_sha3_512() {
let tests = [("416c6c20796f75722062617365206172652062656c6f6e6720746f207573",
Expand Down
8 changes: 4 additions & 4 deletions openssl/src/md.rs
Expand Up @@ -150,25 +150,25 @@ impl Md {
unsafe { MdRef::from_ptr(ffi::EVP_sha512() as *mut _) }
}

#[cfg(ossl111)]
#[cfg(any(ossl111, libressl380))]
#[inline]
pub fn sha3_224() -> &'static MdRef {
unsafe { MdRef::from_ptr(ffi::EVP_sha3_224() as *mut _) }
}

#[cfg(ossl111)]
#[cfg(any(ossl111, libressl380))]
#[inline]
pub fn sha3_256() -> &'static MdRef {
unsafe { MdRef::from_ptr(ffi::EVP_sha3_256() as *mut _) }
}

#[cfg(ossl111)]
#[cfg(any(ossl111, libressl380))]
#[inline]
pub fn sha3_384() -> &'static MdRef {
unsafe { MdRef::from_ptr(ffi::EVP_sha3_384() as *mut _) }
}

#[cfg(ossl111)]
#[cfg(any(ossl111, libressl380))]
#[inline]
pub fn sha3_512() -> &'static MdRef {
unsafe { MdRef::from_ptr(ffi::EVP_sha3_512() as *mut _) }
Expand Down
8 changes: 4 additions & 4 deletions openssl/src/nid.rs
Expand Up @@ -1078,13 +1078,13 @@ impl Nid {
pub const SM2: Nid = Nid(ffi::NID_sm2);
#[cfg(any(ossl111, libressl291))]
pub const SM3: Nid = Nid(ffi::NID_sm3);
#[cfg(ossl111)]
#[cfg(any(ossl111, libressl380))]
pub const SHA3_224: Nid = Nid(ffi::NID_sha3_224);
#[cfg(ossl111)]
#[cfg(any(ossl111, libressl380))]
pub const SHA3_256: Nid = Nid(ffi::NID_sha3_256);
#[cfg(ossl111)]
#[cfg(any(ossl111, libressl380))]
pub const SHA3_384: Nid = Nid(ffi::NID_sha3_384);
#[cfg(ossl111)]
#[cfg(any(ossl111, libressl380))]
pub const SHA3_512: Nid = Nid(ffi::NID_sha3_512);
#[cfg(ossl111)]
pub const SHAKE128: Nid = Nid(ffi::NID_shake128);
Expand Down