diff options
Diffstat (limited to 'openpgp/src/cert/keyiter.rs')
-rw-r--r-- | openpgp/src/cert/keyiter.rs | 38 |
1 files changed, 19 insertions, 19 deletions
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::<Vec<_>>(); /// # 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<T>(self, policy: &'a dyn Policy, time: T) + pub fn with_policy<T>(self, policy: &'a dyn Policy, time: T) -> ValidKeyIter<'a, P> where T: Into<Option<SystemTime>> { @@ -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::<Vec<KeyHandle>>(), &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::<Vec<KeyHandle>>(), &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::<Vec<KeyHandle>>(), &keyids); |