summaryrefslogtreecommitdiffstats
path: root/openpgp/src/cert.rs
diff options
context:
space:
mode:
authorJustus Winter <justus@sequoia-pgp.org>2023-07-06 18:24:59 +0200
committerJustus Winter <justus@sequoia-pgp.org>2023-07-06 20:22:58 +0200
commit9cde4b27309582715edc0692501a5df9d62c9f17 (patch)
treef909f071e9660316f94f04f41da5f6dac18630d5 /openpgp/src/cert.rs
parent00a2fc56ed639ae0210e44f53ba4fe474fdb79c0 (diff)
openpgp: Fix hashing v3 signatures.
- The high-level hashing functions are implemented on SignatureFields (so that we can use them from the SignatureBuilder). Unfortunately, when those functions invoke SignatureFields::hash, the type encoding the packet version has been erased. - Recover the version at runtime and dispatch to the right hashing function.
Diffstat (limited to 'openpgp/src/cert.rs')
-rw-r--r--openpgp/src/cert.rs28
1 files changed, 28 insertions, 0 deletions
diff --git a/openpgp/src/cert.rs b/openpgp/src/cert.rs
index 23050580..0170b0e8 100644
--- a/openpgp/src/cert.rs
+++ b/openpgp/src/cert.rs
@@ -7247,4 +7247,32 @@ Pu1xwz57O4zo1VYf6TqHJzVC3OMvMUM2hhdecMUe5x6GorNaj6g=
Ok(())
}
+
+ /// Tests v3 binding signatures.
+ #[test]
+ fn v3_binding_signature() -> Result<()> {
+ if ! crate::types::PublicKeyAlgorithm::DSA.is_supported() {
+ eprintln!("Skipping because DSA is not supported");
+ return Ok(());
+ }
+
+ let c = Cert::from_bytes(
+ crate::tests::key("pgp5-dsa-elg-v3-subkey-binding.pgp"))?;
+ assert_eq!(c.bad_signatures().count(), 0);
+
+ let np = crate::policy::NullPolicy::new();
+
+ // The subkey is interesting because it is bound using a v3
+ // signature.
+ let vcert = c.with_policy(&np, None)?;
+ assert_eq!(vcert.keys().subkeys().count(), 1);
+
+ // XXX: Unfortunately, it being a v3 signature, the subkey has
+ // no keyflags, limiting its usefulness for now.
+
+ // The subkey is interesting because it is bound using a v3
+ // signature.
+ assert_eq!(c.keys().subkeys().with_policy(&np, None).count(), 1);
+ Ok(())
+ }
}