summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--guide/src/chapter_01.md8
-rw-r--r--guide/src/chapter_02.md8
-rw-r--r--ipc/examples/gpg-agent-decrypt.rs2
-rw-r--r--ipc/examples/gpg-agent-sign.rs2
-rw-r--r--ipc/tests/gpg-agent.rs12
-rw-r--r--net/src/lib.rs2
-rw-r--r--openpgp-ffi/examples/decrypt-with.c2
-rw-r--r--openpgp-ffi/examples/encrypt-for.c4
-rw-r--r--openpgp-ffi/include/sequoia/openpgp.h25
-rw-r--r--openpgp-ffi/src/cert.rs35
-rw-r--r--openpgp-ffi/src/parse/stream.rs2
-rw-r--r--openpgp/examples/decrypt-with.rs2
-rw-r--r--openpgp/examples/encrypt-for.rs4
-rw-r--r--openpgp/examples/generate-encrypt-decrypt.rs2
-rw-r--r--openpgp/examples/generate-sign-verify.rs2
-rw-r--r--openpgp/examples/notarize.rs4
-rw-r--r--openpgp/examples/pad.rs4
-rw-r--r--openpgp/examples/sign-detached.rs4
-rw-r--r--openpgp/examples/sign.rs4
-rw-r--r--openpgp/src/cert/bindings.rs8
-rw-r--r--openpgp/src/cert/builder.rs4
-rw-r--r--openpgp/src/cert/keyiter.rs34
-rw-r--r--openpgp/src/cert/mod.rs40
-rw-r--r--openpgp/src/crypto/keygrip.rs2
-rw-r--r--openpgp/src/crypto/mpis.rs2
-rw-r--r--openpgp/src/packet/signature/mod.rs2
-rw-r--r--openpgp/src/parse/stream.rs6
-rw-r--r--openpgp/src/serialize/cert.rs4
-rw-r--r--openpgp/src/serialize/stream.rs20
-rw-r--r--sqv/src/sqv.rs4
-rw-r--r--store/src/backend/mod.rs2
-rw-r--r--tool/src/commands/mod.rs8
-rw-r--r--tool/tests/sq-sign.rs2
33 files changed, 112 insertions, 154 deletions
diff --git a/guide/src/chapter_01.md b/guide/src/chapter_01.md
index 6368a9eb..56c131fb 100644
--- a/guide/src/chapter_01.md
+++ b/guide/src/chapter_01.md
@@ -51,7 +51,7 @@ fn main() {
# fn sign(sink: &mut Write, plaintext: &str, tsk: &openpgp::Cert)
# -> openpgp::Result<()> {
# // Get the keypair to do the signing from the Cert.
-# let keypair = tsk.keys_valid().for_signing().nth(0).unwrap().
+# let keypair = tsk.keys().alive().revoked(false).for_signing().nth(0).unwrap().
# key().clone().mark_parts_secret().unwrap().into_keypair()?;
#
# // Start streaming an OpenPGP message.
@@ -196,7 +196,7 @@ fn generate() -> openpgp::Result<openpgp::Cert> {
# fn sign(sink: &mut Write, plaintext: &str, tsk: &openpgp::Cert)
# -> openpgp::Result<()> {
# // Get the keypair to do the signing from the Cert.
-# let keypair = tsk.keys_valid().for_signing().nth(0).unwrap().
+# let keypair = tsk.keys().alive().revoked(false).for_signing().nth(0).unwrap().
# key().clone().mark_parts_secret().unwrap().into_keypair()?;
#
# // Start streaming an OpenPGP message.
@@ -341,7 +341,7 @@ implements [`io::Write`], and we simply write the plaintext to it.
fn sign(sink: &mut Write, plaintext: &str, tsk: &openpgp::Cert)
-> openpgp::Result<()> {
// Get the keypair to do the signing from the Cert.
- let keypair = tsk.keys_valid().for_signing().nth(0).unwrap().
+ let keypair = tsk.keys().alive().revoked(false).for_signing().nth(0).unwrap().
key().clone().mark_parts_secret().unwrap().into_keypair()?;
// Start streaming an OpenPGP message.
@@ -497,7 +497,7 @@ Verified data can be read from this using [`io::Read`].
# fn sign(sink: &mut Write, plaintext: &str, tsk: &openpgp::Cert)
# -> openpgp::Result<()> {
# // Get the keypair to do the signing from the Cert.
-# let keypair = tsk.keys_valid().for_signing().nth(0).unwrap().
+# let keypair = tsk.keys().alive().revoked(false).for_signing().nth(0).unwrap().
# key().clone().mark_parts_secret().unwrap().into_keypair()?;
#
# // Start streaming an OpenPGP message.
diff --git a/guide/src/chapter_02.md b/guide/src/chapter_02.md
index e1687803..9f4c3a0a 100644
--- a/guide/src/chapter_02.md
+++ b/guide/src/chapter_02.md
@@ -51,7 +51,7 @@ fn main() {
# -> openpgp::Result<()> {
# // Build a vector of recipients to hand to Encryptor.
# let mut recipients =
-# recipient.keys_valid()
+# recipient.keys().alive().revoked(false)
# .for_transport_encryption()
# .map(|ka| ka.key().into())
# .collect::<Vec<_>>();
@@ -192,7 +192,7 @@ fn generate() -> openpgp::Result<openpgp::Cert> {
# -> openpgp::Result<()> {
# // Build a vector of recipients to hand to Encryptor.
# let mut recipients =
-# recipient.keys_valid()
+# recipient.keys().alive().revoked(false)
# .for_transport_encryption()
# .map(|ka| ka.key().into())
# .collect::<Vec<_>>();
@@ -333,7 +333,7 @@ fn encrypt(sink: &mut Write, plaintext: &str, recipient: &openpgp::Cert)
-> openpgp::Result<()> {
// Build a vector of recipients to hand to Encryptor.
let mut recipients =
- recipient.keys_valid()
+ recipient.keys().alive().revoked(false)
.for_transport_encryption()
.map(|ka| ka.key().into())
.collect::<Vec<_>>();
@@ -488,7 +488,7 @@ Decrypted data can be read from this using [`io::Read`].
# -> openpgp::Result<()> {
# // Build a vector of recipients to hand to Encryptor.
# let mut recipients =
-# recipient.keys_valid()
+# recipient.keys().alive().revoked(false)
# .for_transport_encryption()
# .map(|ka| ka.key().into())
# .collect::<Vec<_>>();
diff --git a/ipc/examples/gpg-agent-decrypt.rs b/ipc/examples/gpg-agent-decrypt.rs
index 381bab6d..2b9252cc 100644
--- a/ipc/examples/gpg-agent-decrypt.rs
+++ b/ipc/examples/gpg-agent-decrypt.rs
@@ -74,7 +74,7 @@ impl<'a> Helper<'a> {
// Map (sub)KeyIDs to secrets.
let mut keys = HashMap::new();
for cert in certs {
- for ka in cert.keys_all() {
+ for ka in cert.keys() {
if ka.binding_signature(None)
.map(|s| (s.key_flags().for_storage_encryption()
|| s.key_flags().for_transport_encryption()))
diff --git a/ipc/examples/gpg-agent-sign.rs b/ipc/examples/gpg-agent-sign.rs
index dfc3f304..b5f32a9c 100644
--- a/ipc/examples/gpg-agent-sign.rs
+++ b/ipc/examples/gpg-agent-sign.rs
@@ -39,7 +39,7 @@ fn main() {
// Construct a KeyPair for every signing-capable (sub)key.
let mut signers = certs.iter().flat_map(|cert| {
- cert.keys_valid().for_signing().filter_map(|ka| {
+ cert.keys().alive().revoked(false).for_signing().filter_map(|ka| {
KeyPair::new(&ctx, ka.key()).ok()
})
}).collect::<Vec<KeyPair>>();
diff --git a/ipc/tests/gpg-agent.rs b/ipc/tests/gpg-agent.rs
index 6a74ffa3..889402b5 100644
--- a/ipc/tests/gpg-agent.rs
+++ b/ipc/tests/gpg-agent.rs
@@ -95,7 +95,9 @@ fn sign() {
gpg_import(&ctx, &buf);
let keypair = KeyPair::new(
- &ctx, cert.keys_valid().for_signing().take(1).next().unwrap().key())
+ &ctx,
+ cert.keys().alive().revoked(false)
+ .for_signing().take(1).next().unwrap().key())
.unwrap();
let mut message = Vec::new();
@@ -208,7 +210,8 @@ fn decrypt() {
let mut message = Vec::new();
{
let recipient =
- cert.keys_valid().key_flags(
+ cert.keys().alive().revoked(false)
+ .key_flags(
KeyFlags::default().set_transport_encryption(true))
.map(|ka| ka.key().into())
.nth(0).unwrap();
@@ -275,8 +278,9 @@ fn decrypt() {
{
let mut keypair = KeyPair::new(
self.ctx,
- self.cert.keys_valid().key_flags(
- KeyFlags::default().set_transport_encryption(true))
+ self.cert.keys().alive().revoked(false).
+ key_flags(
+ KeyFlags::default().set_transport_encryption(true))
.take(1).next().unwrap().key())
.unwrap();
diff --git a/net/src/lib.rs b/net/src/lib.rs
index a7746727..8f91ce18 100644
--- a/net/src/lib.rs
+++ b/net/src/lib.rs
@@ -183,7 +183,7 @@ impl KeyServer {
Some(armor::Kind::PublicKey)));
match Cert::from_reader(r) {
Ok(cert) => {
- if cert.keys_all().any(|ka| {
+ if cert.keys().any(|ka| {
KeyID::from(ka.key().fingerprint())
== keyid_want
}) {
diff --git a/openpgp-ffi/examples/decrypt-with.c b/openpgp-ffi/examples/decrypt-with.c
index 423106bd..c85b96f8 100644
--- a/openpgp-ffi/examples/decrypt-with.c
+++ b/openpgp-ffi/examples/decrypt-with.c
@@ -155,7 +155,7 @@ decrypt_cb (void *cookie_opaque,
pgp_pkesk_t pkesk = pkesks[i];
pgp_keyid_t keyid = pgp_pkesk_recipient (pkesk);
- pgp_cert_key_iter_t key_iter = pgp_cert_key_iter_all (cookie->key);
+ pgp_cert_key_iter_t key_iter = pgp_cert_key_iter (cookie->key);
pgp_key_t key;
while ((key = pgp_cert_key_iter_next (key_iter, NULL, NULL))) {
pgp_keyid_t this_keyid = pgp_key_keyid (key);
diff --git a/openpgp-ffi/examples/encrypt-for.c b/openpgp-ffi/examples/encrypt-for.c
index 8303f8ee..65bd8a45 100644
--- a/openpgp-ffi/examples/encrypt-for.c
+++ b/openpgp-ffi/examples/encrypt-for.c
@@ -36,7 +36,9 @@ main (int argc, char **argv)
if (cert == NULL)
error (1, 0, "pgp_cert_from_file: %s", pgp_error_to_string (err));
- pgp_cert_key_iter_t iter = pgp_cert_key_iter_valid (cert);
+ pgp_cert_key_iter_t iter = pgp_cert_key_iter (cert);
+ pgp_cert_key_iter_alive (iter);
+ pgp_cert_key_iter_revoked (iter, false);
pgp_cert_key_iter_for_storage_encryption (iter);
pgp_cert_key_iter_for_transport_encryption (iter);
size_t recipients_len;
diff --git a/openpgp-ffi/include/sequoia/openpgp.h b/openpgp-ffi/include/sequoia/openpgp.h
index 4d6d8416..4468ccb5 100644
--- a/openpgp-ffi/include/sequoia/openpgp.h
+++ b/openpgp-ffi/include/sequoia/openpgp.h
@@ -912,30 +912,9 @@ pgp_user_id_binding_iter_t pgp_cert_user_id_binding_iter (pgp_cert_t cert);
/// Returns an iterator over all `Key`s in a Cert.
///
/// That is, this returns an iterator over the primary key and any
-/// subkeys, along with the corresponding signatures.
-///
-/// Note: since a primary key is different from a subkey, the iterator
-/// is over `Key`s and not `SubkeyBindings`. Since the primary key
-/// has no binding signature, the signature carrying the primary key's
-/// key flags is returned (either a direct key signature, or the
-/// self-signature on the primary User ID). There are corner cases
-/// where no such signature exists (e.g. partial Certs), therefore this
-/// iterator may return `None` for the primary key's signature.
-///
-/// A valid `Key` has at least one good self-signature.
-///
-/// Compare with `pgp_cert_key_iter_valid`, which filters out expired and
-/// revoked keys.
-/*/
-pgp_cert_key_iter_t pgp_cert_key_iter_all (pgp_cert_t cert);
-
-/*/
-/// Returns an iterator over the live and unrevoked `Key`s in a Cert.
-///
-/// Compare with `pgp_cert_key_iter_all`, which doesn't filter out
-/// expired and revoked keys by default.
+/// subkeys.
/*/
-pgp_cert_key_iter_t pgp_cert_key_iter_valid (pgp_cert_t cert);
+pgp_cert_key_iter_t pgp_cert_key_iter (pgp_cert_t cert);
/*/
/// Returns the Cert's primary user id (if any).
diff --git a/openpgp-ffi/src/cert.rs b/openpgp-ffi/src/cert.rs
index 2791ad1c..0c91dd88 100644
--- a/openpgp-ffi/src/cert.rs
+++ b/openpgp-ffi/src/cert.rs
@@ -436,44 +436,17 @@ pub struct KeyIterWrapper<'a> {
next_called: bool,
}
-/// Returns an iterator over the Cert's live, non-revoked keys.
-///
-/// That is, this returns an iterator over the primary key and any
-/// subkeys, along with the corresponding signatures.
-///
-/// Note: since a primary key is different from a subkey, the iterator
-/// is over `Key`s and not `SubkeyBindings`. Since the primary key
-/// has no binding signature, the signature carrying the primary key's
-/// key flags is returned (either a direct key signature, or the
-/// self-signature on the primary User ID). There are corner cases
-/// where no such signature exists (e.g. partial Certs), therefore this
-/// iterator may return `None` for the primary key's signature.
-///
-/// A valid `Key` has at least one good self-signature.
-///
-/// To return all keys, use `pgp_cert_key_iter_all()`.
-#[::sequoia_ffi_macros::extern_fn] #[no_mangle]
-pub extern "C" fn pgp_cert_key_iter_valid(cert: *const Cert)
- -> *mut KeyIterWrapper<'static>
-{
- let cert = cert.ref_raw();
- box_raw!(KeyIterWrapper {
- iter: cert.keys_valid(),
- next_called: false,
- })
-}
-
/// Returns an iterator over all `Key`s in a Cert.
///
-/// Compare with `pgp_cert_key_iter_valid`, which filters out expired
-/// and revoked keys by default.
+/// That is, this returns an iterator over the primary key and any
+/// subkeys.
#[::sequoia_ffi_macros::extern_fn] #[no_mangle]
-pub extern "C" fn pgp_cert_key_iter_all(cert: *const Cert)
+pub extern "C" fn pgp_cert_key_iter(cert: *const Cert)
-> *mut KeyIterWrapper<'static>
{
let cert = cert.ref_raw();
box_raw!(KeyIterWrapper {
- iter: cert.keys_all(),
+ iter: cert.keys(),
next_called: false,
})
}
diff --git a/openpgp-ffi/src/parse/stream.rs b/openpgp-ffi/src/parse/stream.rs
index f3b5b32f..3478b141 100644
--- a/openpgp-ffi/src/parse/stream.rs
+++ b/openpgp-ffi/src/parse/stream.rs
@@ -816,7 +816,7 @@ impl DecryptionHelper for DHelper {
/// pgp_pkesk_t pkesk = pkesks[i];
/// pgp_keyid_t keyid = pgp_pkesk_recipient (pkesk);
///
-/// pgp_cert_key_iter_t key_iter = pgp_cert_key_iter_all (cookie->key);
+/// pgp_cert_key_iter_t key_iter = pgp_cert_key_iter (cookie->key);
/// pgp_key_t key;
/// while ((key = pgp_cert_key_iter_next (key_iter, NULL, NULL))) {
/// pgp_keyid_t this_keyid = pgp_key_keyid (key);
diff --git a/openpgp/examples/decrypt-with.rs b/openpgp/examples/decrypt-with.rs
index 7c924cc9..27977048 100644
--- a/openpgp/examples/decrypt-with.rs
+++ b/openpgp/examples/decrypt-with.rs
@@ -58,7 +58,7 @@ impl Helper {
// Map (sub)KeyIDs to secrets.
let mut keys = HashMap::new();
for cert in certs {
- for ka in cert.keys_all() {
+ for ka in cert.keys() {
if ka.binding_signature(None)
.map(|s| (s.key_flags().for_storage_encryption()
|| s.key_flags().for_transport_encryption()))
diff --git a/openpgp/examples/encrypt-for.rs b/openpgp/examples/encrypt-for.rs
index eceec5b3..93eba5b5 100644
--- a/openpgp/examples/encrypt-for.rs
+++ b/openpgp/examples/encrypt-for.rs
@@ -37,7 +37,9 @@ fn main() {
// Build a vector of recipients to hand to Encryptor.
let mut recipients =
certs.iter()
- .flat_map(|cert| cert.keys_valid().key_flags(mode.clone()))
+ .flat_map(|cert| {
+ cert.keys().alive().revoked(false).key_flags(mode.clone())
+ })
.map(|ka| ka.key().into())
.collect::<Vec<_>>();
diff --git a/openpgp/examples/generate-encrypt-decrypt.rs b/openpgp/examples/generate-encrypt-decrypt.rs
index 01782b47..416a4b73 100644
--- a/openpgp/examples/generate-encrypt-decrypt.rs
+++ b/openpgp/examples/generate-encrypt-decrypt.rs
@@ -42,7 +42,7 @@ fn encrypt(sink: &mut dyn Write, plaintext: &str, recipient: &openpgp::Cert)
-> openpgp::Result<()> {
// Build a vector of recipients to hand to Encryptor.
let mut recipients =
- recipient.keys_valid()
+ recipient.keys().alive().revoked(false)
.for_transport_encryption()
.map(|ka| ka.key().into())
.collect::<Vec<_>>();
diff --git a/openpgp/examples/generate-sign-verify.rs b/openpgp/examples/generate-sign-verify.rs
index 1cccac44..a51ff031 100644
--- a/openpgp/examples/generate-sign-verify.rs
+++ b/openpgp/examples/generate-sign-verify.rs
@@ -40,7 +40,7 @@ fn generate() -> openpgp::Result<openpgp::Cert> {
fn sign(sink: &mut dyn Write, plaintext: &str, tsk: &openpgp::Cert)
-> openpgp::Result<()> {
// Get the keypair to do the signing from the Cert.
- let keypair = tsk.keys_valid().for_signing().nth(0).unwrap()
+ let keypair = tsk.keys().alive().revoked(false).for_signing().nth(0).unwrap()
.key().clone().mark_parts_secret().unwrap().into_keypair()?;
// Start streaming an OpenPGP message.
diff --git a/openpgp/examples/notarize.rs b/openpgp/examples/notarize.rs
index f52466f4..fec7419b 100644
--- a/openpgp/examples/notarize.rs
+++ b/openpgp/examples/notarize.rs
@@ -28,7 +28,9 @@ fn main() {
.expect("Failed to read key");
let mut n = 0;
- for key in tsk.keys_valid().for_signing().secret().map(|ka| ka.key()) {
+ for key in tsk.keys().alive().revoked(false).for_signing().secret()
+ .map(|ka| ka.key())
+ {
keys.push({
let mut key = key.clone();
if key.secret().expect("filtered").is_encrypted() {
diff --git a/openpgp/examples/pad.rs b/openpgp/examples/pad.rs
index 32583a42..95625f51 100644
--- a/openpgp/examples/pad.rs
+++ b/openpgp/examples/pad.rs
@@ -39,7 +39,9 @@ fn main() {
// Build a vector of recipients to hand to Encryptor.
let mut recipients =
certs.iter()
- .flat_map(|cert| cert.keys_valid().key_flags(mode.clone()))
+ .flat_map(|cert| {
+ cert.keys().alive().revoked(false).key_flags(mode.clone())
+ })
.map(|ka| Recipient::new(KeyID::wildcard(), ka.key()))
.collect::<Vec<_>>();
diff --git a/openpgp/examples/sign-detached.rs b/openpgp/examples/sign-detached.rs
index 20d4150b..eea08f08 100644
--- a/openpgp/examples/sign-detached.rs
+++ b/openpgp/examples/sign-detached.rs
@@ -24,7 +24,9 @@ fn main() {
.expect("Failed to read key");
let mut n = 0;
- for key in tsk.keys_valid().for_signing().secret().map(|ka| ka.key()) {
+ for key in tsk.keys().alive().revoked(false).for_signing().secret()
+ .map(|ka| ka.key())
+ {
keys.push({
let mut key = key.clone();
if key.secret().expect("filtered").is_encrypted() {
diff --git a/openpgp/examples/sign.rs b/openpgp/examples/sign.rs
index 7fae29ef..d8054fac 100644
--- a/openpgp/examples/sign.rs
+++ b/openpgp/examples/sign.rs
@@ -23,7 +23,9 @@ fn main() {
.expect("Failed to read key");
let mut n = 0;
- for key in tsk.keys_valid().for_signing().secret().map(|ka| ka.key()) {
+ for key in tsk.keys().alive().revoked(false).for_signing().secret()
+ .map(|ka| ka.key())
+ {
keys.push({
let mut key = key.clone();
if key.secret().expect("filtered").is_encrypted() {
diff --git a/openpgp/src/cert/bindings.rs b/openpgp/src/cert/bindings.rs
index d06dbfa6..70e80983 100644
--- a/openpgp/src/cert/bindings.rs
+++ b/openpgp/src/cert/bindings.rs
@@ -36,7 +36,9 @@ impl<P: key::KeyParts> Key<P, key::SubordinateRole> {
///
/// // Let's add an encryption subkey.
/// let flags = KeyFlags::default().set_storage_encryption(true);
- /// assert_eq!(cert.keys_valid().key_flags(flags.clone()).count(), 0);
+ /// assert_eq!(cert.keys().alive().revoked(false)
+ /// .key_flags(flags.clone()).count(),
+ /// 0);
///
/// // Generate a subkey and a binding signature.
/// let subkey: Key<_, key::SubordinateRole> =
@@ -51,7 +53,9 @@ impl<P: key::KeyParts> Key<P, key::SubordinateRole> {
/// binding.into()])?;
///
/// // Check that we have an encryption subkey.
- /// assert_eq!(cert.keys_valid().key_flags(flags).count(), 1);
+ /// assert_eq!(cert.keys().alive().revoked(false)
+ /// .key_flags(flags).count(),
+ /// 1);
/// # Ok(()) }
pub fn bind<T>(&self, signer: &mut dyn Signer, cert: &Cert,
signature: signature::Builder,
diff --git a/openpgp/src/cert/builder.rs b/openpgp/src/cert/builder.rs
index 24bc5fe7..511ddd2d 100644
--- a/openpgp/src/cert/builder.rs
+++ b/openpgp/src/cert/builder.rs
@@ -655,7 +655,7 @@ mod tests {
assert!(sig.key_alive(key, now + 590 * s).is_ok());
assert!(! sig.key_alive(key, now + 610 * s).is_ok());
- let (sig, key) = cert.keys_valid().for_signing()
+ let (sig, key) = cert.keys().alive().revoked(false).for_signing()
.nth(0).map(|ka| {
(ka.binding_signature(None).unwrap(), ka.key())
}).unwrap();
@@ -663,7 +663,7 @@ mod tests {
assert!(sig.key_alive(key, now + 290 * s).is_ok());
assert!(! sig.key_alive(key, now + 310 * s).is_ok());
- let (sig, key) = cert.keys_valid().for_authentication()
+ let (sig, key) = cert.keys().alive().revoked(false).for_authentication()
.nth(0).map(|ka| {
(ka.binding_signature(None).unwrap(), ka.key())
}).unwrap();
diff --git