Commit 34766342 authored by Nick Mathewson's avatar Nick Mathewson 🥔
Browse files

Remove direct dependency on generic-array

Instead of tying ourselves to a particular version of the
generic-array crate, we now always use the version re-exported by
our RustCrypto crates.  This lets us avoid the possibility of
version mismatch.

(Originally I had planned to upgrade to generic-array 1.0, but then
I found that we were not actually using it.)
parent 1be1b161
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -4517,7 +4517,6 @@ dependencies = [
 "bytes",
 "digest 0.10.7",
 "educe",
 "generic-array",
 "getrandom 0.2.10",
 "hex-literal",
 "signature 1.6.4",
@@ -5229,7 +5228,6 @@ dependencies = [
 "digest 0.10.7",
 "educe",
 "futures",
 "generic-array",
 "hex",
 "hex-literal",
 "hkdf",
+0 −1
Original line number Diff line number Diff line
@@ -15,7 +15,6 @@ repository = "https://gitlab.torproject.org/tpo/core/arti.git/"
bytes = "1"
digest = { version = "0.10.0", features = ["subtle", "mac"] }
educe = "0.4.6"
generic-array = "0.14.3"
signature = "1"
thiserror = "1"
tor-error = { path = "../tor-error", version = "0.5.4" }
+8 −13
Original line number Diff line number Diff line
@@ -5,7 +5,6 @@
//! this is where I'm putting them.

use super::*;
use generic_array::GenericArray;

// ----------------------------------------------------------------------

@@ -47,15 +46,11 @@ impl Writeable for Vec<u8> {
    }
}

// The GenericArray type is defined to work around a limitation in Rust's
// type system.  Ideally we can get rid of GenericArray entirely at some
// point down the line.
//
// For now, we only use `GenericArray<u8>`, so that's all we'll declare, since
// it permits a faster implementation.
impl<N> Readable for GenericArray<u8, N>
// We also need to implement our traits for an older version (0.14) of
// generic_array, since that's what the digest crate uses (as of digest 0.10.)
impl<N> Readable for digest::generic_array::GenericArray<u8, N>
where
    N: generic_array::ArrayLength<u8>,
    N: digest::generic_array::ArrayLength<u8>,
{
    fn take_from(b: &mut Reader<'_>) -> Result<Self> {
        // safety -- "take" returns the requested bytes or error.
@@ -63,9 +58,9 @@ where
    }
}

impl<N> Writeable for GenericArray<u8, N>
impl<N> Writeable for digest::generic_array::GenericArray<u8, N>
where
    N: generic_array::ArrayLength<u8>,
    N: digest::generic_array::ArrayLength<u8>,
{
    fn write_onto<B: Writer + ?Sized>(&self, b: &mut B) -> EncodeResult<()> {
        b.write_all(self.as_slice());
@@ -271,7 +266,7 @@ mod digest_impls {
    }
    impl<T: OutputSizeUser> Readable for CtOutput<T> {
        fn take_from(b: &mut Reader<'_>) -> Result<Self> {
            let array = GenericArray::take_from(b)?;
            let array = digest::generic_array::GenericArray::take_from(b)?;
            Ok(CtOutput::new(array))
        }
    }
@@ -359,7 +354,7 @@ mod tests {

    #[test]
    fn genarray() {
        use generic_array as ga;
        use digest::generic_array as ga;
        let a: ga::GenericArray<u8, ga::typenum::U7> = [4, 5, 6, 7, 8, 9, 10].into();
        check_roundtrip!(ga::GenericArray<u8, ga::typenum::U7>,
                         a,
+0 −1
Original line number Diff line number Diff line
@@ -61,7 +61,6 @@ derive_more = "0.99.3"
digest = "0.10.0"
educe = "0.4.6"
futures = "0.3.14"
generic-array = "0.14.3"
hkdf = "0.12.0"
hmac = "0.12.0"
pin-project = "1"
+1 −1
Original line number Diff line number Diff line
@@ -34,7 +34,7 @@ use crate::{Error, Result};
use tor_cell::chancell::BoxedCellBody;
use tor_error::internal;

use generic_array::GenericArray;
use digest::generic_array::GenericArray;

use super::binding::CircuitBinding;

Loading