summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJustus Winter <justus@sequoia-pgp.org>2019-02-13 11:44:12 +0100
committerJustus Winter <justus@sequoia-pgp.org>2019-02-13 12:13:02 +0100
commitf2cd1cf10eef430214d2df3d2dc7283b94fc1949 (patch)
tree9f30fb56ceac7861e5e7d9213af01e6357d2cbf5
parent779fd253b285f315aff529690716e2e56047caa9 (diff)
openpgp: Qualify nettle::Hash.
-rw-r--r--openpgp/src/crypto/hash.rs35
-rw-r--r--openpgp/src/crypto/mod.rs4
-rw-r--r--openpgp/src/crypto/mpis.rs12
-rw-r--r--openpgp/src/packet/signature/mod.rs4
-rw-r--r--openpgp/src/parse/key.rs2
-rw-r--r--openpgp/src/parse/parse.rs4
6 files changed, 31 insertions, 30 deletions
diff --git a/openpgp/src/crypto/hash.rs b/openpgp/src/crypto/hash.rs
index d0494853..26f9fda6 100644
--- a/openpgp/src/crypto/hash.rs
+++ b/openpgp/src/crypto/hash.rs
@@ -9,7 +9,8 @@ use Error;
use Result;
use conversions::Time;
-use nettle::Hash;
+use nettle;
+use nettle::Hash as NettleHash;
use std::fs::{File, OpenOptions};
use std::io::Write;
@@ -36,11 +37,11 @@ impl HashAlgorithm {
/// Creates a new Nettle hash context for this algorith. Fails if Sequoia
/// does not support this algorithm. See `is_supported`.
- pub fn context(self) -> Result<Box<Hash>> {
+ pub fn context(self) -> Result<Box<nettle::Hash>> {
use nettle::hash::*;
use nettle::hash::insecure_do_not_use::Sha1;
- let c: Result<Box<Hash>> = match self {
+ let c: Result<Box<nettle::Hash>> = match self {
HashAlgorithm::SHA1 => Ok(Box::new(Sha1::default())),
HashAlgorithm::SHA224 => Ok(Box::new(Sha224::default())),
HashAlgorithm::SHA256 => Ok(Box::new(Sha256::default())),
@@ -53,7 +54,7 @@ impl HashAlgorithm {
};
if let Some(prefix) = DUMP_HASHED_VALUES {
- c.map(|c: Box<Hash>| -> Box<Hash> {
+ c.map(|c: Box<nettle::Hash>| -> Box<nettle::Hash> {
Box::new(HashDumper::new(c, prefix))
})
} else {
@@ -80,14 +81,14 @@ impl HashAlgorithm {
}
struct HashDumper {
- h: Box<Hash>,
+ h: Box<nettle::Hash>,
sink: File,
filename: String,
written: usize,
}
impl HashDumper {
- fn new(h: Box<Hash>, prefix: &str) -> Self {
+ fn new(h: Box<nettle::Hash>, prefix: &str) -> Self {
let mut n = 0;
let mut filename;
let sink = loop {
@@ -116,7 +117,7 @@ impl Drop for HashDumper {
}
}
-impl Hash for HashDumper {
+impl nettle::Hash for HashDumper {
fn digest_size(&self) -> usize {
self.h.digest_size()
}
@@ -128,14 +129,14 @@ impl Hash for HashDumper {
fn digest(&mut self, digest: &mut [u8]) {
self.h.digest(digest);
}
- fn box_clone(&self) -> Box<Hash> {
+ fn box_clone(&self) -> Box<nettle::Hash> {
Box::new(Self::new(self.h.box_clone(), &DUMP_HASHED_VALUES.unwrap()))
}
}
impl UserID {
/// Update the Hash with a hash of the user id.
- pub fn hash<H: Hash>(&self, hash: &mut H) {
+ pub fn hash<H: nettle::Hash>(&self, hash: &mut H) {
let mut header = [0; 5];
header[0] = 0xB4;
@@ -152,7 +153,7 @@ impl UserID {
impl UserAttribute {
/// Update the Hash with a hash of the user attribute.
- pub fn hash<H: Hash>(&self, hash: &mut H) {
+ pub fn hash<H: nettle::Hash>(&self, hash: &mut H) {
let mut header = [0; 5];
header[0] = 0xD1;
@@ -169,7 +170,7 @@ impl UserAttribute {
impl Key {
/// Update the Hash with a hash of the key.
- pub fn hash<H: Hash + Write>(&self, hash: &mut H) {
+ pub fn hash<H: nettle::Hash + Write>(&self, hash: &mut H) {
// We hash 8 bytes plus the MPIs. But, the len doesn't
// include the tag (1 byte) or the length (2 bytes).
let len = (9 - 3) + self.mpis().serialized_len();
@@ -206,14 +207,14 @@ impl Key {
impl Signature {
/// Adds the `Signature` to the provided hash context.
- pub fn hash<H: Hash>(&self, hash: &mut H) {
+ pub fn hash<H: nettle::Hash>(&self, hash: &mut H) {
self.fields.hash(hash);
}
}
impl signature::Builder {
/// Adds the `Signature` to the provided hash context.
- pub fn hash<H: Hash>(&self, hash: &mut H) {
+ pub fn hash<H: nettle::Hash>(&self, hash: &mut H) {
// A version 4 signature packet is laid out as follows:
//
// version - 1 byte \
@@ -277,7 +278,7 @@ impl Signature {
where S: Into<&'a signature::Builder> {
let sig = sig.into();
- let mut h: Box<Hash> = sig.hash_algo().context().unwrap();
+ let mut h: Box<nettle::Hash> = sig.hash_algo().context().unwrap();
key.hash(&mut h);
sig.hash(&mut h);
@@ -294,7 +295,7 @@ impl Signature {
where S: Into<&'a signature::Builder> {
let sig = sig.into();
- let mut h: Box<Hash> = sig.hash_algo().context().unwrap();
+ let mut h: Box<nettle::Hash> = sig.hash_algo().context().unwrap();
key.hash(&mut h);
subkey.hash(&mut h);
@@ -312,7 +313,7 @@ impl Signature {
where S: Into<&'a signature::Builder> {
let sig = sig.into();
- let mut h: Box<Hash> = sig.hash_algo().context().unwrap();
+ let mut h: Box<nettle::Hash> = sig.hash_algo().context().unwrap();
key.hash(&mut h);
userid.hash(&mut h);
@@ -331,7 +332,7 @@ impl Signature {
where S: Into<&'a signature::Builder> {
let sig = sig.into();
- let mut h: Box<Hash> = sig.hash_algo().context().unwrap();
+ let mut h: Box<nettle::Hash> = sig.hash_algo().context().unwrap();
key.hash(&mut h);
ua.hash(&mut h);
diff --git a/openpgp/src/crypto/mod.rs b/openpgp/src/crypto/mod.rs
index 9dfec48e..5f94e3b4 100644
--- a/openpgp/src/crypto/mod.rs
+++ b/openpgp/src/crypto/mod.rs
@@ -6,7 +6,7 @@ use std::fmt;
use std::cmp::Ordering;
use memsec;
-use nettle::Hash;
+use nettle;
use nettle::random::Yarrow;
use constants::HashAlgorithm;
@@ -157,7 +157,7 @@ impl fmt::Debug for Password {
///
/// This is useful when verifying detached signatures.
pub fn hash_file<R: Read>(reader: R, algos: &[HashAlgorithm])
- -> Result<Vec<(HashAlgorithm, Box<Hash>)>>
+ -> Result<Vec<(HashAlgorithm, Box<nettle::Hash>)>>
{
use std::mem;
diff --git a/openpgp/src/crypto/mpis.rs b/openpgp/src/crypto/mpis.rs
index 0563ca01..f749d90f 100644
--- a/openpgp/src/crypto/mpis.rs
+++ b/openpgp/src/crypto/mpis.rs
@@ -15,7 +15,7 @@ use constants::{
};
use serialize::Serialize;
-use nettle::Hash;
+use nettle;
/// Holds a single MPI.
#[derive(Clone, Hash)]
@@ -49,7 +49,7 @@ impl MPI {
}
/// Update the Hash with a hash of the MPIs.
- pub fn hash<H: Hash>(&self, hash: &mut H) {
+ pub fn hash<H: nettle::Hash>(&self, hash: &mut H) {
let len = &[(self.bits >> 8) as u8 & 0xFF, self.bits as u8];
hash.update(len);
@@ -256,7 +256,7 @@ impl PublicKey {
}
/// Update the Hash with a hash of the MPIs.
- pub fn hash<H: Hash + Write>(&self, hash: &mut H) {
+ pub fn hash<H: nettle::Hash + Write>(&self, hash: &mut H) {
self.serialize(hash).expect("hashing does not fail")
}
}
@@ -556,7 +556,7 @@ impl SecretKey {
}
/// Update the Hash with a hash of the MPIs.
- pub fn hash<H: Hash + Write>(&self, hash: &mut H) {
+ pub fn hash<H: nettle::Hash + Write>(&self, hash: &mut H) {
self.serialize(hash).expect("hashing does not fail")
}
}
@@ -676,7 +676,7 @@ impl Ciphertext {
}
/// Update the Hash with a hash of the MPIs.
- pub fn hash<H: Hash + Write>(&self, hash: &mut H) {
+ pub fn hash<H: nettle::Hash + Write>(&self, hash: &mut H) {
self.serialize(hash).expect("hashing does not fail")
}
}
@@ -786,7 +786,7 @@ impl Signature {
}
/// Update the Hash with a hash of the MPIs.
- pub fn hash<H: Hash + Write>(&self, hash: &mut H) {
+ pub fn hash<H: nettle::Hash + Write>(&self, hash: &mut H) {
self.serialize(hash).expect("hashing does not fail")
}
}
diff --git a/openpgp/src/packet/signature/mod.rs b/openpgp/src/packet/signature/mod.rs
index dfb3059c..0a3f7cba 100644
--- a/openpgp/src/packet/signature/mod.rs
+++ b/openpgp/src/packet/signature/mod.rs
@@ -22,7 +22,7 @@ use packet;
use packet::signature::subpacket::SubpacketArea;
use serialize::Serialize;
-use nettle::{dsa, ecdsa, ed25519, Hash, rsa};
+use nettle::{self, dsa, ecdsa, ed25519, rsa};
use nettle::rsa::verify_digest_pkcs1;
#[cfg(test)]
@@ -186,7 +186,7 @@ impl Builder {
/// algorithm used by `signer`, the hash-algorithm field is set to
/// `hash_algo`.
pub fn sign_hash(mut self, signer: &mut Signer,
- hash_algo: HashAlgorithm, mut hash: Box<Hash>)
+ hash_algo: HashAlgorithm, mut hash: Box<nettle::Hash>)
-> Result<Signature> {
// Fill out some fields, then hash the packet.
self.pk_algo = signer.public().pk_algo();
diff --git a/openpgp/src/parse/key.rs b/openpgp/src/parse/key.rs
index f18cc574..76afeb01 100644
--- a/openpgp/src/parse/key.rs
+++ b/openpgp/src/parse/key.rs
@@ -1,6 +1,6 @@
//! Helper functions for OpenPGP Key parsing.
-use nettle::Hash;
+use nettle::Hash as NettleHash;
use nettle::hash::insecure_do_not_use::Sha1;
use {
diff --git a/openpgp/src/parse/parse.rs b/openpgp/src/parse/parse.rs
index b90428d0..be146c2e 100644
--- a/openpgp/src/parse/parse.rs
+++ b/openpgp/src/parse/parse.rs
@@ -10,7 +10,7 @@ use std::path::Path;
use time;
use failure;
-use nettle::Hash;
+use nettle;
use ::buffered_reader::*;
@@ -497,7 +497,7 @@ pub(crate) struct SignatureGroup {
ops_count: usize,
/// Maps hash algorithms to hash contexts.
- pub(crate) hashes: HashMap<HashAlgorithm, Box<Hash>>,
+ pub(crate) hashes: HashMap<HashAlgorithm, Box<nettle::Hash>>,
}
impl fmt::Debug for SignatureGroup {