Remove the ring override (#227)

This commit is contained in:
Pierre Krieger
2018-05-31 14:24:49 +02:00
committed by GitHub
parent 6b95414161
commit 2a2ad77d28
4 changed files with 12 additions and 7 deletions

View File

@@ -22,8 +22,6 @@ members = [
]
[patch.crates-io]
# TODO: Update ring and solve conflicts
"ring" = { git = "https://github.com/briansmith/ring", rev = "3a14ef619559f7d4b69e2286d49c833409eef34a" }
# Using a version of rust-multihash that compiles on emscripten
# TODO: remove once merged upstream
"multihash" = { git = "https://github.com/tomaka/rust-multihash", branch = "emscripten-hack" }

View File

@@ -14,7 +14,7 @@ ring = { version = "0.12.1", features = ["rsa_signing"] }
rust-crypto = "^0.2"
rw-stream-sink = { path = "../rw-stream-sink" }
tokio-io = "0.1.0"
untrusted = "0.6.0"
untrusted = "0.5.1"
[dev-dependencies]
libp2p-tcp-transport = { path = "../tcp-transport" }

View File

@@ -42,6 +42,8 @@ use ring::hmac;
pub struct DecoderMiddleware<S> {
cipher_state: Box<SynchronousStreamCipher>,
hmac_key: hmac::VerificationKey,
// TODO: when a new version of ring is released, we can use `hmac_key.digest_algorithm().output_len` instead
hmac_num_bytes: usize,
raw_stream: S,
}
@@ -51,11 +53,13 @@ impl<S> DecoderMiddleware<S> {
raw_stream: S,
cipher: Box<SynchronousStreamCipher>,
hmac_key: hmac::VerificationKey,
hmac_num_bytes: usize, // TODO: remove this parameter
) -> DecoderMiddleware<S> {
DecoderMiddleware {
cipher_state: cipher,
hmac_key: hmac_key,
raw_stream: raw_stream,
hmac_key,
raw_stream,
hmac_num_bytes,
}
}
}
@@ -77,7 +81,8 @@ where
Err(err) => return Err(err.into()),
};
let hmac_num_bytes = self.hmac_key.digest_algorithm().output_len;
// TODO: when a new version of ring is released, we can use `hmac_key.digest_algorithm().output_len` instead
let hmac_num_bytes = self.hmac_num_bytes;
if frame.len() < hmac_num_bytes {
debug!("frame too short when decoding secio frame");

View File

@@ -50,8 +50,9 @@ pub fn full_codec<S>(
where
S: AsyncRead + AsyncWrite,
{
let hmac_num_bytes = encoding_hmac.digest_algorithm().output_len;
let encoder = EncoderMiddleware::new(socket, cipher_encoding, encoding_hmac);
let codec = DecoderMiddleware::new(encoder, cipher_decoder, decoding_hmac);
let codec = DecoderMiddleware::new(encoder, cipher_decoder, decoding_hmac, hmac_num_bytes);
codec
}
@@ -102,6 +103,7 @@ mod tests {
vec![0; 16],
)),
VerificationKey::new(&SHA256, &hmac_key),
32,
);
let data = b"hello world";