parent
0541b3e036
commit
5c1f043df4
@ -0,0 +1,28 @@
|
||||
[DEFAULT]
|
||||
unwanted-features =
|
||||
aes
|
||||
block-modes
|
||||
block-padding
|
||||
blowfish
|
||||
cast5
|
||||
cipher
|
||||
des
|
||||
digest
|
||||
eax
|
||||
ecdsa
|
||||
ed25519-dalek
|
||||
generic-array
|
||||
idea
|
||||
md-5
|
||||
num-bigint-dig
|
||||
p256
|
||||
rand07
|
||||
rand_core
|
||||
ripemd160
|
||||
rsa
|
||||
sha-1
|
||||
sha2
|
||||
twofish
|
||||
typenum
|
||||
x25519-dalek
|
||||
crypto-rust
|
@ -0,0 +1,141 @@
|
||||
From ba5882c2b9835d9662986ec63e39912d7a2e60c2 Mon Sep 17 00:00:00 2001
|
||||
From: Fabio Valentini <decathorpe@gmail.com>
|
||||
Date: Tue, 18 Jan 2022 20:10:23 +0100
|
||||
Subject: [PATCH] revert commit 17cd68f
|
||||
|
||||
---
|
||||
src/packet/container.rs | 41 +++++++++++++++++++++++++++--------------
|
||||
src/parse.rs | 4 +---
|
||||
2 files changed, 28 insertions(+), 17 deletions(-)
|
||||
|
||||
diff --git a/src/packet/container.rs b/src/packet/container.rs
|
||||
index dfbb624..3a4bb26 100644
|
||||
--- a/src/packet/container.rs
|
||||
+++ b/src/packet/container.rs
|
||||
@@ -8,11 +8,11 @@ use std::hash::{Hash, Hasher};
|
||||
use std::slice;
|
||||
use std::vec;
|
||||
|
||||
-use xxhash_rust::xxh3::Xxh3;
|
||||
-
|
||||
use crate::{
|
||||
Packet,
|
||||
+ crypto::hash,
|
||||
packet::Iter,
|
||||
+ types::HashAlgorithm,
|
||||
};
|
||||
|
||||
/// A packet's body holds either unprocessed bytes, processed bytes,
|
||||
@@ -126,7 +126,7 @@ pub struct Container {
|
||||
body: Body,
|
||||
|
||||
/// We compute a digest over the body to implement comparison.
|
||||
- body_digest: u64,
|
||||
+ body_digest: Vec<u8>,
|
||||
}
|
||||
|
||||
assert_send_and_sync!(Container);
|
||||
@@ -138,6 +138,14 @@ impl std::ops::Deref for Container {
|
||||
}
|
||||
}
|
||||
|
||||
+// Pick the fastest hash function from the SHA2 family for the
|
||||
+// architectures word size. On 64-bit architectures, SHA512 is almost
|
||||
+// twice as fast, but on 32-bit ones, SHA256 is faster.
|
||||
+#[cfg(target_pointer_width = "64")]
|
||||
+const CONTAINER_BODY_HASH: HashAlgorithm = HashAlgorithm::SHA512;
|
||||
+#[cfg(not(target_pointer_width = "64"))]
|
||||
+const CONTAINER_BODY_HASH: HashAlgorithm = HashAlgorithm::SHA256;
|
||||
+
|
||||
impl PartialEq for Container {
|
||||
fn eq(&self, other: &Container) -> bool {
|
||||
use Body::*;
|
||||
@@ -169,7 +177,7 @@ impl Default for Container {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
body: Body::Structured(Vec::with_capacity(0)),
|
||||
- body_digest: 0,
|
||||
+ body_digest: Vec::with_capacity(0),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -178,7 +186,7 @@ impl From<Vec<Packet>> for Container {
|
||||
fn from(packets: Vec<Packet>) -> Self {
|
||||
Self {
|
||||
body: Body::Structured(packets),
|
||||
- body_digest: 0,
|
||||
+ body_digest: Vec::with_capacity(0),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -296,31 +304,36 @@ impl Container {
|
||||
}
|
||||
|
||||
/// Returns the hash for the empty body.
|
||||
- fn empty_body_digest() -> u64 {
|
||||
+ fn empty_body_digest() -> Vec<u8> {
|
||||
lazy_static::lazy_static!{
|
||||
- static ref DIGEST: u64 = {
|
||||
- Container::make_body_hash().digest()
|
||||
+ static ref DIGEST: Vec<u8> = {
|
||||
+ let mut h = Container::make_body_hash();
|
||||
+ let mut d = vec![0; h.digest_size()];
|
||||
+ let _ = h.digest(&mut d);
|
||||
+ d
|
||||
};
|
||||
}
|
||||
|
||||
- *DIGEST
|
||||
+ DIGEST.clone()
|
||||
}
|
||||
|
||||
/// Creates a hash context for hashing the body.
|
||||
pub(crate) // For parse.rs
|
||||
- fn make_body_hash() -> Box<Xxh3> {
|
||||
- Box::new(Xxh3::new())
|
||||
+ fn make_body_hash() -> Box<dyn hash::Digest> {
|
||||
+ CONTAINER_BODY_HASH.context()
|
||||
+ .expect("CONTAINER_BODY_HASH must be implemented")
|
||||
}
|
||||
|
||||
/// Hashes content that has been streamed.
|
||||
pub(crate) // For parse.rs
|
||||
- fn set_body_hash(&mut self, h: Box<Xxh3>) {
|
||||
- self.body_digest = h.digest();
|
||||
+ fn set_body_hash(&mut self, mut h: Box<dyn hash::Digest>) {
|
||||
+ self.body_digest.resize(h.digest_size(), 0);
|
||||
+ let _ = h.digest(&mut self.body_digest);
|
||||
}
|
||||
|
||||
pub(crate)
|
||||
fn body_digest(&self) -> String {
|
||||
- format!("{:08X}", self.body_digest)
|
||||
+ crate::fmt::hex::encode(&self.body_digest)
|
||||
}
|
||||
|
||||
// Converts an indentation level to whitespace.
|
||||
diff --git a/src/parse.rs b/src/parse.rs
|
||||
index 1fe8899..23084af 100644
|
||||
--- a/src/parse.rs
|
||||
+++ b/src/parse.rs
|
||||
@@ -183,8 +183,6 @@ use std::fmt;
|
||||
use std::path::Path;
|
||||
use std::result::Result as StdResult;
|
||||
|
||||
-use xxhash_rust::xxh3::Xxh3;
|
||||
-
|
||||
use ::buffered_reader::*;
|
||||
|
||||
use crate::{
|
||||
@@ -3306,7 +3304,7 @@ pub struct PacketParser<'a> {
|
||||
|
||||
/// We compute a hashsum over the body to implement comparison on
|
||||
/// containers that have been streamed.
|
||||
- body_hash: Option<Box<Xxh3>>,
|
||||
+ body_hash: Option<Box<dyn crate::crypto::hash::Digest>>,
|
||||
|
||||
state: PacketParserState,
|
||||
}
|
||||
--
|
||||
2.34.1
|
||||
|
@ -1 +1 @@
|
||||
SHA512 (sequoia-openpgp-1.3.0.crate) = a2bcd06a0deafb7df151e07a55b86e2fa96ee95715b1480081b6dedcd20388ba7a000646ebcc827af16fd75675843ccd38c1f20232a05f2d0d8370de7b9e8c24
|
||||
SHA512 (sequoia-openpgp-1.7.0.crate) = 2f77d1aaee9257124143e3849441c5fb912740e16270cdefea2a4e73798e4a5ffed89fa1437643d9df8c53efbe649f162f42359e26fecd75f526bc2a11bee6fa
|
||||
|
Loading…
Reference in new issue