mirror of
https://github.com/jkcoxson/idevice.git
synced 2026-03-02 06:26:15 +01:00
Conditionally compile crypto backend
This commit is contained in:
@@ -5,7 +5,7 @@ edition = "2024"
|
||||
|
||||
|
||||
[dependencies]
|
||||
idevice = { path = "../idevice" }
|
||||
idevice = { path = "../idevice", default-features = false }
|
||||
log = "0.4.26"
|
||||
simplelog = "0.12.2"
|
||||
once_cell = "1.21.1"
|
||||
@@ -15,6 +15,10 @@ plist = "1.7.1"
|
||||
plist_ffi = "0.1.3"
|
||||
|
||||
[features]
|
||||
aws-lc = ["idevice/aws-lc"]
|
||||
ring = ["idevice/ring"]
|
||||
|
||||
|
||||
afc = ["idevice/afc"]
|
||||
amfi = ["idevice/amfi"]
|
||||
core_device = ["idevice/core_device"]
|
||||
@@ -64,7 +68,7 @@ full = [
|
||||
"springboardservices",
|
||||
"syslog_relay",
|
||||
]
|
||||
default = ["full"]
|
||||
default = ["full", "aws-lc"]
|
||||
|
||||
[build-dependencies]
|
||||
cbindgen = "0.29.0"
|
||||
|
||||
@@ -390,15 +390,34 @@ impl Idevice {
|
||||
pairing_file: &pairing_file::PairingFile,
|
||||
) -> Result<(), IdeviceError> {
|
||||
if CryptoProvider::get_default().is_none() {
|
||||
let crypto_provider = if cfg!(feature = "ring") {
|
||||
let crypto_provider = {
|
||||
#[cfg(all(feature = "ring", not(feature = "aws-lc")))]
|
||||
{
|
||||
debug!("Using ring crypto backend");
|
||||
rustls::crypto::ring::default_provider()
|
||||
} else if cfg!(feature = "aws-lc") {
|
||||
}
|
||||
|
||||
#[cfg(all(feature = "aws-lc", not(feature = "ring")))]
|
||||
{
|
||||
debug!("Using aws-lc crypto backend");
|
||||
rustls::crypto::aws_lc_rs::default_provider()
|
||||
} else {
|
||||
panic!("No crypto provider compiled in! Use one of the features for idevice to specify a provider");
|
||||
}
|
||||
|
||||
#[cfg(not(any(feature = "ring", feature = "aws-lc")))]
|
||||
{
|
||||
panic!(
|
||||
"No crypto backend was selected! Specify an idevice feature for a crypto backend"
|
||||
);
|
||||
}
|
||||
|
||||
#[cfg(all(feature = "ring", feature = "aws-lc"))]
|
||||
{
|
||||
compile_error!(
|
||||
"Cannot enable both `ring` and `aws-lc` features at the same time"
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
if let Err(e) = CryptoProvider::install_default(crypto_provider) {
|
||||
// For whatever reason, getting the default provider will return None on iOS at
|
||||
// random. Installing the default provider a second time will return an error, so
|
||||
|
||||
@@ -94,7 +94,7 @@ name = "restore_service"
|
||||
path = "src/restore_service.rs"
|
||||
|
||||
[dependencies]
|
||||
idevice = { path = "../idevice", features = ["full"] }
|
||||
idevice = { path = "../idevice", features = ["full"], default-features = false }
|
||||
tokio = { version = "1.43", features = ["full"] }
|
||||
log = { version = "0.4" }
|
||||
env_logger = { version = "0.11" }
|
||||
@@ -105,3 +105,8 @@ clap = { version = "4.5" }
|
||||
plist = { version = "1.7" }
|
||||
ns-keyed-archive = "0.1.2"
|
||||
uuid = "1.16"
|
||||
|
||||
[features]
|
||||
default = ["aws-lc"]
|
||||
aws-lc = ["idevice/aws-lc"]
|
||||
ring = ["idevice/ring"]
|
||||
|
||||
Reference in New Issue
Block a user