]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
rust/ssh: use md-5 crate instead of md5
authorJason Ish <jason.ish@oisf.net>
Wed, 23 Dec 2020 04:27:26 +0000 (22:27 -0600)
committerVictor Julien <victor@inliniac.net>
Tue, 12 Jan 2021 20:17:29 +0000 (21:17 +0100)
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.

rust/src/ssh/parser.rs

index a626359f78d0fd24b3b3dbd65044da10aa88cb75..a8a2f3826c2dfc134768888308c9dd08e01c367c 100644 (file)
@@ -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());
     }
 }