Stop re-exporting traits from tor-llcrypto. It does not help.

This commit is contained in:
Nick Mathewson 2020-05-08 00:18:39 -04:00
parent dd17ba05d0
commit 3c7f75302b
8 changed files with 9 additions and 18 deletions

View File

@ -9,10 +9,6 @@
//! Encryption is implemented in `cipher`, digests are in `d`, and //! Encryption is implemented in `cipher`, digests are in `d`, and
//! public key cryptography (including signatures, encryption, and key //! public key cryptography (including signatures, encryption, and key
//! agreement) are in `pk`. //! 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 // TODO -- the long-term intention here is that this functionality
// should be replaceable at compile time with other implementations. // should be replaceable at compile time with other implementations.
@ -20,4 +16,3 @@
pub mod cipher; pub mod cipher;
pub mod d; pub mod d;
pub mod pk; pub mod pk;
pub mod traits;

View File

@ -1,5 +1,5 @@
use crate::pk; use crate::pk;
use crate::traits::Digest; use digest::Digest;
use zeroize::Zeroizing; use zeroize::Zeroizing;
/// Convert a curve25519 public key (with sign bit) to an ed25519 /// Convert a curve25519 public key (with sign bit) to an ed25519

View File

@ -141,7 +141,7 @@ impl PublicKey {
/// Compute the RSAIdentity for this public key. /// Compute the RSAIdentity for this public key.
pub fn to_rsa_identity(&self) -> RSAIdentity { pub fn to_rsa_identity(&self) -> RSAIdentity {
use crate::d::Sha1; use crate::d::Sha1;
use crate::traits::Digest; use digest::Digest;
let id = Sha1::digest(&self.to_der()).into(); let id = Sha1::digest(&self.to_der()).into();
RSAIdentity { id } RSAIdentity { id }
} }

View File

@ -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};

View File

@ -1,4 +1,6 @@
use digest::Digest;
use hex_literal::hex; use hex_literal::hex;
use stream_cipher::{NewStreamCipher, StreamCipher};
use tor_llcrypto as ll; use tor_llcrypto as ll;
#[test] #[test]
@ -124,7 +126,6 @@ fn tv_aes128_ctr() {
// From NIST Special Publication 800-38A. // From NIST Special Publication 800-38A.
// https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38a.pdf // https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38a.pdf
use ll::cipher::aes::Aes128Ctr; use ll::cipher::aes::Aes128Ctr;
use ll::traits::{NewStreamCipher, StreamCipher};
let k1 = hex!("2b7e151628aed2a6abf7158809cf4f3c").into(); let k1 = hex!("2b7e151628aed2a6abf7158809cf4f3c").into();
let ctr1 = hex!("f0f1f2f3f4f5f6f7f8f9fafbfcfdfeff").into(); let ctr1 = hex!("f0f1f2f3f4f5f6f7f8f9fafbfcfdfeff").into();
@ -156,7 +157,6 @@ fn tv_aes256_ctr() {
// https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38a.pdf // https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38a.pdf
use ll::cipher::aes::Aes256Ctr; use ll::cipher::aes::Aes256Ctr;
use ll::traits::{NewStreamCipher, StreamCipher};
let k1 = hex!( let k1 = hex!(
"603deb1015ca71be2b73aef0857d7781 "603deb1015ca71be2b73aef0857d7781
@ -190,7 +190,6 @@ fn tv_aes256_ctr() {
fn tv_sha1() { fn tv_sha1() {
// From RFC 3174, extracted from the example C code. // From RFC 3174, extracted from the example C code.
use ll::d::Sha1; use ll::d::Sha1;
use ll::traits::Digest;
fn run_test(inp: &[u8], repeatcount: usize, expect: &[u8]) { fn run_test(inp: &[u8], repeatcount: usize, expect: &[u8]) {
let mut d = Sha1::new(); let mut d = Sha1::new();

View File

@ -11,6 +11,7 @@ tor-llcrypto = { path="../tor-llcrypto", version="*" }
tor-cert = { path="../tor-cert", version="*" } tor-cert = { path="../tor-cert", version="*" }
tor-protover = { path="../tor-protover", version= "*" } tor-protover = { path="../tor-protover", version= "*" }
digest = "*"
phf = { version = "*", features = ["macros"] } phf = { version = "*", features = ["macros"] }
hex = "*" hex = "*"
lazy_static = "*" lazy_static = "*"

View File

@ -12,7 +12,7 @@ use std::{net, time};
use tor_llcrypto as ll; use tor_llcrypto as ll;
use tor_llcrypto::pk::rsa::RSAIdentity; use tor_llcrypto::pk::rsa::RSAIdentity;
use ll::traits::Digest; use digest::Digest;
pub struct RouterDesc { pub struct RouterDesc {
nickname: String, nickname: String,

View File

@ -11,18 +11,18 @@ tor-llcrypto = { path="../tor-llcrypto" }
tor-bytes = { path="../tor-bytes" } tor-bytes = { path="../tor-bytes" }
arrayref = "*" arrayref = "*"
rand = "*"
digest = "*" digest = "*"
rand = "*"
typenum = "*" typenum = "*"
# XXXX why did I have to downgrade? # XXXX why did I have to downgrade?
generic-array = "0.12" generic-array = "0.12"
stream-cipher = "*"
rand_core = "*" rand_core = "*"
crypto-mac = "*" crypto-mac = "*"
hmac = "*" hmac = "*"
hkdf = "*" hkdf = "*"
zeroize = "*" zeroize = "*"
subtle = "2.2.2" subtle = "*"
stream-cipher = "*"
[dev-dependencies] [dev-dependencies]
hex-literal = "*" hex-literal = "*"