From d6ed2a3cbb18c50c2da73d5efbdade343e3bad12 Mon Sep 17 00:00:00 2001 From: Justus Winter Date: Thu, 6 Feb 2020 14:49:01 +0100 Subject: openpgp: Rename methods 'set_policy' to 'with_policy'. - Fixes #427. --- openpgp/examples/decrypt-with.rs | 2 +- openpgp/examples/encrypt-for.rs | 2 +- openpgp/examples/generate-encrypt-decrypt.rs | 4 +- openpgp/examples/generate-sign-verify.rs | 2 +- openpgp/examples/notarize.rs | 2 +- openpgp/examples/pad.rs | 2 +- openpgp/examples/sign-detached.rs | 2 +- openpgp/examples/sign.rs | 2 +- openpgp/src/autocrypt.rs | 2 +- openpgp/src/cert/amalgamation.rs | 12 ++--- openpgp/src/cert/bindings.rs | 4 +- openpgp/src/cert/builder.rs | 28 ++++++------ openpgp/src/cert/component_iter.rs | 6 +-- openpgp/src/cert/key_amalgamation.rs | 16 +++---- openpgp/src/cert/keyiter.rs | 38 ++++++++-------- openpgp/src/cert/mod.rs | 66 ++++++++++++++-------------- openpgp/src/cert/revoke.rs | 4 +- openpgp/src/packet/signature/mod.rs | 4 +- openpgp/src/parse/stream.rs | 6 +-- openpgp/src/policy.rs | 22 +++++----- openpgp/src/serialize/cert.rs | 12 ++--- openpgp/src/serialize/stream.rs | 14 +++--- openpgp/src/types/timestamp.rs | 4 +- 23 files changed, 128 insertions(+), 128 deletions(-) (limited to 'openpgp') diff --git a/openpgp/examples/decrypt-with.rs b/openpgp/examples/decrypt-with.rs index b52c143c..fdcb3f7e 100644 --- a/openpgp/examples/decrypt-with.rs +++ b/openpgp/examples/decrypt-with.rs @@ -62,7 +62,7 @@ impl Helper { // Map (sub)KeyIDs to secrets. let mut keys = HashMap::new(); for cert in certs { - for ka in cert.keys().set_policy(p, None) + for ka in cert.keys().with_policy(p, None) .for_storage_encryption().for_transport_encryption() { // This only works for unencrypted secret keys. diff --git a/openpgp/examples/encrypt-for.rs b/openpgp/examples/encrypt-for.rs index b64165b7..557e648f 100644 --- a/openpgp/examples/encrypt-for.rs +++ b/openpgp/examples/encrypt-for.rs @@ -42,7 +42,7 @@ fn main() { certs.iter() .flat_map(|cert| { cert.keys() - .set_policy(p, None).alive().revoked(false).key_flags(&mode) + .with_policy(p, None).alive().revoked(false).key_flags(&mode) }) .map(|ka| ka.key().into()) .collect::>(); diff --git a/openpgp/examples/generate-encrypt-decrypt.rs b/openpgp/examples/generate-encrypt-decrypt.rs index 089ed8e7..9f3b8d6a 100644 --- a/openpgp/examples/generate-encrypt-decrypt.rs +++ b/openpgp/examples/generate-encrypt-decrypt.rs @@ -48,7 +48,7 @@ fn encrypt(p: &dyn Policy, sink: &mut dyn Write, plaintext: &str, { // Build a vector of recipients to hand to Encryptor. let mut recipients = - recipient.keys().set_policy(p, None).alive().revoked(false) + recipient.keys().with_policy(p, None).alive().revoked(false) .for_transport_encryption() .map(|ka| ka.key().into()) .collect::>(); @@ -124,7 +124,7 @@ impl<'a> DecryptionHelper for Helper<'a> { -> openpgp::Result> where D: FnMut(SymmetricAlgorithm, &SessionKey) -> openpgp::Result<()> { - let key = self.secret.keys().set_policy(self.policy, None) + let key = self.secret.keys().with_policy(self.policy, None) .for_transport_encryption().nth(0).unwrap().key().clone(); // The secret key is not encrypted. diff --git a/openpgp/examples/generate-sign-verify.rs b/openpgp/examples/generate-sign-verify.rs index e3142667..12709609 100644 --- a/openpgp/examples/generate-sign-verify.rs +++ b/openpgp/examples/generate-sign-verify.rs @@ -45,7 +45,7 @@ fn sign(p: &dyn Policy, sink: &mut dyn Write, plaintext: &str, tsk: &openpgp::Ce -> openpgp::Result<()> { // Get the keypair to do the signing from the Cert. let keypair = tsk - .keys().set_policy(p, None).alive().revoked(false).for_signing() + .keys().with_policy(p, None).alive().revoked(false).for_signing() .nth(0).unwrap() .key().clone().mark_parts_secret().unwrap().into_keypair()?; diff --git a/openpgp/examples/notarize.rs b/openpgp/examples/notarize.rs index 62042e60..83e34cee 100644 --- a/openpgp/examples/notarize.rs +++ b/openpgp/examples/notarize.rs @@ -31,7 +31,7 @@ fn main() { let mut n = 0; for key in tsk.keys() - .set_policy(p, None).alive().revoked(false).for_signing().secret() + .with_policy(p, None).alive().revoked(false).for_signing().secret() .map(|ka| ka.key()) { keys.push({ diff --git a/openpgp/examples/pad.rs b/openpgp/examples/pad.rs index 68efa655..c1c341c8 100644 --- a/openpgp/examples/pad.rs +++ b/openpgp/examples/pad.rs @@ -43,7 +43,7 @@ fn main() { .iter() .flat_map(|cert| { cert.keys() - .set_policy(p, None).alive().revoked(false).key_flags(&mode) + .with_policy(p, None).alive().revoked(false).key_flags(&mode) }) .map(|ka| Recipient::new(KeyID::wildcard(), ka.key())) .collect::>(); diff --git a/openpgp/examples/sign-detached.rs b/openpgp/examples/sign-detached.rs index e93cd0e2..da5cd776 100644 --- a/openpgp/examples/sign-detached.rs +++ b/openpgp/examples/sign-detached.rs @@ -27,7 +27,7 @@ fn main() { let mut n = 0; for key in tsk - .keys().set_policy(p, None).alive().revoked(false).for_signing().secret() + .keys().with_policy(p, None).alive().revoked(false).for_signing().secret() .map(|ka| ka.key()) { keys.push({ diff --git a/openpgp/examples/sign.rs b/openpgp/examples/sign.rs index 85565b2e..95afee20 100644 --- a/openpgp/examples/sign.rs +++ b/openpgp/examples/sign.rs @@ -26,7 +26,7 @@ fn main() { let mut n = 0; for key in tsk.keys() - .set_policy(p, None).alive().revoked(false).for_signing().secret() + .with_policy(p, None).alive().revoked(false).for_signing().secret() .map(|ka| ka.key()) { keys.push({ diff --git a/openpgp/src/autocrypt.rs b/openpgp/src/autocrypt.rs index 22dfa40d..6d02c5ce 100644 --- a/openpgp/src/autocrypt.rs +++ b/openpgp/src/autocrypt.rs @@ -130,7 +130,7 @@ impl AutocryptHeader { } // The UserIDs matching ADDR. - for uidb in cert.userids().set_policy(policy, None) { + for uidb in cert.userids().with_policy(policy, None) { // XXX: Fix match once we have the rfc2822-name-addr. if let Ok(Some(a)) = uidb.userid().email() { if &a == addr { diff --git a/openpgp/src/cert/amalgamation.rs b/openpgp/src/cert/amalgamation.rs index 10ee8d5b..3ea1b25c 100644 --- a/openpgp/src/cert/amalgamation.rs +++ b/openpgp/src/cert/amalgamation.rs @@ -50,7 +50,7 @@ impl<'a, C> ComponentAmalgamation<'a, C> { /// time, if any. /// /// Note: this function is not exported. Users of this interface - /// should do: ca.set_policy(policy, time)?.binding_signature(). + /// should do: ca.with_policy(policy, time)?.binding_signature(). fn binding_signature(&self, policy: &dyn Policy, time: T) -> Option<&'a Signature> where T: Into> @@ -65,7 +65,7 @@ impl<'a, C> ComponentAmalgamation<'a, C> { /// /// This transforms the `ComponentAmalgamation` into a /// `ValidComponentAmalgamation`. - pub fn set_policy(self, policy: &'a dyn Policy, time: T) + pub fn with_policy(self, policy: &'a dyn Policy, time: T) -> Result> where T: Into> { @@ -189,7 +189,7 @@ impl<'a, C> ValidComponentAmalgamation<'a, C> } }) .and_then(|c| ComponentAmalgamation::new(cert, (c.0).0) - .set_policy(policy, t).ok()) + .with_policy(policy, t).ok()) } } @@ -213,7 +213,7 @@ pub trait Amalgamation<'a> { /// Changes the amalgamation's policy. /// /// If `time` is `None`, the current time is used. - fn set_policy(self, policy: &'a dyn Policy, time: T) -> Result + fn with_policy(self, policy: &'a dyn Policy, time: T) -> Result where Self: Sized, T: Into>; /// Returns the component's binding signature as of the reference time. @@ -272,11 +272,11 @@ impl<'a, C> Amalgamation<'a> for ValidComponentAmalgamation<'a, C> { /// Changes the amalgamation's policy. /// /// If `time` is `None`, the current time is used. - fn set_policy(self, policy: &'a dyn Policy, time: T) -> Result + fn with_policy(self, policy: &'a dyn Policy, time: T) -> Result where T: Into> { let time = time.into().unwrap_or_else(SystemTime::now); - self.a.set_policy(policy, time) + self.a.with_policy(policy, time) } /// Returns the component's binding signature as of the reference time. diff --git a/openpgp/src/cert/bindings.rs b/openpgp/src/cert/bindings.rs index 40a326d8..582ff705 100644 --- a/openpgp/src/cert/bindings.rs +++ b/openpgp/src/cert/bindings.rs @@ -39,7 +39,7 @@ impl Key { /// /// // Let's add an encryption subkey. /// let flags = KeyFlags::default().set_storage_encryption(true); - /// assert_eq!(cert.keys().set_policy(p, None).alive().revoked(false) + /// assert_eq!(cert.keys().with_policy(p, None).alive().revoked(false) /// .key_flags(&flags).count(), /// 0); /// @@ -56,7 +56,7 @@ impl Key { /// binding.into()])?; /// /// // Check that we have an encryption subkey. - /// assert_eq!(cert.keys().set_policy(p, None).alive().revoked(false) + /// assert_eq!(cert.keys().with_policy(p, None).alive().revoked(false) /// .key_flags(flags).count(), /// 1); /// # Ok(()) } diff --git a/openpgp/src/cert/builder.rs b/openpgp/src/cert/builder.rs index c09d90ae..171627f2 100644 --- a/openpgp/src/cert/builder.rs +++ b/openpgp/src/cert/builder.rs @@ -481,7 +481,7 @@ mod tests { .add_certification_subkey() .generate().unwrap(); - let mut userids = cert.userids().set_policy(p, None) + let mut userids = cert.userids().with_policy(p, None) .map(|u| String::from_utf8_lossy(u.userid().value()).into_owned()) .collect::>(); userids.sort(); @@ -507,7 +507,7 @@ mod tests { assert_eq!(cert.userids().count(), 0); assert_eq!(cert.subkeys().count(), 3); let sig = - cert.primary_key().set_policy(p, None).unwrap().binding_signature(); + cert.primary_key().with_policy(p, None).unwrap().binding_signature(); assert_eq!(sig.typ(), crate::types::SignatureType::DirectKey); assert!(sig.features().unwrap().supports_mdc()); } @@ -581,7 +581,7 @@ mod tests { .primary_key_flags(KeyFlags::default()) .add_transport_encryption_subkey() .generate().unwrap(); - assert!(cert1.primary_key().set_policy(p, None).unwrap().for_certification()); + assert!(cert1.primary_key().with_policy(p, None).unwrap().for_certification()); assert_eq!(cert1.keys().subkeys().count(), 1); } @@ -673,19 +673,19 @@ mod tests { assert!(sig.key_alive(key, now + 590 * s).is_ok()); assert!(! sig.key_alive(key, now + 610 * s).is_ok()); - let ka = cert.keys().set_policy(p, now).alive().revoked(false) + let ka = cert.keys().with_policy(p, now).alive().revoked(false) .for_signing() .nth(0).unwrap(); assert!(ka.alive().is_ok()); - assert!(ka.clone().set_policy(p, now + 290 * s).unwrap().alive().is_ok()); - assert!(! ka.clone().set_policy(p, now + 310 * s).unwrap().alive().is_ok()); + assert!(ka.clone().with_policy(p, now + 290 * s).unwrap().alive().is_ok()); + assert!(! ka.clone().with_policy(p, now + 310 * s).unwrap().alive().is_ok()); - let ka = cert.keys().set_policy(p, now).alive().revoked(false) + let ka = cert.keys().with_policy(p, now).alive().revoked(false) .for_authentication() .nth(0).unwrap(); assert!(ka.alive().is_ok()); - assert!(ka.clone().set_policy(p, now + 590 * s).unwrap().alive().is_ok()); - assert!(! ka.clone().set_policy(p, now + 610 * s).unwrap().alive().is_ok()); + assert!(ka.clone().with_policy(p, now + 590 * s).unwrap().alive().is_ok()); + assert!(! ka.clone().with_policy(p, now + 610 * s).unwrap().alive().is_ok()); } #[test] @@ -701,17 +701,17 @@ mod tests { .generate().unwrap(); assert_eq!(cert.primary_key().creation_time(), UNIX_EPOCH); - assert_eq!(cert.primary_key().set_policy(p, None).unwrap() + assert_eq!(cert.primary_key().with_policy(p, None).unwrap() .binding_signature() .signature_creation_time().unwrap(), UNIX_EPOCH); - assert_eq!(cert.primary_key().set_policy(p, None).unwrap() + assert_eq!(cert.primary_key().with_policy(p, None).unwrap() .direct_key_signature().unwrap() .signature_creation_time().unwrap(), UNIX_EPOCH); assert_eq!(rev.signature_creation_time().unwrap(), UNIX_EPOCH); // (Sub)Keys. - assert_eq!(cert.keys().set_policy(p, None).count(), 2); - for ka in cert.keys().set_policy(p, None) { + assert_eq!(cert.keys().with_policy(p, None).count(), 2); + for ka in cert.keys().with_policy(p, None) { assert_eq!(ka.key().creation_time(), UNIX_EPOCH); assert_eq!(ka.binding_signature() .signature_creation_time().unwrap(), UNIX_EPOCH); @@ -719,7 +719,7 @@ mod tests { // UserIDs. assert_eq!(cert.userids().count(), 1); - for ui in cert.userids().set_policy(p, None) { + for ui in cert.userids().with_policy(p, None) { assert_eq!(ui.binding_signature() .signature_creation_time().unwrap(), UNIX_EPOCH); } diff --git a/openpgp/src/cert/component_iter.rs b/openpgp/src/cert/component_iter.rs index 879c673c..1d7f0cc9 100644 --- a/openpgp/src/cert/component_iter.rs +++ b/openpgp/src/cert/component_iter.rs @@ -60,7 +60,7 @@ impl<'a, C> ComponentIter<'a, C> { /// If `time` is None, then the current time is used. /// /// See `ValidComponentIter` for the definition of a valid component. - pub fn set_policy(self, policy: &'a dyn Policy, time: T) + pub fn with_policy(self, policy: &'a dyn Policy, time: T) -> ValidComponentIter<'a, C> where T: Into> { @@ -128,7 +128,7 @@ impl<'a, C> Iterator for ValidComponentIter<'a, C> t!("Considering component: {:?}", ca.bundle()); let vca - = if let Ok(vca) = ca.set_policy(self.policy, self.time) { + = if let Ok(vca) = ca.with_policy(self.policy, self.time) { vca } else { t!("No self-signature at time {:?}", self.time); @@ -195,7 +195,7 @@ impl<'a, C> ValidComponentIter<'a, C> { /// # let timestamp = None; /// let non_revoked_uas = cert /// .user_attributes() - /// .set_policy(p, timestamp) + /// .with_policy(p, timestamp) /// .filter(|ca| { /// match ca.revoked() { /// RevocationStatus::Revoked(_) => diff --git a/openpgp/src/cert/key_amalgamation.rs b/openpgp/src/cert/key_amalgamation.rs index 1d736c1e..08a13139 100644 --- a/openpgp/src/cert/key_amalgamation.rs +++ b/openpgp/src/cert/key_amalgamation.rs @@ -219,7 +219,7 @@ impl<'a, P: 'a + key::KeyParts> KeyAmalgamation<'a, P> { /// if any. /// /// Note: this function is not exported. Users of this interface - /// should do: ka.set_policy(time)?.binding_signature(). + /// should do: ka.with_policy(time)?.binding_signature(). fn binding_signature(&self, policy: &'a dyn Policy, time: T) -> Option<&'a Signature> where T: Into> @@ -249,7 +249,7 @@ impl<'a, P: 'a + key::KeyParts> KeyAmalgamation<'a, P> { /// /// This transforms the `KeyAmalgamation` into a /// `ValidKeyAmalgamation`. - pub fn set_policy(self, policy: &'a dyn Policy, time: T) + pub fn with_policy(self, policy: &'a dyn Policy, time: T) -> Result> where T: Into> { @@ -330,11 +330,11 @@ impl<'a, P: key::KeyParts> PrimaryKeyAmalgamation<'a, P> { /// /// This transforms the `KeyAmalgamation` into a /// `ValidKeyAmalgamation`. - pub fn set_policy(self, policy: &'a dyn Policy, time: T) + pub fn with_policy(self, policy: &'a dyn Policy, time: T) -> Result> where T: Into> { - Ok(ValidPrimaryKeyAmalgamation::new(self.a.set_policy(policy, time)?)) + Ok(ValidPrimaryKeyAmalgamation::new(self.a.with_policy(policy, time)?)) } } @@ -443,11 +443,11 @@ impl<'a, P: 'a + key::KeyParts> Amalgamation<'a> for ValidKeyAmalgamation<'a, P> /// Changes the amalgamation's policy. /// /// If `time` is `None`, the current time is used. - fn set_policy(self, policy: &'a dyn Policy, time: T) -> Result + fn with_policy(self, policy: &'a dyn Policy, time: T) -> Result where T: Into> { let time = time.into().unwrap_or_else(SystemTime::now); - self.a.set_policy(policy, time) + self.a.with_policy(policy, time) } /// Returns the key's binding signature as of the reference time, @@ -712,9 +712,9 @@ impl<'a, P: key::KeyParts> ValidPrimaryKeyAmalgamation<'a, P> { /// Changes the amalgamation's policy. /// /// If `time` is `None`, the current time is used. - pub fn set_policy(self, policy: &'a dyn Policy, time: T) -> Result + pub fn with_policy(self, policy: &'a dyn Policy, time: T) -> Result where T: Into> { - Ok(Self::new(self.a.set_policy(policy, time)?)) + Ok(Self::new(self.a.with_policy(policy, time)?)) } } diff --git a/openpgp/src/cert/keyiter.rs b/openpgp/src/cert/keyiter.rs index e1bd03c6..6aa3ea3b 100644 --- a/openpgp/src/cert/keyiter.rs +++ b/openpgp/src/cert/keyiter.rs @@ -287,7 +287,7 @@ impl<'a, P: 'a + key::KeyParts> KeyIter<'a, P> /// } else if let Err(_) = cert.alive(p, None) { /// // The certificate is not alive, don't use any keys from it. /// } else { - /// for key in cert.keys().set_policy(p, None).alive().revoked(false).for_signing() { + /// for key in cert.keys().with_policy(p, None).alive().revoked(false).for_signing() { /// // We can sign the message with this key. /// } /// } @@ -326,7 +326,7 @@ impl<'a, P: 'a + key::KeyParts> KeyIter<'a, P> /// } else if let Err(_) = cert.alive(p, None) { /// // The certificate is not alive, don't use any keys from it. /// } else { - /// for key in cert.keys().set_policy(p, timestamp).alive().revoked(false).for_signing() { + /// for key in cert.keys().with_policy(p, timestamp).alive().revoked(false).for_signing() { /// // Verify the message with this keys. /// } /// } @@ -372,7 +372,7 @@ impl<'a, P: 'a + key::KeyParts> KeyIter<'a, P> /// # let (cert, _) = /// # CertBuilder::general_purpose(None, Some("alice@example.org")) /// # .generate()?; - /// let decryption_keys = cert.keys().set_policy(p, None) + /// let decryption_keys = cert.keys().with_policy(p, None) /// .for_storage_encryption().for_transport_encryption() /// .collect::>(); /// # Ok(()) @@ -381,7 +381,7 @@ impl<'a, P: 'a + key::KeyParts> KeyIter<'a, P> /// /// [signature expirations]: https://tools.ietf.org/html/rfc4880#section-5.2.3.10 /// [this discussion]: https://crypto.stackexchange.com/a/12138 . - pub fn set_policy(self, policy: &'a dyn Policy, time: T) + pub fn with_policy(self, policy: &'a dyn Policy, time: T) -> ValidKeyIter<'a, P> where T: Into> { @@ -569,7 +569,7 @@ impl<'a, P: 'a + key::KeyParts> ValidKeyIter<'a, P> { = if ! self.primary { self.primary = true; let ka = KeyAmalgamation::new_primary(cert); - match ka.set_policy(self.policy, self.time) { + match ka.with_policy(self.policy, self.time) { Ok(ka) => ka, Err(err) => { // The primary key is bad. Abort. @@ -580,7 +580,7 @@ impl<'a, P: 'a + key::KeyParts> ValidKeyIter<'a, P> { } else { let ka = KeyAmalgamation::new_subordinate( cert.into(), self.subkey_iter.next()?); - match ka.set_policy(self.policy, self.time) { + match ka.with_policy(self.policy, self.time) { Ok(ka) => ka, Err(err) => { // The subkey is bad, abort. @@ -780,7 +780,7 @@ impl<'a, P: 'a + key::KeyParts> ValidKeyIter<'a, P> /// # let timestamp = None; /// let non_revoked_keys = cert /// .keys() - /// .set_policy(p, timestamp) + /// .with_policy(p, timestamp) /// .filter(|ka| { /// match ka.revoked() { /// RevocationStatus::Revoked(_) => @@ -1054,7 +1054,7 @@ mod test { .generate().unwrap(); let flags = KeyFlags::default().set_transport_encryption(true); - assert_eq!(cert.keys().set_policy(p, None).key_flags(flags).count(), 0); + assert_eq!(cert.keys().with_policy(p, None).key_flags(flags).count(), 0); } #[test] @@ -1065,7 +1065,7 @@ mod test { .generate().unwrap(); let flags = KeyFlags::default().set_transport_encryption(true); - assert_eq!(cert.keys().set_policy(p, None).key_flags(flags).count(), 1); + assert_eq!(cert.keys().with_policy(p, None).key_flags(flags).count(), 1); } #[test] @@ -1077,7 +1077,7 @@ mod test { .generate().unwrap(); let flags = KeyFlags::default().set_transport_encryption(true); - assert_eq!(cert.keys().set_policy(p, None).key_flags(flags).count(), 1); + assert_eq!(cert.keys().with_policy(p, None).key_flags(flags).count(), 1); } #[test] @@ -1090,7 +1090,7 @@ mod test { let now = SystemTime::now() - std::time::Duration::new(52 * 7 * 24 * 60 * 60, 0); - assert_eq!(cert.keys().set_policy(p, now).key_flags(flags).alive().count(), + assert_eq!(cert.keys().with_policy(p, now).key_flags(flags).alive().count(), 0); } @@ -1102,7 +1102,7 @@ mod test { .generate().unwrap(); let flags = KeyFlags::default().set_certification(true); - assert_eq!(cert.keys().set_policy(p, None).key_flags(flags).count(), + assert_eq!(cert.keys().with_policy(p, None).key_flags(flags).count(), 2); } @@ -1116,20 +1116,20 @@ mod test { .add_storage_encryption_subkey() .add_authentication_subkey() .generate().unwrap(); - assert_eq!(cert.keys().set_policy(p, None).alive().revoked(false) + assert_eq!(cert.keys().with_policy(p, None).alive().revoked(false) .for_certification().count(), 2); - assert_eq!(cert.keys().set_policy(p, None).alive().revoked(false) + assert_eq!(cert.keys().with_policy(p, None).alive().revoked(false) .for_transport_encryption().count(), 1); - assert_eq!(cert.keys().set_policy(p, None).alive().revoked(false) + assert_eq!(cert.keys().with_policy(p, None).alive().revoked(false) .for_storage_encryption().count(), 1); - assert_eq!(cert.keys().set_policy(p, None).alive().revoked(false) + assert_eq!(cert.keys().with_policy(p, None).alive().revoked(false) .for_signing().count(), 1); - assert_eq!(cert.keys().set_policy(p, None).alive().revoked(false) + assert_eq!(cert.keys().with_policy(p, None).alive().revoked(false) .key_flags(KeyFlags::default().set_authentication(true)) .count(), 1); @@ -1178,12 +1178,12 @@ mod test { .collect::>(), &keyids); check( - &cert.keys().set_policy(p, None).key_handles(keyids.iter()) + &cert.keys().with_policy(p, None).key_handles(keyids.iter()) .map(|ka| ka.key().key_handle()) .collect::>(), &keyids); check( - &cert.keys().key_handles(keyids.iter()).set_policy(p, None) + &cert.keys().key_handles(keyids.iter()).with_policy(p, None) .map(|ka| ka.key().key_handle()) .collect::>(), &keyids); diff --git a/openpgp/src/cert/mod.rs b/openpgp/src/cert/mod.rs index 5051a225..4dc126ef 100644 --- a/openpgp/src/cert/mod.rs +++ b/openpgp/src/cert/mod.rs @@ -455,7 +455,7 @@ impl Cert { // Both a primary key signature and the primary userid's // binding signature can override a soft revocation. Compute // the most recent one. - let vkao = self.primary_key().set_policy(policy, t).ok(); + let vkao = self.primary_key().with_policy(policy, t).ok(); let mut sig = vkao.as_ref().map(|vka| vka.binding_signature()); if let Some(direct) = vkao.as_ref() .and_then(|vka| vka.direct_key_signature()) @@ -535,7 +535,7 @@ impl Cert { where T: Into> { let t = t.into(); - self.primary_key().set_policy(policy, t).context("Primary key")?.alive() + self.primary_key().with_policy(policy, t).context("Primary key")?.alive() } /// Sets the key to expire in delta seconds. @@ -551,7 +551,7 @@ impl Cert { now: time::SystemTime) -> Result { - let primary = self.primary_key().set_policy(policy, now)?; + let primary = self.primary_key().with_policy(policy, now)?; let mut sigs = Vec::new(); let binding = primary.binding_signature(); for template in [ @@ -1816,13 +1816,13 @@ mod test { let cert = Cert::from_bytes(crate::tests::key("about-to-expire.expired.pgp")) .unwrap(); - cert.primary_key().set_policy(p, None).unwrap().alive().unwrap_err(); + cert.primary_key().with_policy(p, None).unwrap().alive().unwrap_err(); let update = Cert::from_bytes(crate::tests::key("about-to-expire.update-no-uid.pgp")) .unwrap(); let cert = cert.merge(update).unwrap(); - cert.primary_key().set_policy(p, None).unwrap().alive().unwrap(); + cert.primary_key().with_policy(p, None).unwrap().alive().unwrap(); } #[test] @@ -1927,7 +1927,7 @@ mod test { let now = cert.primary_key().creation_time(); let a_sec = time::Duration::new(1, 0); - let expiry_orig = cert.primary_key().set_policy(policy, now).unwrap() + let expiry_orig = cert.primary_key().with_policy(policy, now).unwrap() .key_expiration_time() .expect("Keys expire by default."); @@ -1940,14 +1940,14 @@ mod test { policy, &mut keypair, None, as_of1).unwrap(); { // If t < as_of1, we should get the original expiry. - assert_eq!(cert.primary_key().set_policy(policy, now).unwrap() + assert_eq!(cert.primary_key().with_policy(policy, now).unwrap() .key_expiration_time(), Some(expiry_orig)); - assert_eq!(cert.primary_key().set_policy(policy, as_of1 - a_sec).unwrap() + assert_eq!(cert.primary_key().with_policy(policy, as_of1 - a_sec).unwrap() .key_expiration_time(), Some(expiry_orig)); // If t >= as_of1, we should get the new expiry. - assert_eq!(cert.primary_key().set_policy(policy, as_of1).unwrap() + assert_eq!(cert.primary_key().with_policy(policy, as_of1).unwrap() .key_expiration_time(), None); } @@ -1963,22 +1963,22 @@ mod test { policy, &mut keypair, Some(expiry_new), as_of2).unwrap(); { // If t < as_of1, we should get the original expiry. - assert_eq!(cert.primary_key().set_policy(policy, now).unwrap() + assert_eq!(cert.primary_key().with_policy(policy, now).unwrap() .key_expiration_time(), Some(expiry_orig)); - assert_eq!(cert.primary_key().set_policy(policy, as_of1 - a_sec).unwrap() + assert_eq!(cert.primary_key().with_policy(policy, as_of1 - a_sec).unwrap() .key_expiration_time(), Some(expiry_orig)); // If as_of1 <= t < as_of2, we should get the second // expiry (None). - assert_eq!(cert.primary_key().set_policy(policy, as_of1).unwrap() + assert_eq!(cert.primary_key().with_policy(policy, as_of1).unwrap() .key_expiration_time(), None); - assert_eq!(cert.primary_key().set_policy(policy, as_of2 - a_sec).unwrap() + assert_eq!(cert.primary_key().with_policy(policy, as_of2 - a_sec).unwrap() .key_expiration_time(), None); // If t <= as_of2, we should get the new expiry. - assert_eq!(cert.primary_key().set_policy(policy, as_of2).unwrap() + assert_eq!(cert.primary_key().with_policy(policy, as_of2).unwrap() .key_expiration_time(), Some(expiry_new)); } @@ -2000,7 +2000,7 @@ mod test { let cert2 = Cert::from_bytes(&buf).unwrap(); assert_eq!( - cert2.primary_key().set_policy(p, None).unwrap() + cert2.primary_key().with_policy(p, None).unwrap() .direct_key_signature().unwrap().typ(), SignatureType::DirectKey); assert_eq!(cert2.userids().count(), 0); @@ -2014,7 +2014,7 @@ mod test { // If we have a user id---even if it is revoked---we have // a primary key signature. - let typ = cert.primary_key().set_policy(p, None).unwrap() + let typ = cert.primary_key().with_policy(p, None).unwrap() .binding_signature().typ(); assert_eq!(typ, SignatureType::PositiveCertification, "{:#?}", cert); @@ -2028,7 +2028,7 @@ mod test { "{:#?}", cert); } - for userid in cert.userids().set_policy(p, None) { + for userid in cert.userids().with_policy(p, None) { let typ = userid.binding_signature().typ(); assert_eq!(typ, SignatureType::PositiveCertification, "{:#?}", cert); @@ -2188,7 +2188,7 @@ mod test { .generate().unwrap(); let sig = { - let uid = cert.userids().set_policy(p, None).nth(1).unwrap(); + let uid = cert.userids().with_policy(p, None).nth(1).unwrap(); assert_eq!(RevocationStatus::NotAsFarAsWeKnow, uid.revoked()); let mut keypair = cert.primary_key().key().clone().mark_parts_secret() @@ -2205,7 +2205,7 @@ mod test { assert_eq!(RevocationStatus::NotAsFarAsWeKnow, cert.revoked(p, None)); - let uid = cert.userids().set_policy(p, None).nth(1).unwrap(); + let uid = cert.userids().with_policy(p, None).nth(1).unwrap(); assert_match!(RevocationStatus::Revoked(_) = uid.revoked()); } @@ -2347,7 +2347,7 @@ mod test { let cert = Cert::from_bytes( crate::tests::key( &format!("really-revoked-{}-0-public.pgp", f))).unwrap(); - let selfsig0 = cert.primary_key().set_policy(p, None).unwrap() + let selfsig0 = cert.primary_key().with_policy(p, None).unwrap() .binding_signature().signature_creation_time().unwrap(); assert!(!revoked(p, &cert, Some(selfsig0))); @@ -2405,7 +2405,7 @@ mod test { let mut slim_shady = false; let mut eminem = false; - for b in cert.userids().set_policy(p, t) { + for b in cert.userids().with_policy(p, t) { if b.userid().value() == b"Slim Shady" { assert!(!slim_shady); slim_shady = true; @@ -2466,7 +2466,7 @@ mod test { let now = time::SystemTime::now(); let selfsig0 - = cert.userids().set_policy(p, now).map(|b| { + = cert.userids().with_policy(p, now).map(|b| { b.binding_signature().signature_creation_time().unwrap() }) .max().unwrap(); @@ -2523,7 +2523,7 @@ mod test { let cert = Cert::from_bytes(crate::tests::key("un-revoked-userid.pgp")).unwrap(); - for uid in cert.userids().set_policy(p, None) { + for uid in cert.userids().with_policy(p, None) { assert_eq!(uid.revoked(), RevocationStatus::NotAsFarAsWeKnow); } } @@ -2718,7 +2718,7 @@ Pu1xwz57O4zo1VYf6TqHJzVC3OMvMUM2hhdecMUe5x6GorNaj6g= let now = time::SystemTime::now(); let selfsig0 - = cert.userids().set_policy(p, now).map(|b| { + = cert.userids().with_policy(p, now).map(|b| { b.binding_signature().signature_creation_time().unwrap() }) .max().unwrap(); @@ -2783,7 +2783,7 @@ Pu1xwz57O4zo1VYf6TqHJzVC3OMvMUM2hhdecMUe5x6GorNaj6g= let cert = Cert::from_bytes( crate::tests::key("primary-key-0-public.pgp")).unwrap(); let selfsig0 - = cert.userids().set_policy(p, now).map(|b| { + = cert.userids().with_policy(p, now).map(|b| { b.binding_signature().signature_creation_time().unwrap() }) .max().unwrap(); @@ -2925,22 +2925,22 @@ Pu1xwz57O4zo1VYf6TqHJzVC3OMvMUM2hhdecMUe5x6GorNaj6g= // A time that matches multiple signatures. let direct_signatures = cert.primary_key().bundle().self_signatures(); - assert_eq!(cert.primary_key().set_policy(p, *t).unwrap() + assert_eq!(cert.primary_key().with_policy(p, *t).unwrap() .direct_key_signature(), direct_signatures.get(*offset)); // A time that doesn't match any signature. - assert_eq!(cert.primary_key().set_policy(p, *t + a_sec).unwrap() + assert_eq!(cert.primary_key().with_policy(p, *t + a_sec).unwrap() .direct_key_signature(), direct_signatures.get(*offset)); // The current time, which should use the first signature. - assert_eq!(cert.primary_key().set_policy(p, None).unwrap() + assert_eq!(cert.primary_key().with_policy(p, None).unwrap() .direct_key_signature(), direct_signatures.get(0)); // The beginning of time, which should return no // binding signatures. - assert!(cert.primary_key().set_policy(p, time_zero).is_err()); + assert!(cert.primary_key().with_policy(p, time_zero).is_err()); } } } @@ -3071,7 +3071,7 @@ Pu1xwz57O4zo1VYf6TqHJzVC3OMvMUM2hhdecMUe5x6GorNaj6g= let uid = UserID::from("foo@example.org"); let cert = cert.merge_packets(vec![uid.into()])?; assert_eq!(cert.userids().count(), 1); - assert_eq!(cert.userids().set_policy(&p, None).count(), 0); + assert_eq!(cert.userids().with_policy(&p, None).count(), 0); // Add a bare user attribute. use packet::user_attribute::{Subpacket, Image}; @@ -3081,7 +3081,7 @@ Pu1xwz57O4zo1VYf6TqHJzVC3OMvMUM2hhdecMUe5x6GorNaj6g= ])?; let cert = cert.merge_packets(vec![ua.into()])?; assert_eq!(cert.user_attributes().count(), 1); - assert_eq!(cert.user_attributes().set_policy(&p, None).count(), 0); + assert_eq!(cert.user_attributes().with_policy(&p, None).count(), 0); // Add a bare signing subkey. let signing_subkey: Key<_, key::SubordinateRole> = @@ -3089,7 +3089,7 @@ Pu1xwz57O4zo1VYf6TqHJzVC3OMvMUM2hhdecMUe5x6GorNaj6g= let _signing_subkey_pair = signing_subkey.clone().into_keypair()?; let cert = cert.merge_packets(vec![signing_subkey.into()])?; assert_eq!(cert.keys().skip_primary().count(), 1); - assert_eq!(cert.keys().skip_primary().set_policy(&p, None).count(), 0); + assert_eq!(cert.keys().skip_primary().with_policy(&p, None).count(), 0); // Add a component that Sequoia doesn't understand. let mut fake_key = packet::Unknown::new( @@ -3116,7 +3116,7 @@ Pu1xwz57O4zo1VYf6TqHJzVC3OMvMUM2hhdecMUe5x6GorNaj6g= crate::tests::key("eike-v3-v4.pgp"))?; dbg!(&cert); assert_eq!(cert.userids() - .set_policy(&crate::policy::StandardPolicy::new(), None) + .with_policy(&crate::policy::StandardPolicy::new(), None) .count(), 1); Ok(()) } diff --git a/openpgp/src/cert/revoke.rs b/openpgp/src/cert/revoke.rs index 05bd458a..1c890e23 100644 --- a/openpgp/src/cert/revoke.rs +++ b/openpgp/src/cert/revoke.rs @@ -303,7 +303,7 @@ impl Deref for SubkeyRevocationBuilder { /// let cert = cert.merge_packets(vec![revocation.clone().into()])?; /// /// // Check that it is revoked. -/// let userid = cert.userids().set_policy(p, None).nth(0).unwrap(); +/// let userid = cert.userids().with_policy(p, None).nth(0).unwrap(); /// if let RevocationStatus::Revoked(revocations) = userid.revoked() { /// assert_eq!(revocations.len(), 1); /// assert_eq!(*revocations[0], revocation); @@ -423,7 +423,7 @@ impl Deref for UserIDRevocationBuilder { /// let cert = cert.merge_packets(vec![revocation.clone().into()])?; /// /// // Check that it is revoked. -/// let ua = cert.user_attributes().set_policy(p, None).nth(0).unwrap(); +/// let ua = cert.user_attributes().with_policy(p, None).nth(0).unwrap(); /// if let RevocationStatus::Revoked(revocations) = ua.revoked() { /// assert_eq!(revocations.len(), 1); /// assert_eq!(*revocations[0], revocation); diff --git a/openpgp/src/packet/signature/mod.rs b/openpgp/src/packet/signature/mod.rs index 5c3af38f..036ca793 100644 --- a/openpgp/src/packet/signature/mod.rs +++ b/openpgp/src/packet/signature/mod.rs @@ -1378,7 +1378,7 @@ mod test { let test1 = Cert::from_bytes( crate::tests::key("test1-certification-key.pgp")).unwrap(); - let cert_key1 = test1.keys().set_policy(p, None) + let cert_key1 = test1.keys().with_policy(p, None) .for_certification() .nth(0) .map(|ka| ka.key()) @@ -1386,7 +1386,7 @@ mod test { let test2 = Cert::from_bytes( crate::tests::key("test2-signed-by-test1.pgp")).unwrap(); let uid_binding = - test2.userids().set_policy(p, None).nth(0).unwrap().bundle(); + test2.userids().with_policy(p, None).nth(0).unwrap().bundle(); let cert = &uid_binding.certifications()[0]; cert.verify_userid_binding(cert_key1, diff --git a/openpgp/src/parse/stream.rs b/openpgp/src/parse/stream.rs index a1931c15..3e0dad10 100644 --- a/openpgp/src/parse/stream.rs +++ b/openpgp/src/parse/stream.rs @@ -764,7 +764,7 @@ impl<'a, H: VerificationHelper> Verifier<'a, H> { let issuers = sig.get_issuers(); for ka in self.certs.iter() .flat_map(|cert| { - cert.keys().set_policy(self.policy, sig_time) + cert.keys().with_policy(self.policy, sig_time) .key_handles(issuers.iter()) }) { @@ -1759,7 +1759,7 @@ impl<'a, H: VerificationHelper + DecryptionHelper> Decryptor<'a, H> { let issuers = sig.get_issuers(); for ka in self.certs.iter() .flat_map(|cert| { - cert.keys().set_policy(self.policy, sig_time) + cert.keys().with_policy(self.policy, sig_time) .key_handles(issuers.iter()) }) { @@ -2276,7 +2276,7 @@ mod test { // sign 30MiB message let mut buf = vec![]; { - let key = cert.keys().set_policy(p, None).for_signing().nth(0).unwrap().key(); + let key = cert.keys().with_policy(p, None).for_signing().nth(0).unwrap().key(); let keypair = key.clone().mark_parts_secret().unwrap() .into_keypair().unwrap(); diff --git a/openpgp/src/policy.rs b/openpgp/src/policy.rs index 29b6135f..261dbab6 100644 --- a/openpgp/src/policy.rs +++ b/openpgp/src/policy.rs @@ -97,7 +97,7 @@ mod test { .add_transport_encryption_subkey() .generate().unwrap(); - assert_eq!(cert.keys().set_policy(p, None).count(), 3); + assert_eq!(cert.keys().with_policy(p, None).count(), 3); // Reject all direct key signatures. #[derive(Debug)] @@ -114,7 +114,7 @@ mod test { } let p = &NoDirectKeySigs {}; - assert_eq!(cert.keys().set_policy(p, None).count(), 0); + assert_eq!(cert.keys().with_policy(p, None).count(), 0); // Reject all subkey signatures. #[derive(Debug)] @@ -131,7 +131,7 @@ mod test { } let p = &NoSubkeySigs {}; - assert_eq!(cert.keys().set_policy(p, None).count(), 1); + assert_eq!(cert.keys().with_policy(p, None).count(), 1); } #[test] @@ -151,8 +151,8 @@ mod test { .generate()?; // Make sure we have all keys and all user ids. - assert_eq!(cert.keys().set_policy(p, None).count(), 3); - assert_eq!(cert.userids().set_policy(p, None).count(), 1); + assert_eq!(cert.keys().with_policy(p, None).count(), 3); + assert_eq!(cert.userids().with_policy(p, None).count(), 1); // Reject all user id signatures. #[derive(Debug)] @@ -168,7 +168,7 @@ mod test { } } let p = &NoPositiveCertifications {}; - assert_eq!(cert.userids().set_policy(p, None).count(), 0); + assert_eq!(cert.userids().with_policy(p, None).count(), 0); // Revoke it. @@ -189,7 +189,7 @@ mod test { let cert = cert.merge_packets(vec![revocation.clone().into()])?; // Check that it is revoked. - assert_eq!(cert.userids().set_policy(p, None).revoked(false).count(), 0); + assert_eq!(cert.userids().with_policy(p, None).revoked(false).count(), 0); // Reject all user id signatures. #[derive(Debug)] @@ -207,7 +207,7 @@ mod test { let p = &NoCertificationRevocation {}; // Check that the user id is no longer revoked. - assert_eq!(cert.userids().set_policy(p, None).revoked(false).count(), 1); + assert_eq!(cert.userids().with_policy(p, None).revoked(false).count(), 1); // Generate the revocation for the first subkey. @@ -221,9 +221,9 @@ mod test { assert_eq!(revocation.typ(), SignatureType::SubkeyRevocation); // Now merge the revocation signature into the Cert. - assert_eq!(cert.keys().set_policy(p, None).revoked(false).count(), 3); + assert_eq!(cert.keys().with_policy(p, None).revoked(false).count(), 3); let cert = cert.merge_packets(vec![revocation.clone().into()])?; - assert_eq!(cert.keys().set_policy(p, None).revoked(false).count(), 2); + assert_eq!(cert.keys().with_policy(p, None).revoked(false).count(), 2); // Reject all subkey revocations. #[derive(Debug)] @@ -241,7 +241,7 @@ mod test { let p = &NoSubkeyRevocation {}; // Check that the key is no longer revoked. - assert_eq!(cert.keys().set_policy(p, None).revoked(false).count(), 3); + assert_eq!(cert.keys().with_policy(p, None).revoked(false).count(), 3); Ok(()) } diff --git a/openpgp/src/serialize/cert.rs b/openpgp/src/serialize/cert.rs index 330254e6..1297d317 100644 --- a/openpgp/src/serialize/cert.rs +++ b/openpgp/src/serialize/cert.rs @@ -337,7 +337,7 @@ impl<'a> TSK<'a> { /// let p = &StandardPolicy::new(); /// /// let (cert, _) = CertBuilder::new().add_signing_subkey().generate()?; - /// assert_eq!(cert.keys().set_policy(p, None).alive().revoked(false).secret().count(), 2); + /// assert_eq!(cert.keys().with_policy(p, None).alive().revoked(false).secret().count(), 2); /// /// // Only write out the primary key's secret. /// let mut buf = Vec::new(); @@ -346,7 +346,7 @@ impl<'a> TSK<'a> { /// .serialize(&mut buf)?; /// /// let cert_ = Cert::from_bytes(&buf)?; - /// assert_eq!(cert_.keys().set_policy(p, None).alive().revoked(false).secret().count(), 1); + /// assert_eq!(cert_.keys().with_policy(p, None).alive().revoked(false).secret().count(), 1); /// assert!(cert_.primary_key().secret().is_some()); /// # Ok(()) } pub fn set_filter

(mut self, predicate: P) -> Self @@ -771,7 +771,7 @@ mod test { let uid_binding = uid.bind( &mut keypair, &cert, signature::Builder::from( - cert.primary_key().set_policy(p, None).unwrap() + cert.primary_key().with_policy(p, None).unwrap() .direct_key_signature().unwrap().clone()) .set_type(SignatureType::PositiveCertification) .set_exportable_certification(false).unwrap()).unwrap(); @@ -782,7 +782,7 @@ mod test { let ua_binding = ua.bind( &mut keypair, &cert, signature::Builder::from( - cert.primary_key().set_policy(p, None).unwrap() + cert.primary_key().with_policy(p, None).unwrap() .direct_key_signature().unwrap().clone()) .set_type(SignatureType::PositiveCertification) .set_exportable_certification(false).unwrap()).unwrap(); @@ -797,9 +797,9 @@ mod test { assert!(cert.subkeys().nth(0).unwrap().binding_signature(p, None) .is_some()); assert_eq!(cert.userids().count(), 1); - assert!(cert.userids().set_policy(p, None).nth(0).is_some()); + assert!(cert.userids().with_policy(p, None).nth(0).is_some()); assert_eq!(cert.user_attributes().count(), 1); - assert!(cert.user_attributes().set_policy(p, None).nth(0).is_some()); + assert!(cert.user_attributes().with_policy(p, None).nth(0).is_some()); // The binding signature is not exportable, so when we export // and re-parse, we expect the userid to be gone. diff --git a/openpgp/src/serialize/stream.rs b/openpgp/src/serialize/stream.rs index 328c7e74..a3760b84 100644 --- a/openpgp/src/serialize/stream.rs +++ b/openpgp/src/serialize/stream.rs @@ -233,7 +233,7 @@ impl<'a> Signer<'a> { /// # let tsk = Cert::from_bytes(&include_bytes!( /// # "../../tests/data/keys/testy-new-private.pgp")[..]) /// # .unwrap(); - /// # let keypair = tsk.keys().set_policy(p, None).alive().revoked(false).for_signing() + /// # let keypair = tsk.keys().with_policy(p, None).alive().revoked(false).for_signing() /// # .nth(0).unwrap() /// # .key().clone().mark_parts_secret().unwrap().into_keypair().unwrap(); /// # f(tsk, keypair).unwrap(); @@ -343,7 +343,7 @@ impl<'a> Signer<'a> { /// # "../../tests/data/keys/testy-new-private.pgp")[..]) /// # .unwrap(); /// # let keypair - /// # = tsk.keys().set_policy(p, None).alive().revoked(false).for_signing() + /// # = tsk.keys().with_policy(p, None).alive().revoked(false).for_signing() /// # .nth(0).unwrap() /// # .key().clone().mark_parts_secret().unwrap().into_keypair() /// # .unwrap(); @@ -1011,7 +1011,7 @@ impl<'a> Encryptor<'a> { /// /// // Build a vector of recipients to hand to Encryptor. /// let recipient = - /// cert.keys().set_policy(p, None).alive().revoked(false) + /// cert.keys().with_policy(p, None).alive().revoked(false) /// // Or `for_storage_encryption()`, for data at rest. /// .for_transport_encryption() /// .map(|ka| ka.key().into()) @@ -1498,7 +1498,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().set_policy(p, crate::frozen_time()) + for key in tsk.keys().with_policy(p, crate::frozen_time()) .for_signing().map(|ka| ka.key()) { keys.insert(key.fingerprint(), key.clone()); @@ -1702,7 +1702,7 @@ mod test { mut decrypt: D) -> Result> where D: FnMut(SymmetricAlgorithm, &SessionKey) -> Result<()> { - let mut keypair = self.tsk.keys().set_policy(self.policy, None) + let mut keypair = self.tsk.keys().with_policy(self.policy, None) .for_transport_encryption() .map(|ka| ka.key()).next().unwrap() .clone().mark_parts_secret().unwrap() @@ -1731,7 +1731,7 @@ mod test { { let m = Message::new(&mut msg); let recipient = tsk - .keys().set_policy(p, None) + .keys().with_policy(p, None) .for_storage_encryption().for_transport_encryption() .nth(0).unwrap().key().into(); let encryptor = Encryptor::for_recipient(m, recipient) @@ -1821,7 +1821,7 @@ mod test { .generate().unwrap(); // What we're going to sign with. - let ka = cert.keys().set_policy(p, None).for_signing().nth(0).unwrap(); + let ka = cert.keys().with_policy(p, None).for_signing().nth(0).unwrap(); // A timestamp later than the key's creation. let timestamp = ka.key().creation_time() diff --git a/openpgp/src/types/timestamp.rs b/openpgp/src/types/timestamp.rs index 53f84987..aa60812c 100644 --- a/openpgp/src/types/timestamp.rs +++ b/openpgp/src/types/timestamp.rs @@ -129,13 +129,13 @@ impl Timestamp { /// /// /// First, get the certification key. /// let mut keypair = - /// alice.keys().set_policy(policy, t).secret().for_certification() + /// alice.keys().with_policy(policy, t).secret().for_certification() /// .nth(0).ok_or_else(|| failure::err_msg("no valid key at"))? /// .key().clone().into_keypair()?; /// /// // Then, lookup the binding between `bob@example.org` and /// // `bob` at `t`. - /// let ca = bob.userids().set_policy(policy, t) + /// let ca = bob.userids().with_policy(policy, t) /// .filter(|ca| ca.userid().value() == b"bob@example.org") /// .nth(0).ok_or_else(|| failure::err_msg("no valid userid"))?; /// -- cgit v1.2.3