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 /openpgp-ffi/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 'openpgp-ffi/examples')
-rw-r--r-- | openpgp-ffi/examples/decrypt-with.c | 4 | ||||
-rw-r--r-- | openpgp-ffi/examples/encrypt-for.c | 4 |
2 files changed, 6 insertions, 2 deletions
diff --git a/openpgp-ffi/examples/decrypt-with.c b/openpgp-ffi/examples/decrypt-with.c index 3f98c574..e288efbf 100644 --- a/openpgp-ffi/examples/decrypt-with.c +++ b/openpgp-ffi/examples/decrypt-with.c @@ -203,6 +203,7 @@ main (int argc, char **argv) pgp_reader_t plaintext; uint8_t buf[1024]; ssize_t nread; + pgp_policy_t policy = pgp_standard_policy (); if (argc != 2) error (1, 0, "Usage: %s <keyfile> <cipher >plain", argv[0]); @@ -218,7 +219,7 @@ main (int argc, char **argv) .key = cert, .decrypt_called = 0, }; - plaintext = pgp_decryptor_new (&err, source, + plaintext = pgp_decryptor_new (&err, policy, source, get_public_keys_cb, decrypt_cb, check_cb, NULL, &cookie, 0); if (! plaintext) @@ -233,5 +234,6 @@ main (int argc, char **argv) pgp_reader_free (plaintext); pgp_reader_free (source); pgp_cert_free (cert); + pgp_policy_free (policy); return 0; } diff --git a/openpgp-ffi/examples/encrypt-for.c b/openpgp-ffi/examples/encrypt-for.c index aeb4dea4..27a7a585 100644 --- a/openpgp-ffi/examples/encrypt-for.c +++ b/openpgp-ffi/examples/encrypt-for.c @@ -28,6 +28,7 @@ main (int argc, char **argv) pgp_cert_t cert; pgp_writer_t sink; pgp_writer_stack_t writer = NULL; + pgp_policy_t policy = pgp_standard_policy (); if (argc != 2) error (1, 0, "Usage: %s <keyfile> <plain >cipher", argv[0]); @@ -36,7 +37,7 @@ main (int argc, char **argv) if (cert == NULL) error (1, 0, "pgp_cert_from_file: %s", pgp_error_to_string (err)); - pgp_cert_valid_key_iter_t iter = pgp_cert_valid_key_iter (cert, 0); + pgp_cert_valid_key_iter_t iter = pgp_cert_valid_key_iter (cert, policy, 0); pgp_cert_valid_key_iter_alive (iter); pgp_cert_valid_key_iter_revoked (iter, false); pgp_cert_valid_key_iter_for_storage_encryption (iter); @@ -91,5 +92,6 @@ main (int argc, char **argv) pgp_recipient_free (recipients[i]); free (recipients); pgp_cert_free (cert); + pgp_policy_free (policy); return 0; } |