From: Jason Ish Date: Wed, 23 Dec 2020 04:27:26 +0000 (-0600) Subject: rust/ssh: use md-5 crate instead of md5 X-Git-Tag: suricata-7.0.0-beta1~1901 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0a2d8509c966bb9504487b8a81926e02bcf949b8;p=thirdparty%2Fsuricata.git rust/ssh: use md-5 crate instead of md5 The "md-5" crate is part of the RustCrypto project that also uses the sha1 and sha256 crates we are using. These all implement the Digest trait for a common API. --- diff --git a/rust/src/ssh/parser.rs b/rust/src/ssh/parser.rs index a626359f78..a8a2f3826c 100644 --- a/rust/src/ssh/parser.rs +++ b/rust/src/ssh/parser.rs @@ -17,6 +17,8 @@ use nom::combinator::rest; use nom::number::streaming::{be_u32, be_u8}; +use md5c::Md5; +use digest::Digest; use std::fmt; #[derive(PartialEq, Eq, Copy, Clone, Debug)] @@ -151,8 +153,6 @@ pub struct SshPacketKeyExchange<'a> { pub reserved: u32, } -use md5::compute; - const SSH_HASSH_STRING_DELIMITER_SLICE: [u8; 1] = [b';']; impl<'a> SshPacketKeyExchange<'a> { @@ -172,7 +172,7 @@ impl<'a> SshPacketKeyExchange<'a> { hassh_string.reserve_exact(slices.iter().fold(0, |acc, x| acc + x.len())); // copying slices to hassh string slices.iter().for_each(|&x| hassh_string.extend_from_slice(x)); - hassh.extend(format!("{:x?}", compute(&hassh_string)).as_bytes()); + hassh.extend(format!("{:x}", Md5::new().chain(&hassh_string).finalize()).as_bytes()); } }