mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-07-31 00:41:59 +00:00
Remove the ring override (#227)
This commit is contained in:
@@ -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" }
|
||||
|
@@ -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" }
|
||||
|
@@ -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");
|
||||
|
@@ -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";
|
||||
|
Reference in New Issue
Block a user