summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Cargo.lock1
-rw-r--r--net/Cargo.toml1
-rw-r--r--net/src/lib.rs1
-rw-r--r--net/src/wkd.rs21
4 files changed, 9 insertions, 15 deletions
diff --git a/Cargo.lock b/Cargo.lock
index fd86481d..9a4efc2c 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1633,7 +1633,6 @@ dependencies = [
"hyper-tls 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)",
"native-tls 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
- "nettle 5.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
"percent-encoding 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)",
"sequoia-core 0.12.0",
diff --git a/net/Cargo.toml b/net/Cargo.toml
index 73400201..eed53733 100644
--- a/net/Cargo.toml
+++ b/net/Cargo.toml
@@ -31,7 +31,6 @@ hyper = "0.12"
hyper-tls = "0.3"
libc = "0.2.33"
native-tls = "0.2.0"
-nettle = "5.0"
percent-encoding = "2.1"
tempfile = "3.1"
tokio-core = "0.1"
diff --git a/net/src/lib.rs b/net/src/lib.rs
index 8f91ce18..f7add939 100644
--- a/net/src/lib.rs
+++ b/net/src/lib.rs
@@ -45,7 +45,6 @@ extern crate http;
extern crate hyper;
extern crate hyper_tls;
extern crate native_tls;
-extern crate nettle;
extern crate tokio_core;
extern crate tokio_io;
extern crate percent_encoding;
diff --git a/net/src/wkd.rs b/net/src/wkd.rs
index 286b8562..a4134110 100644
--- a/net/src/wkd.rs
+++ b/net/src/wkd.rs
@@ -26,12 +26,6 @@ use failure::ResultExt;
use futures::{future, Future, Stream};
use hyper::{Uri, Client};
use hyper_tls::HttpsConnector;
-// Hash implements the traits for Sha1
-// Sha1 is used to obtain a 20 bytes digest that after zbase32 encoding can
-// be used as file name
-use nettle::{
- Hash, hash::insecure_do_not_use::Sha1,
-};
use url;
use crate::openpgp::{
@@ -40,6 +34,7 @@ use crate::openpgp::{
};
use crate::openpgp::parse::Parse;
use crate::openpgp::serialize::Serialize;
+use crate::openpgp::types::HashAlgorithm;
use crate::openpgp::cert::CertParser;
use super::{Result, Error};
@@ -204,13 +199,15 @@ impl Url {
/// described in [RFC6189], section 5.1.6. The resulting string has a
/// fixed length of 32 octets.
fn encode_local_part<S: AsRef<str>>(local_part: S) -> String {
- let mut hasher = Sha1::default();
- hasher.update(local_part.as_ref().as_bytes());
- // Declare and assign a 20 bytes length vector to use in hasher.result
- let mut local_hash = vec![0; 20];
- hasher.digest(&mut local_hash);
+ let local_part = local_part.as_ref();
+
+ let mut digest = vec![0; 20];
+ let mut ctx = HashAlgorithm::SHA1.context().expect("must be implemented");
+ ctx.update(local_part.as_bytes());
+ ctx.digest(&mut digest);
+
// After z-base-32 encoding 20 bytes, it will be 32 bytes long.
- zbase32::encode_full_bytes(&local_hash[..])
+ zbase32::encode_full_bytes(&digest[..])
}