summaryrefslogtreecommitdiffstats
path: root/openpgp/tests
diff options
context:
space:
mode:
authorNeal H. Walfield <neal@pep.foundation>2020-10-16 18:59:01 +0200
committerNeal H. Walfield <neal@pep.foundation>2020-10-18 08:16:39 +0200
commite2fbf5b9d442f156ee433a3e46c98ec3dc89cc61 (patch)
treeddc3e436866ea5cf9c8776647fbc9ec68a30250a /openpgp/tests
parent3b1856444ef7c618f78f987868ee336207dca62d (diff)
openpgp: Change Cert::into_packets to not drop any information.
- Change `Cert::into_packets` to return the underlying packets. That is don't drop secret key material like `Cert::serialize` does.
Diffstat (limited to 'openpgp/tests')
-rw-r--r--openpgp/tests/for-each-artifact.rs18
1 files changed, 15 insertions, 3 deletions
diff --git a/openpgp/tests/for-each-artifact.rs b/openpgp/tests/for-each-artifact.rs
index 014bf18d..5aa23881 100644
--- a/openpgp/tests/for-each-artifact.rs
+++ b/openpgp/tests/for-each-artifact.rs
@@ -76,11 +76,23 @@ mod for_each_artifact {
assert_eq!(v, w,
"Serialize and SerializeInto disagree on {:?}", p);
- // Check that Cert::into_packets() and Cert::to_vec()
- // agree.
+ // Check that
+ // Cert::strip_secret_key_material().into_packets() and
+ // Cert::to_vec() agree. (Cert::into_packets() returns
+ // secret keys if secret key material is present;
+ // Cert::to_vec only ever returns public keys.)
let v = p.to_vec()?;
let mut buf = Vec::new();
- for p in p.clone().into_packets() {
+ for p in p.clone().strip_secret_key_material().into_packets() {
+ p.serialize(&mut buf)?;
+ }
+ assert_eq!(buf, v);
+
+ // Check that Cert::into_packets() and
+ // Cert::as_tsk().to_vec() agree.
+ let v = p.as_tsk().to_vec()?;
+ let mut buf = Vec::new();
+ for p in p.into_packets() {
p.serialize(&mut buf)?;
}
assert_eq!(buf, v);