Update to version 1.7.0; Fixes RHBZ#2002229

epel9
Fabio Valentini 3 years ago
parent 0541b3e036
commit 5c1f043df4
No known key found for this signature in database
GPG Key ID: 5AC5F572E5D410AF

1
.gitignore vendored

@ -3,3 +3,4 @@
/sequoia-openpgp-1.1.0.crate
/sequoia-openpgp-1.3.0.crate
/sequoia-openpgp-1.7.0.crate

@ -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,27 +1,26 @@
# Generated by rust2rpm 17
# Generated by rust2rpm 20
%bcond_without check
%global debug_package %{nil}
%global crate sequoia-openpgp
Name: rust-%{crate}
Version: 1.3.0
Version: 1.7.0
Release: %autorelease
Summary: OpenPGP data types and associated machinery
# Upstream license specification: GPL-2.0-or-later
License: GPLv2+
# Upstream license specification: LGPL-2.0-or-later
License: LGPLv2+
URL: https://crates.io/crates/sequoia-openpgp
Source: %{crates_source}
# Initial patched metadata
# * drop Windows-specific features and dependencies
# * drop benchmark-only criterion dev-dependency
# * 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}
%if %{__cargo_skip_build}
BuildArch: noarch
%endif
BuildRequires: rust-packaging
@ -36,8 +35,8 @@ BuildArch: noarch
%description devel %{_description}
This package contains library source intended for building other packages
which use "%{crate}" crate.
This package contains library source intended for building other packages which
use the "%{crate}" crate.
%files devel
%license LICENSE.txt
@ -50,20 +49,44 @@ BuildArch: noarch
%description -n %{name}+default-devel %{_description}
This package contains library source intended for building other packages
which use "default" feature of "%{crate}" crate.
This package contains library source intended for building other packages which
use the "default" feature of the "%{crate}" crate.
%files -n %{name}+default-devel
%ghost %{cargo_registry}/%{crate}-%{version_no_tilde}/Cargo.toml
%package -n %{name}+allow-experimental-crypto-devel
Summary: %{summary}
BuildArch: noarch
%description -n %{name}+allow-experimental-crypto-devel %{_description}
This package contains library source intended for building other packages which
use the "allow-experimental-crypto" feature of the "%{crate}" crate.
%files -n %{name}+allow-experimental-crypto-devel
%ghost %{cargo_registry}/%{crate}-%{version_no_tilde}/Cargo.toml
%package -n %{name}+allow-variable-time-crypto-devel
Summary: %{summary}
BuildArch: noarch
%description -n %{name}+allow-variable-time-crypto-devel %{_description}
This package contains library source intended for building other packages which
use the "allow-variable-time-crypto" feature of the "%{crate}" crate.
%files -n %{name}+allow-variable-time-crypto-devel
%ghost %{cargo_registry}/%{crate}-%{version_no_tilde}/Cargo.toml
%package -n %{name}+bzip2-devel
Summary: %{summary}
BuildArch: noarch
%description -n %{name}+bzip2-devel %{_description}
This package contains library source intended for building other packages
which use "bzip2" feature of "%{crate}" crate.
This package contains library source intended for building other packages which
use the "bzip2" feature of the "%{crate}" crate.
%files -n %{name}+bzip2-devel
%ghost %{cargo_registry}/%{crate}-%{version_no_tilde}/Cargo.toml
@ -74,8 +97,8 @@ BuildArch: noarch
%description -n %{name}+compression-devel %{_description}
This package contains library source intended for building other packages
which use "compression" feature of "%{crate}" crate.
This package contains library source intended for building other packages which
use the "compression" feature of the "%{crate}" crate.
%files -n %{name}+compression-devel
%ghost %{cargo_registry}/%{crate}-%{version_no_tilde}/Cargo.toml
@ -86,8 +109,8 @@ BuildArch: noarch
%description -n %{name}+compression-bzip2-devel %{_description}
This package contains library source intended for building other packages
which use "compression-bzip2" feature of "%{crate}" crate.
This package contains library source intended for building other packages which
use the "compression-bzip2" feature of the "%{crate}" crate.
%files -n %{name}+compression-bzip2-devel
%ghost %{cargo_registry}/%{crate}-%{version_no_tilde}/Cargo.toml
@ -98,8 +121,8 @@ BuildArch: noarch
%description -n %{name}+compression-deflate-devel %{_description}
This package contains library source intended for building other packages
which use "compression-deflate" feature of "%{crate}" crate.
This package contains library source intended for building other packages which
use the "compression-deflate" feature of the "%{crate}" crate.
%files -n %{name}+compression-deflate-devel
%ghost %{cargo_registry}/%{crate}-%{version_no_tilde}/Cargo.toml
@ -110,8 +133,8 @@ BuildArch: noarch
%description -n %{name}+crypto-nettle-devel %{_description}
This package contains library source intended for building other packages
which use "crypto-nettle" feature of "%{crate}" crate.
This package contains library source intended for building other packages which
use the "crypto-nettle" feature of the "%{crate}" crate.
%files -n %{name}+crypto-nettle-devel
%ghost %{cargo_registry}/%{crate}-%{version_no_tilde}/Cargo.toml
@ -122,8 +145,8 @@ BuildArch: noarch
%description -n %{name}+flate2-devel %{_description}
This package contains library source intended for building other packages
which use "flate2" feature of "%{crate}" crate.
This package contains library source intended for building other packages which
use the "flate2" feature of the "%{crate}" crate.
%files -n %{name}+flate2-devel
%ghost %{cargo_registry}/%{crate}-%{version_no_tilde}/Cargo.toml
@ -134,8 +157,8 @@ BuildArch: noarch
%description -n %{name}+nettle-devel %{_description}
This package contains library source intended for building other packages
which use "nettle" feature of "%{crate}" crate.
This package contains library source intended for building other packages which
use the "nettle" feature of the "%{crate}" crate.
%files -n %{name}+nettle-devel
%ghost %{cargo_registry}/%{crate}-%{version_no_tilde}/Cargo.toml
@ -155,7 +178,8 @@ which use "nettle" feature of "%{crate}" crate.
%if %{with check}
%check
%cargo_test
# * skip a broken test that claims that two identical strings are different
%cargo_test -- -- --skip packet::test::roundtrip
%endif
%changelog

@ -1,40 +1,40 @@
--- sequoia-openpgp-1.3.0/Cargo.toml 2021-06-08T09:54:24+00:00
+++ sequoia-openpgp-1.3.0/Cargo.toml 2021-06-22T10:03:03.567119+00:00
@@ -96,9 +96,6 @@
--- sequoia-openpgp-1.7.0/Cargo.toml 1970-01-01T00:00:01+00:00
+++ sequoia-openpgp-1.7.0/Cargo.toml 2022-01-18T18:14:10.083516+00:00
@@ -201,13 +201,6 @@
version = "1.1.0"
optional = true
[dependencies.unicode-normalization]
version = "0.1.9"
-[dependencies.xxhash-rust]
-version = "0.8"
-features = ["xxh3"]
-[dev-dependencies.criterion]
-version = "0.3.4"
-features = ["html_reports"]
-
[dev-dependencies.quickcheck]
version = "0.9"
@@ -117,37 +114,9 @@
version = "1"
default-features = false
@@ -230,33 +223,10 @@
compression = ["compression-deflate", "compression-bzip2"]
compression-bzip2 = ["bzip2", "buffered-reader/compression-bzip2"]
compression-deflate = ["flate2", "buffered-reader/compression-deflate"]
-crypto-cng = ["winapi", "win-crypto-ng", "ed25519-dalek", "num-bigint-dig"]
-crypto-cng = ["eax", "winapi", "win-crypto-ng", "ed25519-dalek", "num-bigint-dig"]
crypto-nettle = ["nettle"]
crypto-rust = ["aes", "block-modes", "block-padding", "blowfish", "cast5", "cipher", "des", "digest", "eax", "ed25519-dalek", "generic-array", "idea", "md-5", "num-bigint-dig", "rand07", "ripemd160", "rsa", "sha-1", "sha2", "twofish", "typenum", "x25519-dalek", "p256", "rand_core", "rand_core/getrandom", "ecdsa"]
default = ["compression", "crypto-nettle"]
-[target."cfg(all(target_arch = \"wasm32\", target_os = \"unknown\"))".dependencies.chrono]
-version = "0.4.10"
-features = ["std"]
-default-features = false
-[target."cfg(windows)".dependencies.eax]
-version = "0.3"
-[target."cfg(windows)".dependencies.ed25519-dalek]
-version = "1"
-features = ["rand", "u64_backend"]
-optional = true
-features = ["std", "wasmbind"]
-default-features = false
-
-[target."cfg(windows)".dependencies.num-bigint-dig]
-version = "0.6"
-optional = true
-default-features = false
-[target."cfg(all(target_arch = \"wasm32\", target_os = \"unknown\"))".dependencies.getrandom]
-version = "0.2"
-features = ["js"]
-
-[target."cfg(all(target_arch = \"wasm32\", target_os = \"unknown\"))".dependencies.rand07]
-version = "0.7"
-features = ["wasm-bindgen"]
-package = "rand"
-[target."cfg(windows)".dependencies.win-crypto-ng]
-version = "0.4"
-features = ["rand", "block-cipher"]
@ -45,6 +45,7 @@
-features = ["bcrypt"]
-optional = true
-default-features = false
+
[badges.gitlab]
repository = "sequoia-pgp/sequoia"

@ -1 +1 @@
SHA512 (sequoia-openpgp-1.3.0.crate) = a2bcd06a0deafb7df151e07a55b86e2fa96ee95715b1480081b6dedcd20388ba7a000646ebcc827af16fd75675843ccd38c1f20232a05f2d0d8370de7b9e8c24
SHA512 (sequoia-openpgp-1.7.0.crate) = 2f77d1aaee9257124143e3849441c5fb912740e16270cdefea2a4e73798e4a5ffed89fa1437643d9df8c53efbe649f162f42359e26fecd75f526bc2a11bee6fa

Loading…
Cancel
Save