diff --git a/Cargo.toml b/Cargo.toml index 2c4be9b..8b0111e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,7 +19,7 @@ name = "ots-info" path = "src/bin/ots_info.rs" [dependencies] +bitcoin_hashes = "0.12.0" env_logger = "0.4" log = "0.3" -rust-crypto = "0.2" diff --git a/src/lib.rs b/src/lib.rs index f43a45f..66fff5d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -23,7 +23,7 @@ #![deny(unused_mut)] #![deny(missing_docs)] -extern crate crypto; +extern crate bitcoin_hashes; #[macro_use] extern crate log; pub mod attestation; diff --git a/src/op.rs b/src/op.rs index 220d80d..9ad3cf2 100644 --- a/src/op.rs +++ b/src/op.rs @@ -18,13 +18,10 @@ //! timestamps. //! -use crypto::digest::Digest; -use crypto::sha1::Sha1; -use crypto::sha2::Sha256; -use crypto::ripemd160::Ripemd160; use std::fmt; use std::io::{Read, Write}; +use bitcoin_hashes::{Hash, ripemd160, sha1, sha256}; use error::Error; use hex::Hexed; use ser; @@ -100,25 +97,13 @@ impl Op { pub fn execute(&self, input: &[u8]) -> Vec { match *self { Op::Sha1 => { - let mut ret = vec![0; 20]; - let mut hasher = Sha1::new(); - hasher.input(input); - hasher.result(&mut ret); - ret + sha1::Hash::hash(&input).to_byte_array().to_vec() } Op::Sha256 => { - let mut ret = vec![0; 32]; - let mut hasher = Sha256::new(); - hasher.input(input); - hasher.result(&mut ret); - ret + sha256::Hash::hash(&input).to_byte_array().to_vec() } Op::Ripemd160 => { - let mut ret = vec![0; 20]; - let mut hasher = Ripemd160::new(); - hasher.input(input); - hasher.result(&mut ret); - ret + ripemd160::Hash::hash(&input).to_byte_array().to_vec() } Op::Hexlify => { format!("{}", Hexed(input)).into_bytes()