From 10b38a7d7ceaa2cf167489467b04b9d8c22c643b Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Mon, 13 Jun 2022 10:20:06 -0400 Subject: [PATCH] Add "accel-*" features to arti-client and arti. These need to be optional: they improve performance by shifting to asm implementations, which may not be everybody's idea of good practice. These are not 'pure' features, since they select one implementation but disable another. Therefore they don't go in `full`. Closes #441. --- Cargo.lock | 1 + crates/arti-client/Cargo.toml | 27 +++++++++++++++++++++++++-- crates/arti-client/src/lib.rs | 9 +++++++++ crates/arti/Cargo.toml | 3 +++ crates/arti/src/lib.rs | 9 +++++++++ 5 files changed, 47 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 695725121..f3b5dd54c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -166,6 +166,7 @@ dependencies = [ "tor-dirmgr", "tor-error", "tor-guardmgr", + "tor-llcrypto", "tor-netdoc", "tor-persist", "tor-proto", diff --git a/crates/arti-client/Cargo.toml b/crates/arti-client/Cargo.toml index cf1456d9d..b127aae1c 100644 --- a/crates/arti-client/Cargo.toml +++ b/crates/arti-client/Cargo.toml @@ -18,7 +18,16 @@ default = ["tokio", "native-tls"] # * Features that are testing-only # * Features which are select a particular implementation or build flag and # which therefore are not strictly additive. -full = ["tokio", "async-std", "native-tls", "rustls", "tor-rtcompat/full", "tor-proto/full", "tor-netdoc/full", "tor-dirmgr/full"] +full = [ + "tokio", + "async-std", + "native-tls", + "rustls", + "tor-rtcompat/full", + "tor-proto/full", + "tor-netdoc/full", + "tor-dirmgr/full", +] async-std = ["tor-rtcompat/async-std"] tokio = ["tor-rtcompat/tokio", "tor-proto/tokio"] @@ -29,11 +38,24 @@ static = ["static-sqlite", "static-native-tls"] static-sqlite = ["tor-dirmgr/static"] static-native-tls = ["tor-rtcompat/static", "native-tls"] +accel-sha1-asm = ["tor-llcrypto/with-sha1-asm"] +accel-openssl = ["tor-llcrypto/with-openssl"] + # Enable experimental APIs that are not yet officially supported. # # These APIs are not covered by semantic versioning. Using this # feature voids your "semver warrantee". -experimental = ["dirfilter", "experimental-api", "error_detail", "tor-proto/experimental", "tor-cell/experimental", "tor-checkable/experimental", "tor-netdoc/experimental", "tor-dirmgr/experimental", "tor-circmgr/experimental"] +experimental = [ + "dirfilter", + "experimental-api", + "error_detail", + "tor-proto/experimental", + "tor-cell/experimental", + "tor-checkable/experimental", + "tor-netdoc/experimental", + "tor-dirmgr/experimental", + "tor-circmgr/experimental", +] experimental-api = [] dirfilter = ["tor-dirmgr/dirfilter"] error_detail = [] @@ -60,6 +82,7 @@ tor-config = { path = "../tor-config", version = "0.4.0" } tor-dirmgr = { path = "../tor-dirmgr", version = "0.4.0" } tor-error = { path = "../tor-error", version = "0.3.1" } tor-guardmgr = { path = "../tor-guardmgr", version = "0.3.1" } +tor-llcrypto = { path = "../tor-llcrypto", version = "0.3.1" } tor-netdoc = { path = "../tor-netdoc", version = "0.4.0" } tor-persist = { path = "../tor-persist", version = "0.4.0" } tor-proto = { path = "../tor-proto", version = "0.3.1" } diff --git a/crates/arti-client/src/lib.rs b/crates/arti-client/src/lib.rs index 7052d5bea..c10b51bdb 100644 --- a/crates/arti-client/src/lib.rs +++ b/crates/arti-client/src/lib.rs @@ -195,6 +195,15 @@ //! * `static-native-tls` -- link with a static version of `native-tls`. Enables //! `native-tls`. //! +//! ## Cryptographic acceleration features +//! +//! Libraries should not enable these by default, since they replace one +//! implementation with another. +//! +//! * `accel-sha1-asm` -- Accelerate cryptography by using an assembly +//! implementation of SHA1, if one is available. +//! * `accel-openssl` -- Accelerate cryptography by using openssl as a backend. +//! //! ## Experimental and unstable features //! //! Note that the APIs enabled by these features are NOT covered by semantic diff --git a/crates/arti/Cargo.toml b/crates/arti/Cargo.toml index 40d849792..bcfadd6fe 100644 --- a/crates/arti/Cargo.toml +++ b/crates/arti/Cargo.toml @@ -25,6 +25,9 @@ static-sqlite = ["arti-client/static-sqlite"] static-native-tls = ["arti-client/static-native-tls", "native-tls"] journald = ["tracing-journald"] +accel-sha1-asm = ["arti-client/accel-sha1-asm"] +accel-openssl = ["arti-client/accel-openssl"] + # This feature flag enables experimental features that are not supported. Turning it on may # void your API. experimental = ["arti-client/experimental"] diff --git a/crates/arti/src/lib.rs b/crates/arti/src/lib.rs index 6af26e3df..9c37cb0ab 100644 --- a/crates/arti/src/lib.rs +++ b/crates/arti/src/lib.rs @@ -72,6 +72,15 @@ //! * `static-native-tls` -- Link with a static version of `native-tls`. Enables //! `native-tls`. //! +//! ## Cryptographic acceleration features +//! +//! Libraries should not enable these by default, since they replace one +//! implementation with another. +//! +//! * `accel-sha1-asm` -- Accelerate cryptography by using an assembly +//! implementation of SHA1, if one is available. +//! * `accel-openssl` -- Accelerate cryptography by using openssl as a backend. +//! //! ## Experimental features //! //! Note that the APIs enabled by these features are NOT covered by semantic