diff options
author | Justus Winter <justus@sequoia-pgp.org> | 2023-04-07 12:54:31 +0200 |
---|---|---|
committer | Justus Winter <justus@sequoia-pgp.org> | 2023-04-07 14:51:42 +0200 |
commit | b72a2885aab21f9eff5ea817d8487016fbe11f37 (patch) | |
tree | 33da3161ef5eb387720b341662f96b062d225885 /openpgp/src/armor.rs | |
parent | 7ac5290ea4b4c0e9fbfe8b9fefd187d0f461e592 (diff) |
openpgp: Generalize test.
Diffstat (limited to 'openpgp/src/armor.rs')
-rw-r--r-- | openpgp/src/armor.rs | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/openpgp/src/armor.rs b/openpgp/src/armor.rs index c46ce6cc..fb6ac87b 100644 --- a/openpgp/src/armor.rs +++ b/openpgp/src/armor.rs @@ -2293,7 +2293,8 @@ mod test { types::HashAlgorithm, }; - fn f<R>(clearsig: &[u8], reference: R) -> crate::Result<()> + fn f<R>(clearsig: &[u8], reference: R, hash: HashAlgorithm) + -> crate::Result<()> where R: AsRef<[u8]> { let mut reader = Reader::from_buffered_reader_csft( @@ -2309,7 +2310,7 @@ mod test { // First, an one-pass-signature packet. if let Some(Packet::OnePassSig(ops)) = message.path_ref(&[0]) { - assert_eq!(ops.hash_algo(), HashAlgorithm::SHA256); + assert_eq!(ops.hash_algo(), hash); } else { panic!("expected an OPS packet"); } @@ -2319,7 +2320,7 @@ mod test { // And, the signature. if let Some(Packet::Signature(sig)) = message.path_ref(&[2]) { - assert_eq!(sig.hash_algo(), HashAlgorithm::SHA256); + assert_eq!(sig.hash_algo(), hash); } else { panic!("expected an signature packet"); } @@ -2339,7 +2340,7 @@ mod test { // The signature. if let Some(Packet::Signature(sig)) = pp.path_ref(&[0]) { - assert_eq!(sig.hash_algo(), HashAlgorithm::SHA256); + assert_eq!(sig.hash_algo(), hash); } else { panic!("expected an signature packet"); } @@ -2347,7 +2348,7 @@ mod test { } f(crate::tests::message("a-problematic-poem.txt.cleartext.sig"), - crate::tests::message("a-problematic-poem.txt"))?; + crate::tests::message("a-problematic-poem.txt"), HashAlgorithm::SHA256)?; f(crate::tests::message("a-cypherpunks-manifesto.txt.cleartext.sig"), { // The transformation process trims trailing whitespace, @@ -2358,7 +2359,7 @@ mod test { let ws = manifesto.remove(ws_at); assert_eq!(ws, b' '); manifesto - })?; + }, HashAlgorithm::SHA256)?; Ok(()) } } |