diff --git a/tor-llcrypto/src/lib.rs b/tor-llcrypto/src/lib.rs index 46f85444b..48e1f7863 100644 --- a/tor-llcrypto/src/lib.rs +++ b/tor-llcrypto/src/lib.rs @@ -9,10 +9,6 @@ //! Encryption is implemented in `cipher`, digests are in `d`, and //! public key cryptography (including signatures, encryption, and key //! agreement) are in `pk`. -//! -//! When possible, everything here should be accessed via traits. -//! We're using traits from the rust-crypto project, as -//! re-exported from the traits module. // TODO -- the long-term intention here is that this functionality // should be replaceable at compile time with other implementations. @@ -20,4 +16,3 @@ pub mod cipher; pub mod d; pub mod pk; -pub mod traits; diff --git a/tor-llcrypto/src/pk/keymanip.rs b/tor-llcrypto/src/pk/keymanip.rs index 98bb333a1..22f2c38f6 100644 --- a/tor-llcrypto/src/pk/keymanip.rs +++ b/tor-llcrypto/src/pk/keymanip.rs @@ -1,5 +1,5 @@ use crate::pk; -use crate::traits::Digest; +use digest::Digest; use zeroize::Zeroizing; /// Convert a curve25519 public key (with sign bit) to an ed25519 diff --git a/tor-llcrypto/src/pk/rsa.rs b/tor-llcrypto/src/pk/rsa.rs index 5cc0ffe28..0a2eda508 100644 --- a/tor-llcrypto/src/pk/rsa.rs +++ b/tor-llcrypto/src/pk/rsa.rs @@ -141,7 +141,7 @@ impl PublicKey { /// Compute the RSAIdentity for this public key. pub fn to_rsa_identity(&self) -> RSAIdentity { use crate::d::Sha1; - use crate::traits::Digest; + use digest::Digest; let id = Sha1::digest(&self.to_der()).into(); RSAIdentity { id } } diff --git a/tor-llcrypto/src/traits.rs b/tor-llcrypto/src/traits.rs deleted file mode 100644 index 434ffa92f..000000000 --- a/tor-llcrypto/src/traits.rs +++ /dev/null @@ -1,4 +0,0 @@ -//! Re-export the traits that we expect other code to use. - -pub use digest::Digest; -pub use stream_cipher::{NewStreamCipher, StreamCipher}; diff --git a/tor-llcrypto/tests/testvec.rs b/tor-llcrypto/tests/testvec.rs index 0b36736bb..4fc43dc8a 100644 --- a/tor-llcrypto/tests/testvec.rs +++ b/tor-llcrypto/tests/testvec.rs @@ -1,4 +1,6 @@ +use digest::Digest; use hex_literal::hex; +use stream_cipher::{NewStreamCipher, StreamCipher}; use tor_llcrypto as ll; #[test] @@ -124,7 +126,6 @@ fn tv_aes128_ctr() { // From NIST Special Publication 800-38A. // https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38a.pdf use ll::cipher::aes::Aes128Ctr; - use ll::traits::{NewStreamCipher, StreamCipher}; let k1 = hex!("2b7e151628aed2a6abf7158809cf4f3c").into(); let ctr1 = hex!("f0f1f2f3f4f5f6f7f8f9fafbfcfdfeff").into(); @@ -156,7 +157,6 @@ fn tv_aes256_ctr() { // https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38a.pdf use ll::cipher::aes::Aes256Ctr; - use ll::traits::{NewStreamCipher, StreamCipher}; let k1 = hex!( "603deb1015ca71be2b73aef0857d7781 @@ -190,7 +190,6 @@ fn tv_aes256_ctr() { fn tv_sha1() { // From RFC 3174, extracted from the example C code. use ll::d::Sha1; - use ll::traits::Digest; fn run_test(inp: &[u8], repeatcount: usize, expect: &[u8]) { let mut d = Sha1::new(); diff --git a/tor-netdoc/Cargo.toml b/tor-netdoc/Cargo.toml index f60331d4d..6ed64210d 100644 --- a/tor-netdoc/Cargo.toml +++ b/tor-netdoc/Cargo.toml @@ -11,6 +11,7 @@ tor-llcrypto = { path="../tor-llcrypto", version="*" } tor-cert = { path="../tor-cert", version="*" } tor-protover = { path="../tor-protover", version= "*" } +digest = "*" phf = { version = "*", features = ["macros"] } hex = "*" lazy_static = "*" diff --git a/tor-netdoc/src/routerdesc.rs b/tor-netdoc/src/routerdesc.rs index 564fc1090..db1fb4585 100644 --- a/tor-netdoc/src/routerdesc.rs +++ b/tor-netdoc/src/routerdesc.rs @@ -12,7 +12,7 @@ use std::{net, time}; use tor_llcrypto as ll; use tor_llcrypto::pk::rsa::RSAIdentity; -use ll::traits::Digest; +use digest::Digest; pub struct RouterDesc { nickname: String, diff --git a/tor-proto/Cargo.toml b/tor-proto/Cargo.toml index 71a8a33c3..f49546dee 100644 --- a/tor-proto/Cargo.toml +++ b/tor-proto/Cargo.toml @@ -11,18 +11,18 @@ tor-llcrypto = { path="../tor-llcrypto" } tor-bytes = { path="../tor-bytes" } arrayref = "*" -rand = "*" digest = "*" +rand = "*" typenum = "*" # XXXX why did I have to downgrade? generic-array = "0.12" -stream-cipher = "*" rand_core = "*" crypto-mac = "*" hmac = "*" hkdf = "*" zeroize = "*" -subtle = "2.2.2" +subtle = "*" +stream-cipher = "*" [dev-dependencies] hex-literal = "*"