diff options
author | Neal H. Walfield <neal@pep.foundation> | 2020-01-31 14:20:53 +0100 |
---|---|---|
committer | Neal H. Walfield <neal@pep.foundation> | 2020-01-31 15:59:16 +0100 |
commit | a464ce819ccd1fa07ff8c6d0be74cff5eec5cf34 (patch) | |
tree | 31ed9d18b9c7802a93b4e4c8e6e85d1121b201d8 /examples | |
parent | b9b6533bd5394cd5cdb6b91b5c5ca7a02e3ea199 (diff) |
openpgp: Add a policy object.
- Change all functions that need to evaluate the validity of a
signature (either directly or indirectly to take a policy object.
- Use the policy object to allow the user to place additional
constraints on a signature's validity.
- This addresses the first half of #274 (it introduces the policy
object, but does not yet implement any policy).
Diffstat (limited to 'examples')
-rw-r--r-- | examples/guide-exploring-openpgp.rs | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/examples/guide-exploring-openpgp.rs b/examples/guide-exploring-openpgp.rs index e70c6361..05a777e4 100644 --- a/examples/guide-exploring-openpgp.rs +++ b/examples/guide-exploring-openpgp.rs @@ -2,8 +2,11 @@ extern crate sequoia_openpgp as openpgp; use crate::openpgp::parse::Parse; +use crate::openpgp::policy::StandardPolicy as P; fn main() { + let p = &P::new(); + let cert = "-----BEGIN PGP PUBLIC KEY BLOCK----- @@ -52,7 +55,7 @@ fn main() { println!("Fingerprint: {}", cert.fingerprint()); // List userids. - for (i, ca) in cert.userids().policy(None).enumerate() { + for (i, ca) in cert.userids().set_policy(p, None).enumerate() { println!("{}: UID: {}, {} self-signature(s), {} certification(s)", i, ca.userid(), ca.binding().self_signatures().len(), @@ -60,7 +63,7 @@ fn main() { } // List subkeys. - for (i, ka) in cert.keys().policy(None).skip(1).enumerate() { + for (i, ka) in cert.keys().set_policy(p, None).skip(1).enumerate() { println!("{}: Fingerprint: {}, {} self-signature(s), {} certification(s)", i, ka.key().fingerprint(), ka.binding().self_signatures().len(), |