summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJustus Winter <justus@sequoia-pgp.org>2023-04-07 13:40:50 +0200
committerJustus Winter <justus@sequoia-pgp.org>2023-11-07 12:18:40 +0100
commit8ea1846baffea8af868ed0a533b61da0edb5331d (patch)
treec89f7941484525ed348645da0f5d652c47817f35
parent0cebc44a178f9c43e5f68de5d8df6e7c553efe1d (diff)
openpgp: Implement the v6 cleartext signature framework.crypto-refresh-signatures-and-keys
TODO: reject headers
-rw-r--r--openpgp/src/armor.rs18
-rw-r--r--openpgp/src/parse/stream.rs16
-rw-r--r--openpgp/tests/data/crypto-refresh/cleartext-signed-message.txt16
-rw-r--r--openpgp/tests/data/crypto-refresh/cleartext-signed-message.txt.plain5
4 files changed, 37 insertions, 18 deletions
diff --git a/openpgp/src/armor.rs b/openpgp/src/armor.rs
index 7d0baa2a..b8993048 100644
--- a/openpgp/src/armor.rs
+++ b/openpgp/src/armor.rs
@@ -1483,7 +1483,7 @@ impl<'a> Reader<'a> {
let mut opss = Vec::with_capacity(sigs.len());
for p in sigs.iter().rev() {
if let Packet::Signature(sig) = p {
- if let Ok(ops) = OnePassSig3::try_from(sig) {
+ if let Ok(ops) = OnePassSig::try_from(sig) {
opss.push(ops);
}
}
@@ -2383,19 +2383,9 @@ mod test {
assert_eq!(reference.pop(), Some(b'\n'));
reference
}, HashAlgorithm::SHA256)?;
- f(crate::tests::message("a-cypherpunks-manifesto.txt.cleartext.sig"),
- {
- // The test vector, created by GnuPG, does not preserve
- // the final newline.
- //
- // The transformation process trims trailing whitespace,
- // and the manifesto has a trailing whitespace right at
- // the end.
- let mut manifesto = crate::tests::manifesto().to_vec();
- assert_eq!(manifesto.pop(), Some(b'\n'));
- assert_eq!(manifesto.pop(), Some(b' '));
- manifesto
- }, HashAlgorithm::SHA256)?;
+ f(crate::tests::file("crypto-refresh/cleartext-signed-message.txt"),
+ crate::tests::file("crypto-refresh/cleartext-signed-message.txt.plain"),
+ HashAlgorithm::SHA512)?;
Ok(())
}
}
diff --git a/openpgp/src/parse/stream.rs b/openpgp/src/parse/stream.rs
index 870c728f..94beb199 100644
--- a/openpgp/src/parse/stream.rs
+++ b/openpgp/src/parse/stream.rs
@@ -3176,11 +3176,12 @@ pub mod test {
let p = P::new();
let certs = [
- "neal.pgp",
- "testy-new.pgp",
- "emmelie-dorothea-dina-samantha-awina-ed25519.pgp"
+ "keys/neal.pgp",
+ "keys/testy-new.pgp",
+ "keys/emmelie-dorothea-dina-samantha-awina-ed25519.pgp",
+ "crypto-refresh/v6-minimal-cert.key",
].iter()
- .map(|f| Cert::from_bytes(crate::tests::key(f)).unwrap())
+ .map(|f| Cert::from_bytes(crate::tests::file(f)).unwrap())
.collect::<Vec<_>>();
let tests = &[
// Signed messages.
@@ -3244,6 +3245,13 @@ pub mod test {
false,
None,
VHelper::new(1, 0, 0, 0, certs.clone())),
+ (crate::tests::file("crypto-refresh/cleartext-signed-message.txt")
+ .to_vec(),
+ crate::tests::file("crypto-refresh/cleartext-signed-message.txt.plain")
+ .to_vec(),
+ false,
+ None,
+ VHelper::new(1, 0, 0, 0, certs.clone())),
// A key as example of an invalid message.
(crate::tests::key("neal.pgp").to_vec(),
crate::tests::manifesto().to_vec(),
diff --git a/openpgp/tests/data/crypto-refresh/cleartext-signed-message.txt b/openpgp/tests/data/crypto-refresh/cleartext-signed-message.txt
new file mode 100644
index 00000000..8a02b102
--- /dev/null
+++ b/openpgp/tests/data/crypto-refresh/cleartext-signed-message.txt
@@ -0,0 +1,16 @@
+-----BEGIN PGP SIGNED MESSAGE-----
+SaltedHash: SHA512:dklfUCGIkPf14u48GCJRT3BQD1UdhuXJIeQE40pT+6w
+
+What we need from the grocery store:
+
+- - tofu
+- - vegetables
+- - noodles
+
+-----BEGIN PGP SIGNATURE-----
+
+wpgGARsKAAAAKQWCY5ijYyIhBssYbE8GCaaX5NUt+mxyKwwfHifBilZwj2Ul7Ce6
+2azJAAAAAGk2IHZJX1AhiJD39eLuPBgiUU9wUA9VHYblySHkBONKU/usJ9BvuAqo
+/FvLFuGWMbKAdA+epq7V4HOtAPlBWmU8QOd6aud+aSunHQaaEJ+iTFjP2OMW0KBr
+NK2ay45cX1IVAQ==
+-----END PGP SIGNATURE-----
diff --git a/openpgp/tests/data/crypto-refresh/cleartext-signed-message.txt.plain b/openpgp/tests/data/crypto-refresh/cleartext-signed-message.txt.plain
new file mode 100644
index 00000000..d812d543
--- /dev/null
+++ b/openpgp/tests/data/crypto-refresh/cleartext-signed-message.txt.plain
@@ -0,0 +1,5 @@
+What we need from the grocery store:
+
+- tofu
+- vegetables
+- noodles