From c5946faffd1356bce3f4e2d017eaa9d1fa6fd3ec Mon Sep 17 00:00:00 2001 From: Wolfgang Bumiller Date: Thu, 14 Nov 2019 11:19:43 +0100 Subject: [PATCH] drop md5 crate dependency we already depend on openssl which also provides md5 Signed-off-by: Wolfgang Bumiller --- Cargo.toml | 1 - src/tools.rs | 10 ++++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 4e299d41..20226629 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,7 +22,6 @@ hyper = { version = "0.13.0-alpha.1" } lazy_static = "1.3" libc = "0.2" log = "0.4" -md5 = "0.6" mio = "0.6" native-tls = "0.2" nix = "0.15" diff --git a/src/tools.rs b/src/tools.rs index 891934ad..38d822fa 100644 --- a/src/tools.rs +++ b/src/tools.rs @@ -13,6 +13,7 @@ use std::time::Duration; use failure::*; use serde_json::Value; +use openssl::hash::{hash, DigestBytes, MessageDigest}; use proxmox::tools::vec; @@ -385,13 +386,18 @@ where Ok(()) } +/// Shortcut for md5 sums. +pub fn md5sum(data: &[u8]) -> Result { + hash(MessageDigest::md5(), data).map_err(Error::from) +} + pub fn get_hardware_address() -> Result { static FILENAME: &str = "/etc/ssh/ssh_host_rsa_key.pub"; let contents = proxmox::tools::fs::file_get_contents(FILENAME)?; - let digest = md5::compute(contents); + let digest = md5sum(&contents)?; - Ok(format!("{:0x}", digest)) + Ok(proxmox::tools::bin_to_hex(&digest)) } pub fn assert_if_modified(digest1: &str, digest2: &str) -> Result<(), Error> {