From 6a48a6bf0065608f47ca3d40c890206544b1643d Mon Sep 17 00:00:00 2001 From: Emmanuel Gil Peyrot Date: Thu, 27 Apr 2017 18:33:02 +0100 Subject: [PATCH] ecaps2, error: Update to base64 0.5. --- Cargo.toml | 2 +- src/ecaps2.rs | 12 ++++++------ src/error.rs | 6 +++--- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index c049bd6..e236251 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,7 +6,7 @@ authors = ["Emmanuel Gil Peyrot "] [dependencies] minidom = "0.2.0" jid = "0.2.0" -base64 = "0.4.1" +base64 = "0.5.0" digest = "0.5.0" sha2 = "0.5.0" sha3 = "0.5.0" diff --git a/src/ecaps2.rs b/src/ecaps2.rs index bfd208c..d5a13dd 100644 --- a/src/ecaps2.rs +++ b/src/ecaps2.rs @@ -118,25 +118,25 @@ pub fn hash_ecaps2(data: &[u8], algo: &str) -> String { let mut hasher = Sha256::default(); hasher.input(data); let hash = hasher.result(); - base64::encode(&hash) + base64::encode(&hash.as_slice()) }, "sha-512" => { let mut hasher = Sha512::default(); hasher.input(data); let hash = hasher.result(); - base64::encode(&hash) + base64::encode(&hash.as_slice()) }, "sha3-256" => { let mut hasher = Sha3_256::default(); hasher.input(data); let hash = hasher.result(); - base64::encode(&hash) + base64::encode(&hash.as_slice()) }, "sha3-512" => { let mut hasher = Sha3_512::default(); hasher.input(data); let hash = hasher.result(); - base64::encode(&hash) + base64::encode(&hash.as_slice()) }, "blake2b-256" => { let mut hasher = Blake2b::default(); @@ -438,12 +438,12 @@ mod tests { #[test] fn test_blake2b_512() { let hash = ecaps2::hash_ecaps2("abc".as_bytes(), "blake2b-512"); - let known_hash: [u8; 64] = [ + let known_hash: Vec = vec!( 0xBA, 0x80, 0xA5, 0x3F, 0x98, 0x1C, 0x4D, 0x0D, 0x6A, 0x27, 0x97, 0xB6, 0x9F, 0x12, 0xF6, 0xE9, 0x4C, 0x21, 0x2F, 0x14, 0x68, 0x5A, 0xC4, 0xB7, 0x4B, 0x12, 0xBB, 0x6F, 0xDB, 0xFF, 0xA2, 0xD1, 0x7D, 0x87, 0xC5, 0x39, 0x2A, 0xAB, 0x79, 0x2D, 0xC2, 0x52, 0xD5, 0xDE, 0x45, 0x33, 0xCC, 0x95, 0x18, 0xD3, 0x8A, 0xA8, 0xDB, 0xF1, 0x92, 0x5A, 0xB9, 0x23, 0x86, 0xED, 0xD4, 0x00, 0x99, 0x23, - ]; + ); let known_hash = base64::encode(&known_hash); assert_eq!(hash, known_hash); } diff --git a/src/error.rs b/src/error.rs index e9506ba..07b01c1 100644 --- a/src/error.rs +++ b/src/error.rs @@ -10,7 +10,7 @@ pub enum Error { ParseError(&'static str), IoError(io::Error), XMLError(minidom::Error), - Base64Error(base64::Base64Error), + Base64Error(base64::DecodeError), ParseIntError(num::ParseIntError), } @@ -26,8 +26,8 @@ impl From for Error { } } -impl From for Error { - fn from(err: base64::Base64Error) -> Error { +impl From for Error { + fn from(err: base64::DecodeError) -> Error { Error::Base64Error(err) } }