From 7a674957fbfea4d2847c393d4e4faf32b67287f9 Mon Sep 17 00:00:00 2001
From: Alex Gaynor <alex.gaynor@gmail.com>
Date: Sat, 1 Feb 2025 12:08:33 -0800
Subject: [PATCH] Turn openssl-sys into a workspace dep

Annoyingly matching is done on the crate name, not the package name, so renaming a workspace dep doesn't work.
---
 Cargo.toml                                    | 1 +
 src/rust/Cargo.toml                           | 2 +-
 src/rust/cryptography-cffi/Cargo.toml         | 2 +-
 src/rust/cryptography-key-parsing/Cargo.toml  | 2 +-
 src/rust/cryptography-openssl/Cargo.toml      | 2 +-
 src/rust/cryptography-openssl/src/aead.rs     | 2 ++
 src/rust/cryptography-openssl/src/cmac.rs     | 1 +
 src/rust/cryptography-openssl/src/fips.rs     | 3 +++
 src/rust/cryptography-openssl/src/hmac.rs     | 2 ++
 src/rust/cryptography-openssl/src/poly1305.rs | 2 ++
 10 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/Cargo.toml b/Cargo.toml
index d3cef03c573b..08c52964aa1c 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -23,6 +23,7 @@ rust-version = "1.65.0"
 asn1 = { version = "0.20.0", default-features = false }
 pyo3 = { version = "0.23.4", features = ["abi3"] }
 openssl = "0.10.69"
+openssl-sys = "0.9.104"
 
 [profile.release]
 overflow-checks = true
diff --git a/src/rust/Cargo.toml b/src/rust/Cargo.toml
index b69da58de5ef..f9aa957882f7 100644
--- a/src/rust/Cargo.toml
+++ b/src/rust/Cargo.toml
@@ -20,7 +20,7 @@ cryptography-x509-verification = { path = "cryptography-x509-verification" }
 cryptography-openssl = { path = "cryptography-openssl" }
 pem = { version = "3", default-features = false }
 openssl.workspace = true
-openssl-sys = "0.9.104"
+openssl-sys.workspace = true
 foreign-types-shared = "0.1"
 self_cell = "1"
 
diff --git a/src/rust/cryptography-cffi/Cargo.toml b/src/rust/cryptography-cffi/Cargo.toml
index 09c6ee5849c9..7396a5100255 100644
--- a/src/rust/cryptography-cffi/Cargo.toml
+++ b/src/rust/cryptography-cffi/Cargo.toml
@@ -8,7 +8,7 @@ rust-version.workspace = true
 
 [dependencies]
 pyo3.workspace = true
-openssl-sys = "0.9.104"
+openssl-sys.workspace = true
 
 [build-dependencies]
 cc = "1.2.10"
diff --git a/src/rust/cryptography-key-parsing/Cargo.toml b/src/rust/cryptography-key-parsing/Cargo.toml
index df727ca2e8a2..255ef408716e 100644
--- a/src/rust/cryptography-key-parsing/Cargo.toml
+++ b/src/rust/cryptography-key-parsing/Cargo.toml
@@ -10,7 +10,7 @@ rust-version.workspace = true
 asn1.workspace = true
 cfg-if = "1"
 openssl.workspace = true
-openssl-sys = "0.9.104"
+openssl-sys.workspace = true
 cryptography-x509 = { path = "../cryptography-x509" }
 
 [lints.rust]
diff --git a/src/rust/cryptography-openssl/Cargo.toml b/src/rust/cryptography-openssl/Cargo.toml
index 6e2589a57bbe..fce1fdd327ad 100644
--- a/src/rust/cryptography-openssl/Cargo.toml
+++ b/src/rust/cryptography-openssl/Cargo.toml
@@ -9,7 +9,7 @@ rust-version.workspace = true
 [dependencies]
 cfg-if = "1"
 openssl.workspace = true
-ffi = { package = "openssl-sys", version = "0.9.101" }
+openssl-sys.workspace = true
 foreign-types = "0.3"
 foreign-types-shared = "0.1"
 
diff --git a/src/rust/cryptography-openssl/src/aead.rs b/src/rust/cryptography-openssl/src/aead.rs
index aca3f0f64da2..4c819282150c 100644
--- a/src/rust/cryptography-openssl/src/aead.rs
+++ b/src/rust/cryptography-openssl/src/aead.rs
@@ -2,6 +2,8 @@
 // 2.0, and the BSD License. See the LICENSE file in the root of this repository
 // for complete details.
 
+use openssl_sys as ffi;
+
 use crate::{cvt, cvt_p, OpenSSLResult};
 use foreign_types_shared::{ForeignType, ForeignTypeRef};
 
diff --git a/src/rust/cryptography-openssl/src/cmac.rs b/src/rust/cryptography-openssl/src/cmac.rs
index 2f4d22653111..e93790d874ea 100644
--- a/src/rust/cryptography-openssl/src/cmac.rs
+++ b/src/rust/cryptography-openssl/src/cmac.rs
@@ -5,6 +5,7 @@
 use std::ptr;
 
 use foreign_types_shared::{ForeignType, ForeignTypeRef};
+use openssl_sys as ffi;
 
 use crate::hmac::DigestBytes;
 use crate::{cvt, cvt_p, OpenSSLResult};
diff --git a/src/rust/cryptography-openssl/src/fips.rs b/src/rust/cryptography-openssl/src/fips.rs
index b14d2a5a659d..21a8207d4bf4 100644
--- a/src/rust/cryptography-openssl/src/fips.rs
+++ b/src/rust/cryptography-openssl/src/fips.rs
@@ -2,6 +2,9 @@
 // 2.0, and the BSD License. See the LICENSE file in the root of this repository
 // for complete details.
 
+#[cfg(not(any(CRYPTOGRAPHY_IS_LIBRESSL, CRYPTOGRAPHY_IS_BORINGSSL)))]
+use openssl_sys as ffi;
+
 #[cfg(CRYPTOGRAPHY_OPENSSL_300_OR_GREATER)]
 use crate::{cvt, OpenSSLResult};
 #[cfg(all(
diff --git a/src/rust/cryptography-openssl/src/hmac.rs b/src/rust/cryptography-openssl/src/hmac.rs
index 64abf83d40ae..bceee2bf8dca 100644
--- a/src/rust/cryptography-openssl/src/hmac.rs
+++ b/src/rust/cryptography-openssl/src/hmac.rs
@@ -5,6 +5,7 @@
 use std::ptr;
 
 use foreign_types_shared::{ForeignType, ForeignTypeRef};
+use openssl_sys as ffi;
 
 use crate::{cvt, cvt_p, OpenSSLResult};
 
@@ -92,6 +93,7 @@ impl std::ops::Deref for DigestBytes {
 #[cfg(test)]
 mod tests {
     use super::DigestBytes;
+    use openssl_sys as ffi;
 
     #[test]
     fn test_digest_bytes() {
diff --git a/src/rust/cryptography-openssl/src/poly1305.rs b/src/rust/cryptography-openssl/src/poly1305.rs
index e386bc2d7f4a..d19141a4261c 100644
--- a/src/rust/cryptography-openssl/src/poly1305.rs
+++ b/src/rust/cryptography-openssl/src/poly1305.rs
@@ -4,6 +4,8 @@
 
 use std::mem::MaybeUninit;
 
+use openssl_sys as ffi;
+
 pub struct Poly1305State {
     // The state data must be allocated in the heap so that its address does not change. This is
     // because BoringSSL APIs that take a `poly1305_state*` ignore all the data before an aligned