Skip to content

Commit 96fcab3

Browse files
committed
Switch to OpenSSL instead of crypto API
macOS before 10.7 requires to use OpenSSL because a lot of things is simple missed.
1 parent 8cb2833 commit 96fcab3

File tree

13 files changed

+55
-7
lines changed

13 files changed

+55
-7
lines changed

src/libstd/build.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ mod legacy_bootstrap_helper;
55

66
fn main() {
77
legacy_bootstrap_helper::insert_cargo_features();
8-
98
let target = env::var("TARGET").expect("TARGET was not set");
109
if target.contains("linux") {
1110
if target.contains("android") {

src/tools/cargo/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,3 +115,4 @@ doc = false
115115
deny-warnings = []
116116
vendored-openssl = ['openssl/vendored']
117117
pretty-env-logger = ['pretty_env_logger']
118+
macos_before_10_7 = []

vendor/commoncrypto-sys/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ license = "MIT"
1010

1111
[features]
1212
lint = ["clippy"]
13+
macos_before_10_7 = []
1314

1415
[dependencies]
1516
libc = "0.2"

vendor/commoncrypto-sys/build.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#[path = "../../src/tools/legacy-bootstrap/helper.rs"]
2+
mod legacy_bootstrap_helper;
3+
4+
fn main() {
5+
legacy_bootstrap_helper::insert_cargo_features();
6+
}

vendor/commoncrypto-sys/src/lib.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,33 +197,45 @@ extern "C" {
197197
/// Generates SHA512 hash. See `man 3cc CC_SHA` for details.
198198
pub fn CC_SHA512_Final(md: *mut u8, ctx: *mut CC_SHA512_CTX) -> c_int;
199199
/// Generic digest hasher.
200+
#[cfg(not(feature = "macos_before_10_7"))]
200201
pub fn CCDigest(algorithm: CCDigestAlgorithm,
201202
data: *const u8,
202203
length: usize,
203204
output: *mut u8)
204205
-> c_int;
205206
/// Allocate and initialize a `CCDigestCtx` for a digest.
207+
#[cfg(not(feature = "macos_before_10_7"))]
206208
pub fn CCDigestCreate(algorithm: CCDigestAlgorithm) -> *mut CCDigestCtx;
207209
/// Continue to digest data. Returns `0` on success.
210+
#[cfg(not(feature = "macos_before_10_7"))]
208211
pub fn CCDigestUpdate(ctx: *mut CCDigestCtx, data: *const u8, length: usize) -> c_int;
209212
/// Conclude digest operations and produce the digest output. Returns `0` on success.
213+
#[cfg(not(feature = "macos_before_10_7"))]
210214
pub fn CCDigestFinal(ctx: *mut CCDigestCtx, output: *mut u8) -> c_int;
211215
/// Clear and free a `CCDigestCtx`.
216+
#[cfg(not(feature = "macos_before_10_7"))]
212217
pub fn CCDigestDestroy(ctx: *mut CCDigestCtx);
213218
/// Clear and re-initialize a `CCDigestCtx` for the same algorithm.
219+
#[cfg(not(feature = "macos_before_10_7"))]
214220
pub fn CCDigestReset(ctx: *mut CCDigestCtx);
215221
/// Produce the digest output result for the bytes currently processed. Returns `0` on success.
222+
#[cfg(not(feature = "macos_before_10_7"))]
216223
pub fn CCDigestGetDigest(ctx: *mut CCDigestCtx, output: *mut u8) -> c_int;
217224
/// Provides the block size of the digest algorithm. Returns `0` on failure.
225+
#[cfg(not(feature = "macos_before_10_7"))]
218226
pub fn CCDigestGetBlockSize(algorithm: CCDigestAlgorithm) -> usize;
219227
/// Provides the digest output size of the digest algorithm. Returns `0` on failure.
228+
#[cfg(not(feature = "macos_before_10_7"))]
220229
pub fn CCDigestGetOutputSize(algorithm: CCDigestAlgorithm) -> usize;
221230
/// Provides the block size of the digest algorithm. Returns `0` on failure.
231+
#[cfg(not(feature = "macos_before_10_7"))]
222232
pub fn CCDigestGetBlockSizeFromRef(ctx: *mut CCDigestCtx) -> usize;
223233
/// Provides the digest output size of the digest algorithm. Returns `0` on failure.
234+
#[cfg(not(feature = "macos_before_10_7"))]
224235
pub fn CCDigestGetOutputSizeFromRef(ctx: *mut CCDigestCtx) -> usize;
225236

226237
/// Derive a key from a user-supplied password via PBKDF2.
238+
#[cfg(not(feature = "macos_before_10_7"))]
227239
pub fn CCKeyDerivationPBKDF(algorithm: CCPBKDFAlgorithm,
228240
password: *const u8,
229241
passwordLen: usize,

vendor/commoncrypto/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ license = "MIT"
1010

1111
[features]
1212
lint = ["clippy"]
13+
macos_before_10_7 = []
1314

1415
[dependencies]
1516
commoncrypto-sys = { version = "0.2.0", path = "../commoncrypto-sys" }

vendor/commoncrypto/build.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#[path = "../../src/tools/legacy-bootstrap/helper.rs"]
2+
mod legacy_bootstrap_helper;
3+
4+
fn main() {
5+
legacy_bootstrap_helper::insert_cargo_features();
6+
}

vendor/commoncrypto/src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,12 @@
2222
2323
#![warn(missing_docs)]
2424

25+
#[cfg(not(feature = "macos_before_10_7"))]
2526
extern crate commoncrypto_sys;
2627

2728
#[warn(missing_docs)]
29+
#[cfg(not(feature = "macos_before_10_7"))]
2830
pub mod hash;
2931
#[warn(missing_docs)]
32+
#[cfg(not(feature = "macos_before_10_7"))]
3033
pub mod pbkdf2;

vendor/crypto-hash/Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,11 @@ readme = "README.md"
2121
keywords = ["crypto", "hash", "digest"]
2222
license = "MIT"
2323
repository = "https://github.com/malept/crypto-hash"
24+
[features]
25+
macos_before_10_7 = []
2426
[dependencies.hex]
2527
version = "0.3"
26-
[target."cfg(not(any(target_os = \"windows\", target_os = \"macos\")))".dependencies.openssl]
28+
[target."cfg(not(any(target_os = \"windows\")))".dependencies.openssl]
2729
version = "0.10"
2830
[target."cfg(target_os = \"macos\")".dependencies.commoncrypto]
2931
version = "0.2"

vendor/crypto-hash/build.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#[path = "../../src/tools/legacy-bootstrap/helper.rs"]
2+
mod legacy_bootstrap_helper;
3+
4+
fn main() {
5+
legacy_bootstrap_helper::insert_cargo_features();
6+
}

0 commit comments

Comments
 (0)