summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJustus Winter <justus@sequoia-pgp.org>2024-07-01 14:55:03 +0200
committerJustus Winter <justus@sequoia-pgp.org>2024-07-01 14:55:03 +0200
commit1835ed191a9b4582c0d7fb22a927835257b3d953 (patch)
tree094c7b3be6ac9d9d7274020dc498103bb6dcd630
parentba11dd963fef9eab321ff2e684377322f7dfa7dd (diff)
fixup! openpgp: Add support for v6 OPS packets, inline-signed messages.
-rw-r--r--openpgp/src/parse.rs18
1 files changed, 12 insertions, 6 deletions
diff --git a/openpgp/src/parse.rs b/openpgp/src/parse.rs
index 99c77bd5..4e2200b1 100644
--- a/openpgp/src/parse.rs
+++ b/openpgp/src/parse.rs
@@ -2316,9 +2316,8 @@ impl PacketParser<'_> {
let hash_algo = ops.hash_algo();
let typ = ops.typ();
- let salt = ops.salt();
- let need_hash = HashingMode::for_salt_and_type(
- hash_algo, salt.unwrap_or(&[]), typ);
+ let salt = ops.salt().unwrap_or(&[]);
+ let need_hash = HashingMode::for_salt_and_type(hash_algo, salt, typ);
let recursion_depth = self.recursion_depth();
let want_hashes_for = if Cookie::processing_csf_message(&self.reader) {
HashesFor::CleartextSignature
@@ -2347,10 +2346,11 @@ impl PacketParser<'_> {
mode.map(|ctx| ctx.algo()) == need_hash
})
{
+ let mut ctx = hash_algo.context()?;
+ ctx.update(&salt);
cookie.sig_group_mut().hashes.push(
HashingMode::for_salt_and_type(
- Box::new(hash_algo.context()?),
- salt.unwrap_or(&[]), typ));
+ Box::new(ctx), salt, typ));
}
break;
}
@@ -2422,6 +2422,7 @@ impl OnePassSig6 {
sig.set_hash_algo(hash_algo);
sig.set_pk_algo(pk_algo.into());
sig.set_last_raw(last);
+ let need_hash = HashingMode::for_salt_and_type(hash_algo, &salt, typ);
let recursion_depth = php.recursion_depth();
@@ -2458,8 +2459,13 @@ impl OnePassSig6 {
// Make sure that it uses the required
// hash algorithm.
if php.state.settings.automatic_hashing
+ && ! cookie.sig_group().hashes.iter()
+ .any(|mode| {
+ mode.map(|ctx| ctx.algo()) == need_hash
+ })
{
- if let Ok(ctx) = hash_algo.context() {
+ if let Ok(mut ctx) = hash_algo.context() {
+ ctx.update(&salt);
cookie.sig_group_mut().hashes.push(
HashingMode::for_salt_and_type(
Box::new(ctx), &salt, typ)