aboutsummaryrefslogtreecommitdiff
path: root/src/rust
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2018-08-23 11:30:18 -0400
committerNick Mathewson <nickm@torproject.org>2018-09-16 13:28:29 -0400
commit991bec67ee41fd7f3c12e9194d96491b51bedd50 (patch)
treeca97cfe01e65293ee523bb7e8de3c007801ea9af /src/rust
parent035166e7bf30645f6da9d39374f5e9c9efe867f8 (diff)
downloadtor-991bec67ee41fd7f3c12e9194d96491b51bedd50.tar.gz
tor-991bec67ee41fd7f3c12e9194d96491b51bedd50.zip
When Tor is compiled with NSS, don't claim support for LinkAuth=1
Closes ticket 27288
Diffstat (limited to 'src/rust')
-rw-r--r--src/rust/external/external.rs10
-rw-r--r--src/rust/protover/protover.rs38
2 files changed, 36 insertions, 12 deletions
diff --git a/src/rust/external/external.rs b/src/rust/external/external.rs
index 874c7c3153..d342fe096e 100644
--- a/src/rust/external/external.rs
+++ b/src/rust/external/external.rs
@@ -26,3 +26,13 @@ pub fn c_tor_version_as_new_as(platform: &str, cutoff: &str) -> bool {
result == 1
}
+
+extern "C" {
+ fn tor_is_using_nss() -> c_int;
+}
+
+/// Return true if Tor was built to use NSS.
+pub fn c_tor_is_using_nss() -> bool
+{
+ 0 != unsafe { tor_is_using_nss() }
+}
diff --git a/src/rust/protover/protover.rs b/src/rust/protover/protover.rs
index 6fbe7c5dc1..7b3f808cb2 100644
--- a/src/rust/protover/protover.rs
+++ b/src/rust/protover/protover.rs
@@ -10,6 +10,7 @@ use std::str::FromStr;
use std::string::String;
use external::c_tor_version_as_new_as;
+use external::c_tor_is_using_nss;
use errors::ProtoverError;
use protoset::ProtoSet;
@@ -141,18 +142,31 @@ impl From<Protocol> for UnknownProtocol {
///
// C_RUST_COUPLED: protover.c `protover_get_supported_protocols`
pub(crate) fn get_supported_protocols_cstr() -> &'static CStr {
- cstr!(
- "Cons=1-2 \
- Desc=1-2 \
- DirCache=1-2 \
- HSDir=1-2 \
- HSIntro=3-4 \
- HSRend=1-2 \
- Link=1-5 \
- LinkAuth=1,3 \
- Microdesc=1-2 \
- Relay=1-2"
- )
+ if c_tor_is_using_nss() {
+ cstr!("Cons=1-2 \
+ Desc=1-2 \
+ DirCache=1-2 \
+ HSDir=1-2 \
+ HSIntro=3-4 \
+ HSRend=1-2 \
+ Link=1-5 \
+ LinkAuth=3 \
+ Microdesc=1-2 \
+ Relay=1-2"
+ )
+ } else {
+ cstr!("Cons=1-2 \
+ Desc=1-2 \
+ DirCache=1-2 \
+ HSDir=1-2 \
+ HSIntro=3-4 \
+ HSRend=1-2 \
+ Link=1-5 \
+ LinkAuth=1,3 \
+ Microdesc=1-2 \
+ Relay=1-2"
+ )
+ }
}
/// A map of protocol names to the versions of them which are supported.