From 61f68d8588d853950fafb8e52b94c8634d9c3b61 Mon Sep 17 00:00:00 2001 From: Fabio Valentini Date: Fri, 29 Apr 2022 13:46:34 +0200 Subject: [PATCH] Drop downstream patch to revert upstream move to xxh3 --- 0001-revert-commit-17cd68f.patch | 141 ------------------------------ rust-sequoia-openpgp.spec | 3 - sequoia-openpgp-fix-metadata.diff | 27 +++--- 3 files changed, 16 insertions(+), 155 deletions(-) delete mode 100644 0001-revert-commit-17cd68f.patch diff --git a/0001-revert-commit-17cd68f.patch b/0001-revert-commit-17cd68f.patch deleted file mode 100644 index 491af74..0000000 --- a/0001-revert-commit-17cd68f.patch +++ /dev/null @@ -1,141 +0,0 @@ -From ba5882c2b9835d9662986ec63e39912d7a2e60c2 Mon Sep 17 00:00:00 2001 -From: Fabio Valentini -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, - } - - 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> for Container { - fn from(packets: Vec) -> 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 { - lazy_static::lazy_static!{ -- static ref DIGEST: u64 = { -- Container::make_body_hash().digest() -+ static ref DIGEST: Vec = { -+ 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 { -- Box::new(Xxh3::new()) -+ fn make_body_hash() -> Box { -+ 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) { -- self.body_digest = h.digest(); -+ fn set_body_hash(&mut self, mut h: Box) { -+ 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>, -+ body_hash: Option>, - - state: PacketParserState, - } --- -2.34.1 - diff --git a/rust-sequoia-openpgp.spec b/rust-sequoia-openpgp.spec index 52fd5c2..f85d5a4 100644 --- a/rust-sequoia-openpgp.spec +++ b/rust-sequoia-openpgp.spec @@ -14,11 +14,8 @@ License: LGPLv2+ URL: https://crates.io/crates/sequoia-openpgp Source: %{crates_source} # Initial patched metadata -# * revert upstream commit that switched to xxh3: -# https://gitlab.com/sequoia-pgp/sequoia/-/commit/17cd68f # * drop windows- and WASM-specific dependencies Patch0: sequoia-openpgp-fix-metadata.diff -Patch1: 0001-revert-commit-17cd68f.patch ExclusiveArch: %{rust_arches} diff --git a/sequoia-openpgp-fix-metadata.diff b/sequoia-openpgp-fix-metadata.diff index 4e1c588..eb8bf18 100644 --- a/sequoia-openpgp-fix-metadata.diff +++ b/sequoia-openpgp-fix-metadata.diff @@ -1,20 +1,26 @@ --- sequoia-openpgp-1.8.0/Cargo.toml 1970-01-01T00:00:01+00:00 -+++ sequoia-openpgp-1.8.0/Cargo.toml 2022-03-16T10:27:31.199219+00:00 -@@ -201,13 +201,6 @@ - version = "1.1.0" - optional = true ++++ sequoia-openpgp-1.8.0/Cargo.toml 2022-04-29T11:46:08.278159+00:00 +@@ -33,9 +33,6 @@ + name = "pad" + required-features = ["compression-deflate"] --[dependencies.xxhash-rust] --version = "0.8" --features = ["xxh3"] +-[[bench]] +-name = "run_benchmarks" +-harness = false + [dependencies.aes] + version = "0.6.0" + optional = true +@@ -204,9 +201,6 @@ + [dependencies.xxhash-rust] + version = "0.8" + features = ["xxh3"] -[dev-dependencies.criterion] -version = "0.3.4" -features = ["html_reports"] -- + [dev-dependencies.quickcheck] version = "1" - default-features = false -@@ -230,33 +223,10 @@ +@@ -230,33 +224,9 @@ compression = ["compression-deflate", "compression-bzip2"] compression-bzip2 = ["bzip2", "buffered-reader/compression-bzip2"] compression-deflate = ["flate2", "buffered-reader/compression-deflate"] @@ -45,7 +51,6 @@ -features = ["bcrypt"] -optional = true -default-features = false -+ [badges.gitlab] repository = "sequoia-pgp/sequoia"