diff options
author | Justus Winter <justus@sequoia-pgp.org> | 2022-11-18 11:13:23 +0100 |
---|---|---|
committer | Justus Winter <justus@sequoia-pgp.org> | 2022-11-18 11:16:10 +0100 |
commit | 495f81e831f657bc5adb46d5f11320c9cb7ba442 (patch) | |
tree | acf979b861556298dc836ff43030cb2133f2789c /openpgp | |
parent | 40aaa2dd2f7e825efb18b6869c5a7a1724ab60fb (diff) |
openpgp: Improve tests with marker packets.
Diffstat (limited to 'openpgp')
-rw-r--r-- | openpgp/src/cert/parser/mod.rs | 8 | ||||
-rw-r--r-- | openpgp/src/message/mod.rs | 6 | ||||
-rw-r--r-- | openpgp/src/parse.rs | 18 |
3 files changed, 30 insertions, 2 deletions
diff --git a/openpgp/src/cert/parser/mod.rs b/openpgp/src/cert/parser/mod.rs index 32270b48..b98f286b 100644 --- a/openpgp/src/cert/parser/mod.rs +++ b/openpgp/src/cert/parser/mod.rs @@ -1205,6 +1205,14 @@ mod test { CertParser::from( PacketParser::from_bytes(&testy_with_marker).unwrap()) .next().unwrap().unwrap(); + + let mut testy_with_marker = Vec::new(); + testy_with_marker.extend_from_slice(crate::tests::key("testy.pgp")); + Packet::Marker(Default::default()) + .serialize(&mut testy_with_marker).unwrap(); + CertParser::from( + PacketParser::from_bytes(&testy_with_marker).unwrap()) + .next().unwrap().unwrap(); } #[test] diff --git a/openpgp/src/message/mod.rs b/openpgp/src/message/mod.rs index 5501d031..ec715380 100644 --- a/openpgp/src/message/mod.rs +++ b/openpgp/src/message/mod.rs @@ -776,6 +776,12 @@ mod tests { (Signature, None, 0)], result: true, }, + TestVector { + s: &[(OnePassSig, None, 0), (Literal, None, 0), + (Signature, None, 0), + (Marker, None, 0)], + result: true, + }, ]; for v in &test_vectors { diff --git a/openpgp/src/parse.rs b/openpgp/src/parse.rs index c7912584..9c365420 100644 --- a/openpgp/src/parse.rs +++ b/openpgp/src/parse.rs @@ -5762,14 +5762,27 @@ mod test { #[test] fn message_validator() { + for marker in 0..4 { + let marker_before = marker & 1 > 0; + let marker_after = marker & 2 > 0; + for test in DECRYPT_TESTS.iter() { if !test.algo.is_supported() { eprintln!("Algorithm {} unsupported, skipping", test.algo); continue; } - let mut ppr = PacketParserBuilder::from_bytes( - crate::tests::message(test.filename)).unwrap() + let mut buf = Vec::new(); + if marker_before { + Packet::Marker(Default::default()).serialize(&mut buf).unwrap(); + } + buf.extend_from_slice(crate::tests::message(test.filename)); + if marker_after { + Packet::Marker(Default::default()).serialize(&mut buf).unwrap(); + } + + let mut ppr = PacketParserBuilder::from_bytes(&buf) + .unwrap() .build() .expect(&format!("Error reading {}", test.filename)[..]); @@ -5800,6 +5813,7 @@ mod test { unreachable!(); } } + } } #[test] |