summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJustus Winter <justus@sequoia-pgp.org>2019-12-03 17:38:49 +0100
committerJustus Winter <justus@sequoia-pgp.org>2019-12-04 13:20:26 +0100
commit807eee2432de52715a2e3c7167d5e859ca3315a8 (patch)
treeca712d38feec4caa46c0105f1f0f9d45400c7d55
parentdaee0e230c36cec119d523ca33407789b6fd109f (diff)
openpgp: Rename KeyIter filters.
- See #359.
-rw-r--r--guide/src/chapter_01.md8
-rw-r--r--ipc/examples/gpg-agent-sign.rs2
-rw-r--r--ipc/tests/gpg-agent.rs2
-rw-r--r--openpgp-ffi/include/sequoia/openpgp.h16
-rw-r--r--openpgp-ffi/src/cert.rs24
-rw-r--r--openpgp/examples/generate-sign-verify.rs2
-rw-r--r--openpgp/examples/notarize.rs2
-rw-r--r--openpgp/examples/sign-detached.rs2
-rw-r--r--openpgp/examples/sign.rs2
-rw-r--r--openpgp/src/cert/builder.rs4
-rw-r--r--openpgp/src/cert/keyiter.rs24
-rw-r--r--openpgp/src/packet/signature/mod.rs2
-rw-r--r--openpgp/src/parse/stream.rs2
-rw-r--r--openpgp/src/serialize/stream.rs6
-rw-r--r--sqv/tests/wrong-key-flags.rs2
-rw-r--r--tool/src/commands/mod.rs2
-rw-r--r--tool/tests/sq-sign.rs2
17 files changed, 52 insertions, 52 deletions
diff --git a/guide/src/chapter_01.md b/guide/src/chapter_01.md
index c4f8b7ac..932f2dc8 100644
--- a/guide/src/chapter_01.md
+++ b/guide/src/chapter_01.md
@@ -52,7 +52,7 @@ fn main() {
# -> openpgp::Result<()> {
# // Get the keypair to do the signing from the Cert.
# let key : key::UnspecifiedSecret
-# = tsk.keys_valid().signing_capable().nth(0).unwrap().2.clone().try_into()?;
+# = tsk.keys_valid().for_signing().nth(0).unwrap().2.clone().try_into()?;
# let keypair = key.into_keypair()?;
#
# // Start streaming an OpenPGP message.
@@ -198,7 +198,7 @@ fn generate() -> openpgp::Result<openpgp::Cert> {
# -> openpgp::Result<()> {
# // Get the keypair to do the signing from the Cert.
# let key : key::UnspecifiedSecret
-# = tsk.keys_valid().signing_capable().nth(0).unwrap().2.clone().try_into()?;
+# = tsk.keys_valid().for_signing().nth(0).unwrap().2.clone().try_into()?;
# let keypair = key.into_keypair()?;
#
# // Start streaming an OpenPGP message.
@@ -344,7 +344,7 @@ fn sign(sink: &mut Write, plaintext: &str, tsk: &openpgp::Cert)
-> openpgp::Result<()> {
// Get the keypair to do the signing from the Cert.
let key : key::UnspecifiedSecret
- = tsk.keys_valid().signing_capable().nth(0).unwrap().2.clone().try_into()?;
+ = tsk.keys_valid().for_signing().nth(0).unwrap().2.clone().try_into()?;
let keypair = key.into_keypair()?;
// Start streaming an OpenPGP message.
@@ -501,7 +501,7 @@ Verified data can be read from this using [`io::Read`].
# -> openpgp::Result<()> {
# // Get the keypair to do the signing from the Cert.
# let key : key::UnspecifiedSecret
-# = tsk.keys_valid().signing_capable().nth(0).unwrap().2.clone().try_into()?;
+# = tsk.keys_valid().for_signing().nth(0).unwrap().2.clone().try_into()?;
# let keypair = key.into_keypair()?;
#
# // Start streaming an OpenPGP message.
diff --git a/ipc/examples/gpg-agent-sign.rs b/ipc/examples/gpg-agent-sign.rs
index f6b4d1ff..5e8c28c6 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().signing_capable().filter_map(|(_, _, key)| {
+ cert.keys_valid().for_signing().filter_map(|(_, _, key)| {
KeyPair::new(&ctx, key).ok()
})
}).collect::<Vec<KeyPair<_>>>();
diff --git a/ipc/tests/gpg-agent.rs b/ipc/tests/gpg-agent.rs
index 05aa9ee7..0656bc21 100644
--- a/ipc/tests/gpg-agent.rs
+++ b/ipc/tests/gpg-agent.rs
@@ -95,7 +95,7 @@ fn sign() {
gpg_import(&ctx, &buf);
let keypair = KeyPair::new(
- &ctx, cert.keys_valid().signing_capable().take(1).next().unwrap().2)
+ &ctx, cert.keys_valid().for_signing().take(1).next().unwrap().2)
.unwrap();
let mut message = Vec::new();
diff --git a/openpgp-ffi/include/sequoia/openpgp.h b/openpgp-ffi/include/sequoia/openpgp.h
index b169f78f..00e841f9 100644
--- a/openpgp-ffi/include/sequoia/openpgp.h
+++ b/openpgp-ffi/include/sequoia/openpgp.h
@@ -621,53 +621,53 @@ void pgp_user_id_binding_iter_free (pgp_user_id_binding_iter_t iter);
/// Changes the iterator to only return keys that are certification
/// capable.
///
-/// If you call this function and, e.g., the `signing_capable`
+/// If you call this function and, e.g., the `for_signing`
/// function, the *union* of the values is used. That is, the
/// iterator will return keys that are certification capable *or*
/// signing capable.
///
/// Note: you may not call this function after starting to iterate.
/*/
-void pgp_cert_key_iter_certification_capable (pgp_cert_key_iter_t iter);
+void pgp_cert_key_iter_for_certification (pgp_cert_key_iter_t iter);
/*/
/// Changes the iterator to only return keys that are certification
/// capable.
///
-/// If you call this function and, e.g., the `signing_capable`
+/// If you call this function and, e.g., the `for_signing`
/// function, the *union* of the values is used. That is, the
/// iterator will return keys that are certification capable *or*
/// signing capable.
///
/// Note: you may not call this function after starting to iterate.
/*/
-void pgp_cert_key_iter_signing_capable (pgp_cert_key_iter_t iter);
+void pgp_cert_key_iter_for_signing (pgp_cert_key_iter_t iter);
/*/
/// Changes the iterator to only return keys that are capable of
/// encrypting data at rest.
///
-/// If you call this function and, e.g., the `signing_capable`
+/// If you call this function and, e.g., the `for_signing`
/// function, the *union* of the values is used. That is, the
/// iterator will return keys that are certification capable *or*
/// signing capable.
///
/// Note: you may not call this function after starting to iterate.
/*/
-void pgp_cert_key_iter_encrypting_capable_at_rest (pgp_cert_key_iter_t);
+void pgp_cert_key_iter_for_storage_encryption (pgp_cert_key_iter_t);
/*/
/// Changes the iterator to only return keys that are capable of
/// encrypting data for transport.
///
-/// If you call this function and, e.g., the `signing_capable`
+/// If you call this function and, e.g., the `for_signing`
/// function, the *union* of the values is used. That is, the
/// iterator will return keys that are certification capable *or*
/// signing capable.
///
/// Note: you may not call this function after starting to iterate.
/*/
-void pgp_cert_key_iter_encrypting_capable_for_transport (pgp_cert_key_iter_t);
+void pgp_cert_key_iter_for_transport_encryption (pgp_cert_key_iter_t);
/*/
/// Changes the iterator to only return keys that are alive.
diff --git a/openpgp-ffi/src/cert.rs b/openpgp-ffi/src/cert.rs
index 5385a61d..6b223a3a 100644
--- a/openpgp-ffi/src/cert.rs
+++ b/openpgp-ffi/src/cert.rs
@@ -498,14 +498,14 @@ pub extern "C" fn pgp_cert_key_iter_free(
/// Changes the iterator to only return keys that are certification
/// capable.
///
-/// If you call this function and, e.g., the `signing_capable`
+/// If you call this function and, e.g., the `for_signing`
/// function, the *union* of the values is used. That is, the
/// iterator will return keys that are certification capable *or*
/// signing capable.
///
/// Note: you may not call this function after starting to iterate.
#[::sequoia_ffi_macros::extern_fn] #[no_mangle]
-pub extern "C" fn pgp_cert_key_iter_certification_capable<'a>(
+pub extern "C" fn pgp_cert_key_iter_for_certification<'a>(
iter_wrapper: *mut KeyIterWrapper<'a>)
{
let iter_wrapper = ffi_param_ref_mut!(iter_wrapper);
@@ -515,20 +515,20 @@ pub extern "C" fn pgp_cert_key_iter_certification_capable<'a>(
use std::mem;
let tmp = mem::replace(&mut iter_wrapper.iter, KeyIter::empty());
- iter_wrapper.iter = tmp.certification_capable();
+ iter_wrapper.iter = tmp.for_certification();
}
/// Changes the iterator to only return keys that are certification
/// capable.
///
-/// If you call this function and, e.g., the `signing_capable`
+/// If you call this function and, e.g., the `for_signing`
/// function, the *union* of the values is used. That is, the
/// iterator will return keys that are certification capable *or*
/// signing capable.
///
/// Note: you may not call this function after starting to iterate.
#[::sequoia_ffi_macros::extern_fn] #[no_mangle]
-pub extern "C" fn pgp_cert_key_iter_signing_capable<'a>(
+pub extern "C" fn pgp_cert_key_iter_for_signing<'a>(
iter_wrapper: *mut KeyIterWrapper<'a>)
{
let iter_wrapper = ffi_param_ref_mut!(iter_wrapper);
@@ -538,20 +538,20 @@ pub extern "C" fn pgp_cert_key_iter_signing_capable<'a>(
use std::mem;
let tmp = mem::replace(&mut iter_wrapper.iter, KeyIter::empty());
- iter_wrapper.iter = tmp.signing_capable();
+ iter_wrapper.iter = tmp.for_signing();
}
/// Changes the iterator to only return keys that are capable of
/// encrypting data at rest.
///
-/// If you call this function and, e.g., the `signing_capable`
+/// If you call this function and, e.g., the `for_signing`
/// function, the *union* of the values is used. That is, the
/// iterator will return keys that are certification capable *or*
/// signing capable.
///
/// Note: you may not call this function after starting to iterate.
#[::sequoia_ffi_macros::extern_fn] #[no_mangle]
-pub extern "C" fn pgp_cert_key_iter_encrypting_capable_at_rest<'a>(
+pub extern "C" fn pgp_cert_key_iter_for_storage_encryption<'a>(
iter_wrapper: *mut KeyIterWrapper<'a>)
{
let iter_wrapper = ffi_param_ref_mut!(iter_wrapper);
@@ -560,20 +560,20 @@ pub extern "C" fn pgp_cert_key_iter_encrypting_capable_at_rest<'a>(
}
let tmp = std::mem::replace(&mut iter_wrapper.iter, KeyIter::empty());
- iter_wrapper.iter = tmp.encrypting_capable_at_rest();
+ iter_wrapper.iter = tmp.for_storage_encryption();
}
/// Changes the iterator to only return keys that are capable of
/// encrypting data for transport.
///
-/// If you call this function and, e.g., the `signing_capable`
+/// If you call this function and, e.g., the `for_signing`
/// function, the *union* of the values is used. That is, the
/// iterator will return keys that are certification capable *or*
/// signing capable.
///
/// Note: you may not call this function after starting to iterate.
#[::sequoia_ffi_macros::extern_fn] #[no_mangle]
-pub extern "C" fn pgp_cert_key_iter_encrypting_capable_for_transport<'a>(
+pub extern "C" fn pgp_cert_key_iter_for_transport_encryption<'a>(
iter_wrapper: *mut KeyIterWrapper<'a>)
{
let iter_wrapper = ffi_param_ref_mut!(iter_wrapper);
@@ -582,7 +582,7 @@ pub extern "C" fn pgp_cert_key_iter_encrypting_capable_for_transport<'a>(
}
let tmp = std::mem::replace(&mut iter_wrapper.iter, KeyIter::empty());
- iter_wrapper.iter = tmp.encrypting_capable_for_transport();
+ iter_wrapper.iter = tmp.for_transport_encryption();
}
/// Changes the iterator to only return keys that are alive.
diff --git a/openpgp/examples/generate-sign-verify.rs b/openpgp/examples/generate-sign-verify.rs
index a712e693..6e3d8084 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().signing_capable().nth(0).unwrap().2
+ let keypair = tsk.keys_valid().for_signing().nth(0).unwrap().2
.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 c4694520..ce007968 100644
--- a/openpgp/examples/notarize.rs
+++ b/openpgp/examples/notarize.rs
@@ -28,7 +28,7 @@ fn main() {
.expect("Failed to read key");
let mut n = 0;
- for (_, _, key) in tsk.keys_valid().signing_capable().secret() {
+ for (_, _, key) in tsk.keys_valid().for_signing().secret() {
keys.push({
let mut key = key.clone();
if key.secret().expect("filtered").is_encrypted() {
diff --git a/openpgp/examples/sign-detached.rs b/openpgp/examples/sign-detached.rs
index 9990f770..0fee0e36 100644
--- a/openpgp/examples/sign-detached.rs
+++ b/openpgp/examples/sign-detached.rs
@@ -24,7 +24,7 @@ fn main() {
.expect("Failed to read key");
let mut n = 0;
- for (_, _, key) in tsk.keys_valid().signing_capable().secret() {
+ for (_, _, key) in tsk.keys_valid().for_signing().secret() {
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 296f6950..195ac508 100644
--- a/openpgp/examples/sign.rs
+++ b/openpgp/examples/sign.rs
@@ -23,7 +23,7 @@ fn main() {
.expect("Failed to read key");
let mut n = 0;
- for (_, _, key) in tsk.keys_valid().signing_capable().secret() {
+ for (_, _, key) in tsk.keys_valid().for_signing().secret() {
keys.push({
let mut key = key.clone();
if key.secret().expect("filtered").is_encrypted() {
diff --git a/openpgp/src/cert/builder.rs b/openpgp/src/cert/builder.rs
index dcaf4c22..d9f266ad 100644
--- a/openpgp/src/cert/builder.rs
+++ b/openpgp/src/cert/builder.rs
@@ -649,13 +649,13 @@ mod tests {
assert!(sig.key_alive(key, now + 599 * s));
assert!(! sig.key_alive(key, now + 601 * s));
- let (sig, key) = cert.keys_valid().signing_capable()
+ let (sig, key) = cert.keys_valid().for_signing()
.nth(0).map(|(s, _, k)| (s.unwrap(), k)).unwrap();
assert!(sig.key_alive(key, now));
assert!(sig.key_alive(key, now + 299 * s));
assert!(! sig.key_alive(key, now + 301 * s));
- let (sig, key) = cert.keys_valid().authentication_capable()
+ let (sig, key) = cert.keys_valid().for_authentication()
.nth(0).map(|(s, _, k)| (s.unwrap(), k)).unwrap();
assert!(sig.key_alive(key, now));
assert!(sig.key_alive(key, now + 599 * s));
diff --git a/openpgp/src/cert/keyiter.rs b/openpgp/src/cert/keyiter.rs
index 170a6d6c..13813388 100644
--- a/openpgp/src/cert/keyiter.rs
+++ b/openpgp/src/cert/keyiter.rs
@@ -275,10 +275,10 @@ impl<'a, P: 'a + key::KeyParts, R: 'a + key::KeyRole> KeyIter<'a, P, R>
/// Returns keys that have the at least one of the flags specified
/// in `flags`.
///
- /// If you call this function (or one of `certification_capable`
- /// or `signing_capable` functions) multiple times, the *union* of
+ /// If you call this function (or one of `for_certification`
+ /// or `for_signing` functions) multiple times, the *union* of
/// the values is used. Thus,
- /// `cert.flags().certification_capable().signing_capable()` will
+ /// `cert.flags().for_certification().for_signing()` will
/// return keys that are certification capable or signing capable.
///
/// If you need more complex filtering, e.g., you want a key that
@@ -298,35 +298,35 @@ impl<'a, P: 'a + key::KeyParts, R: 'a + key::KeyRole> KeyIter<'a, P, R>
/// Returns keys that are certification capable.
///
/// See `key_flags` for caveats.
- pub fn certification_capable(self) -> Self {
+ pub fn for_certification(self) -> Self {
self.key_flags(KeyFlags::default().set_certify(true))
}
/// Returns keys that are signing capable.
///
/// See `key_flags` for caveats.
- pub fn signing_capable(self) -> Self {
+ pub fn for_signing(self) -> Self {
self.key_flags(KeyFlags::default().set_sign(true))
}
/// Returns keys that are authentication capable.
///
/// See `key_flags` for caveats.
- pub fn authentication_capable(self) -> Self {
+ pub fn for_authentication(self) -> Self {
self.key_flags(KeyFlags::default().set_authenticate(true))
}
/// Returns keys that are capable of encrypting data at rest.
///
/// See `key_flags` for caveats.
- pub fn encrypting_capable_at_rest(self) -> Self {
+ pub fn for_storage_encryption(self) -> Self {
self.key_flags(KeyFlags::default().set_encrypt_at_rest(true))
}
/// Returns keys that are capable of encrypting data for transport.
///
/// See `key_flags` for caveats.
- pub fn encrypting_capable_for_transport(self) -> Self {
+ pub fn for_transport_encryption(self) -> Self {
self.key_flags(KeyFlags::default().set_encrypt_for_transport(true))
}
@@ -489,11 +489,11 @@ mod test {
.add_encryption_subkey()
.add_authentication_subkey()
.generate().unwrap();
- assert_eq!(cert.keys_valid().certification_capable().count(), 2);
- assert_eq!(cert.keys_valid().encrypting_capable_for_transport().count(),
+ assert_eq!(cert.keys_valid().for_certification().count(), 2);
+ assert_eq!(cert.keys_valid().for_transport_encryption().count(),
1);
- assert_eq!(cert.keys_valid().encrypting_capable_at_rest().count(), 1);
- assert_eq!(cert.keys_valid().signing_capable().count(), 1);
+ assert_eq!(cert.keys_valid().for_storage_encryption().count(), 1);
+ assert_eq!(cert.keys_valid().for_signing().count(), 1);
assert_eq!(cert.keys_valid().key_flags(
KeyFlags::default().set_authenticate(true)).count(), 1);
}
diff --git a/openpgp/src/packet/signature/mod.rs b/openpgp/src/packet/signature/mod.rs
index b05ffe4d..1083d423 100644
--- a/openpgp/src/packet/signature/mod.rs
+++ b/openpgp/src/packet/signature/mod.rs
@@ -1398,7 +1398,7 @@ mod test {
let test1 = Cert::from_bytes(
crate::tests::key("test1-certification-key.pgp")).unwrap();
let cert_key1 = test1.keys_all()
- .certification_capable()
+ .for_certification()
.nth(0)
.map(|x| x.2)
.unwrap();
diff --git a/openpgp/src/parse/stream.rs b/openpgp/src/parse/stream.rs
index 9b202a5f..4b632601 100644
--- a/openpgp/src/parse/stream.rs
+++ b/openpgp/src/parse/stream.rs
@@ -2052,7 +2052,7 @@ mod test {
// sign 30MiB message
let mut buf = vec![];
{
- let key = cert.keys_all().signing_capable().nth(0).unwrap().2;
+ let key = cert.keys_all().for_signing().nth(0).unwrap().2;
let keypair =
key.clone().mark_parts_secret().unwrap()
.into_keypair().unwrap();
diff --git a/openpgp/src/serialize/stream.rs b/openpgp/src/serialize/stream.rs
index 3e7e6532..1afdb547 100644
--- a/openpgp/src/serialize/stream.rs
+++ b/openpgp/src/serialize/stream.rs
@@ -228,7 +228,7 @@ impl<'a> Signer<'a> {
/// # let tsk = Cert::from_bytes(&include_bytes!(
/// # "../../tests/data/keys/testy-new-private.pgp")[..])
/// # .unwrap();
- /// # let keypair = tsk.keys_valid().signing_capable().nth(0).unwrap().2
+ /// # let keypair = tsk.keys_valid().for_signing().nth(0).unwrap().2
/// # .clone().mark_parts_secret().unwrap().into_keypair().unwrap();
/// # f(tsk, keypair).unwrap();
/// # fn f(cert: Cert, mut signing_keypair: KeyPair<key::UnspecifiedRole>)
@@ -331,7 +331,7 @@ impl<'a> Signer<'a> {
/// # let tsk = Cert::from_bytes(&include_bytes!(
/// # "../../tests/data/keys/testy-new-private.pgp")[..])
/// # .unwrap();
- /// # let keypair = tsk.keys_valid().signing_capable().nth(0).unwrap().2
+ /// # let keypair = tsk.keys_valid().for_signing().nth(0).unwrap().2
/// # .clone().mark_parts_secret().unwrap().into_keypair().unwrap();
/// # f(tsk, keypair).unwrap();
/// # fn f(cert: Cert, mut signing_keypair: KeyPair<key::UnspecifiedRole>)
@@ -1468,7 +1468,7 @@ mod test {
Cert::from_bytes(crate::tests::key("testy-private.pgp")).unwrap(),
Cert::from_bytes(crate::tests::key("testy-new-private.pgp")).unwrap(),
] {
- for key in tsk.keys_all().signing_capable().map(|x| x.2)
+ for key in tsk.keys_all().for_signing().map(|x| x.2)
{
keys.insert(key.fingerprint(), key.clone());
}
diff --git a/sqv/tests/wrong-key-flags.rs b/sqv/tests/wrong-key-flags.rs
index 4fb1e1e8..c1f8ab7f 100644
--- a/sqv/tests/wrong-key-flags.rs
+++ b/sqv/tests/wrong-key-flags.rs
@@ -6,7 +6,7 @@ mod integration {
use std::path;
#[test]
- fn not_signing_capable_subkey() {
+ fn not_for_signing_subkey() {
Assert::cargo_binary("sqv")
.current_dir(path::Path::new("tests").join("data"))
.with_args(
diff --git a/tool/src/commands/mod.rs b/tool/src/commands/mod.rs
index ce228b2d..b4350dfb 100644
--- a/tool/src/commands/mod.rs
+++ b/tool/src/commands/mod.rs
@@ -50,7 +50,7 @@ fn get_signing_keys(certs: &[openpgp::Cert])
let mut keys = Vec::new();
'next_cert: for tsk in certs {
for key in tsk.keys_valid()
- .signing_capable()
+ .for_signing()
.map(|k| k.2)
{
if let Some(secret) = key.secret() {
diff --git a/tool/tests/sq-sign.rs b/tool/tests/sq-sign.rs
index 507f778d..adab186a 100644
--- a/tool/tests/sq-sign.rs
+++ b/tool/tests/sq-sign.rs
@@ -208,7 +208,7 @@ fn sq_sign_append_on_compress_then_sign() {
// message by foot.
let tsk = Cert::from_file(&p("keys/dennis-simon-anton-private.pgp"))
.unwrap();
- let key = tsk.keys_all().signing_capable().nth(0).unwrap().2;
+ let key = tsk.keys_all().for_signing().nth(0).unwrap().2;
let sec = match key.secret() {
Some(SecretKeyMaterial::Unencrypted(ref u)) => u.clone(),
_ => unreachable!(),