Add ring as optional crypto provider

This commit is contained in:
Jackson Coxson
2025-07-31 11:14:42 -06:00
parent 9f2de4d340
commit 8ee58c3502
3 changed files with 16 additions and 9 deletions

View File

@@ -13,7 +13,7 @@ keywords = ["lockdownd", "ios"]
[dependencies]
tokio = { version = "1.43", features = ["io-util"] }
tokio-rustls = "0.26"
rustls = "0.23"
rustls = { version = "0.23", default-features = false }
plist = { version = "1.7" }
serde = { version = "1", features = ["derive"] }
@@ -56,6 +56,10 @@ tun-rs = { version = "2.0.8", features = ["async_tokio"] }
bytes = "1.10.1"
[features]
default = ["aws-lc"]
aws-lc = ["rustls/aws-lc-rs"]
ring = ["rustls/ring"]
afc = ["dep:chrono"]
amfi = []
core_device = ["xpc", "dep:uuid"]

View File

@@ -390,9 +390,16 @@ impl Idevice {
pairing_file: &pairing_file::PairingFile,
) -> Result<(), IdeviceError> {
if CryptoProvider::get_default().is_none() {
if let Err(e) =
CryptoProvider::install_default(rustls::crypto::aws_lc_rs::default_provider())
{
let crypto_provider = if cfg!(feature = "ring") {
debug!("Using ring crypto backend");
rustls::crypto::ring::default_provider()
} else if cfg!(feature = "aws-lc") {
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");
};
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
// we will log it but not propogate it. An issue should be opened with rustls.