diff options
author | Justus Winter <justus@sequoia-pgp.org> | 2020-02-06 14:15:10 +0100 |
---|---|---|
committer | Justus Winter <justus@sequoia-pgp.org> | 2020-02-06 14:15:10 +0100 |
commit | d183e12a3231e4c505f5f2cf48b6c1f881ad258a (patch) | |
tree | affb4e4c0acc3bce3d14adba627f5193c166bc32 | |
parent | c8eb94375a38e5606441a9e86d402442662ffb02 (diff) |
openpgp: Rename ComponentBinding to ComponentBundle, etc.
- Likewise KeyBinding, UserIDBinding, UserAttributeBinding,
UnknownBinding, etc.
- Reason: a self-signature on a component is a binding, but
revocations and TPSes are not bindings.
- Consistently call collections of components and associated
signatures bundles now. Likewise for fields, methods.
- Fixes #425.
28 files changed, 287 insertions, 287 deletions
diff --git a/examples/guide-exploring-openpgp.rs b/examples/guide-exploring-openpgp.rs index 05a777e4..6d905b9e 100644 --- a/examples/guide-exploring-openpgp.rs +++ b/examples/guide-exploring-openpgp.rs @@ -58,15 +58,15 @@ fn main() { for (i, ca) in cert.userids().set_policy(p, None).enumerate() { println!("{}: UID: {}, {} self-signature(s), {} certification(s)", i, ca.userid(), - ca.binding().self_signatures().len(), - ca.binding().certifications().len()); + ca.bundle().self_signatures().len(), + ca.bundle().certifications().len()); } // List subkeys. for (i, ka) in cert.keys().set_policy(p, None).skip(1).enumerate() { println!("{}: Fingerprint: {}, {} self-signature(s), {} certification(s)", i, ka.key().fingerprint(), - ka.binding().self_signatures().len(), - ka.binding().certifications().len()); + ka.bundle().self_signatures().len(), + ka.bundle().certifications().len()); } } diff --git a/ffi-macros/src/rust2c.rs b/ffi-macros/src/rust2c.rs index 0f06a674..2e469703 100644 --- a/ffi-macros/src/rust2c.rs +++ b/ffi-macros/src/rust2c.rs @@ -16,9 +16,9 @@ fn ident2c(ident: &syn::Ident) -> (String, bool) { "KeyID" => return ("pgp_keyid_t".into(), true), "CertBuilder" => return ("pgp_cert_builder_t".into(), true), "UserID" => return ("pgp_userid_t".into(), true), - "UserIDBinding" => return ("pgp_user_id_binding_t".into(), true), - "UserIDBindingIter" => - return ("pgp_user_id_binding_iter_t".into(), true), + "UserIDBundle" => return ("pgp_user_id_bundle_t".into(), true), + "UserIDBundleIter" => + return ("pgp_user_id_bundle_iter_t".into(), true), // Types from the libc crate. "c_void" => return ("void".into(), false), diff --git a/ffi/src/store.rs b/ffi/src/store.rs index d0401d01..af71d350 100644 --- a/ffi/src/store.rs +++ b/ffi/src/store.rs @@ -29,7 +29,7 @@ use std::ptr; extern crate sequoia_openpgp as openpgp; use sequoia_store::{ - self, Mapping, MappingIter, Binding, BindingIter, Key, KeyIter, LogIter, Store, + self, Mapping, MappingIter, Binding, BundleIter, Key, KeyIter, LogIter, Store, }; use super::error::Status; @@ -295,7 +295,7 @@ fn sq_mapping_delete(ctx: *mut Context, mapping: *mut Mapping) /// Lists all bindings. #[::sequoia_ffi_macros::extern_fn] #[no_mangle] pub extern "C" fn sq_mapping_iter(ctx: *mut Context, mapping: *const Mapping) - -> *mut BindingIter { + -> *mut BundleIter { let ctx = ffi_param_ref_mut!(ctx); ffi_make_fry_from_ctx!(ctx); let mapping = ffi_param_ref!(mapping); @@ -309,7 +309,7 @@ fn sq_mapping_iter(ctx: *mut Context, mapping: *const Mapping) /// bindings label is mappingd there. If `fpp` is not `NULL`, the /// bindings fingerprint is mappingd there. #[::sequoia_ffi_macros::extern_fn] #[no_mangle] pub extern "C" -fn sq_binding_iter_next(iter: *mut BindingIter, +fn sq_binding_iter_next(iter: *mut BundleIter, labelp: Option<&mut *mut c_char>, fpp: Option<&mut Maybe<Fingerprint>>) -> *mut Binding { @@ -337,7 +337,7 @@ fn sq_binding_iter_next(iter: *mut BindingIter, /// Frees a sq_binding_iter_t. #[::sequoia_ffi_macros::extern_fn] #[no_mangle] pub extern "C" -fn sq_binding_iter_free(iter: Option<&mut BindingIter>) { +fn sq_binding_iter_free(iter: Option<&mut BundleIter>) { ffi_free!(iter) } diff --git a/net/src/wkd.rs b/net/src/wkd.rs index fd598731..0b16ac35 100644 --- a/net/src/wkd.rs +++ b/net/src/wkd.rs @@ -235,7 +235,7 @@ fn parse_body<S: AsRef<str>>(body: &[u8], email_address: S) let valid_certs: Vec<Cert> = certs.iter() // XXX: This filter could become a Cert method, but it adds other API // method to maintain - .filter(|cert| {cert.userids().bindings() + .filter(|cert| {cert.userids().bundles() .any(|uidb| if let Ok(Some(a)) = uidb.userid().email() { a == email_address @@ -344,7 +344,7 @@ pub fn insert<P, S, V>(base_path: P, domain: S, variant: V, let variant = variant.into().unwrap_or_default(); // First, check which UserIDs are in `domain`. - let addresses = cert.userids().bindings().filter_map(|uidb| { + let addresses = cert.userids().bundles().filter_map(|uidb| { uidb.userid().email().unwrap_or(None).and_then(|addr| { if EmailAddress::from(&addr).ok().map(|e| e.domain == domain) .unwrap_or(false) diff --git a/openpgp-ffi/include/sequoia/openpgp.h b/openpgp-ffi/include/sequoia/openpgp.h index 83c7416e..647bc4af 100644 --- a/openpgp-ffi/include/sequoia/openpgp.h +++ b/openpgp-ffi/include/sequoia/openpgp.h @@ -584,7 +584,7 @@ pgp_packet_t pgp_literal_into_packet (pgp_literal_t literal); /*/ void pgp_literal_free (pgp_literal_t literal); -/* openpgp::cert::UserIDBinding. */ +/* openpgp::cert::UserIDBundle. */ /*/ /// Returns the user id. @@ -595,25 +595,25 @@ void pgp_literal_free (pgp_literal_t literal); /// /// The caller must free the returned value. /*/ -char *pgp_user_id_binding_user_id (pgp_user_id_binding_t binding); +char *pgp_user_id_bundle_user_id (pgp_user_id_bundle_t binding); /*/ /// Returns a reference to the self-signature, if any. /*/ -pgp_signature_t pgp_user_id_binding_selfsig(pgp_user_id_binding_t binding, +pgp_signature_t pgp_user_id_bundle_selfsig(pgp_user_id_bundle_t binding, pgp_policy_t policy); -/* openpgp::cert::UserIDBindingIter. */ +/* openpgp::cert::UserIDBundleIter. */ /*/ /// Returns the next element in the iterator. /*/ -pgp_user_id_binding_t pgp_user_id_binding_iter_next (pgp_user_id_binding_iter_t iter); +pgp_user_id_bundle_t pgp_user_id_bundle_iter_next (pgp_user_id_bundle_iter_t iter); /*/ -/// Frees an pgp_user_id_binding_iter_t. +/// Frees an pgp_user_id_bundle_iter_t. /*/ -void pgp_user_id_binding_iter_free (pgp_user_id_binding_iter_t iter); +void pgp_user_id_bundle_iter_free (pgp_user_id_bundle_iter_t iter); /* openpgp::cert::KeyIter. */ @@ -940,9 +940,9 @@ pgp_cert_t pgp_cert_set_expiry(pgp_error_t *errp, int pgp_cert_is_tsk(pgp_cert_t cert); /*/ -/// Returns an iterator over the `UserIDBinding`s. +/// Returns an iterator over the `UserIDBundle`s. /*/ -pgp_user_id_binding_iter_t pgp_cert_user_id_binding_iter (pgp_cert_t cert); +pgp_user_id_bundle_iter_t pgp_cert_user_id_binding_iter (pgp_cert_t cert); /*/ /// Returns an iterator over all `Key`s in a Cert. diff --git a/openpgp-ffi/include/sequoia/openpgp/types.h b/openpgp-ffi/include/sequoia/openpgp/types.h index 7a8eb83a..e99413d0 100644 --- a/openpgp-ffi/include/sequoia/openpgp/types.h +++ b/openpgp-ffi/include/sequoia/openpgp/types.h @@ -366,12 +366,12 @@ typedef struct pgp_packet_pile *pgp_packet_pile_t; /*/ /// A `UserIDBinding`. /*/ -typedef struct pgp_user_id_binding *pgp_user_id_binding_t; +typedef struct pgp_user_id_bundle *pgp_user_id_bundle_t; /*/ /// An iterator over `UserIDBinding`s. /*/ -typedef struct pgp_user_id_binding_iter *pgp_user_id_binding_iter_t; +typedef struct pgp_user_id_bundle_iter *pgp_user_id_bundle_iter_t; /*/ /// An iterator over keys in a Cert. diff --git a/openpgp-ffi/src/cert.rs b/openpgp-ffi/src/cert.rs index e2a58c03..bfba521c 100644 --- a/openpgp-ffi/src/cert.rs +++ b/openpgp-ffi/src/cert.rs @@ -27,8 +27,8 @@ use self::openpgp::{ ValidKeyIter, components::{ Amalgamation, - UserIDBinding, - UserIDBindingIter, + UserIDBundle, + UserIDBundleIter, }, }, }; @@ -385,7 +385,7 @@ fn pgp_cert_primary_user_id(cert: *const Cert, policy: *const Policy) } } -/* UserIDBinding */ +/* UserIDBundle */ /// Returns the user id. /// @@ -395,8 +395,8 @@ fn pgp_cert_primary_user_id(cert: *const Cert, policy: *const Policy) /// /// The caller must free the returned value. #[::sequoia_ffi_macros::extern_fn] #[no_mangle] -pub extern "C" fn pgp_user_id_binding_user_id( - binding: *const UserIDBinding) +pub extern "C" fn pgp_user_id_bundle_user_id( + binding: *const UserIDBundle) -> *mut c_char { let binding = ffi_param_ref!(binding); @@ -406,8 +406,8 @@ pub extern "C" fn pgp_user_id_binding_user_id( /// Returns a reference to the self-signature, if any. #[::sequoia_ffi_macros::extern_fn] #[no_mangle] -pub extern "C" fn pgp_user_id_binding_selfsig( - binding: *const UserIDBinding, +pub extern "C" fn pgp_user_id_bundle_selfsig( + binding: *const UserIDBundle, policy: *const Policy) -> Maybe<Signature> { @@ -417,30 +417,30 @@ pub extern "C" fn pgp_user_id_binding_selfsig( } -/* UserIDBindingIter */ +/* UserIDBundleIter */ /// Returns an iterator over the Cert's user id bindings. #[::sequoia_ffi_macros::extern_fn] #[no_mangle] pub extern "C" fn pgp_cert_user_id_binding_iter(cert: *const Cert) - -> *mut UserIDBindingIter<'static> + -> *mut UserIDBundleIter<'static> { let cert = cert.ref_raw(); - box_raw!(cert.userids().bindings()) + box_raw!(cert.userids().bundles()) } -/// Frees a pgp_user_id_binding_iter_t. +/// Frees a pgp_user_id_bundle_iter_t. #[::sequoia_ffi_macros::extern_fn] #[no_mangle] -pub extern "C" fn pgp_user_id_binding_iter_free( - iter: Option<&mut UserIDBindingIter>) +pub extern "C" fn pgp_user_id_bundle_iter_free( + iter: Option<&mut UserIDBundleIter>) { ffi_free!(iter) } -/// Returns the next `UserIDBinding`. +/// Returns the next `UserIDBundle`. #[::sequoia_ffi_macros::extern_fn] #[no_mangle] -pub extern "C" fn pgp_user_id_binding_iter_next<'a>( - iter: *mut UserIDBindingIter<'a>) - -> Option<&'a UserIDBinding> +pub extern "C" fn pgp_user_id_bundle_iter_next<'a>( + iter: *mut UserIDBundleIter<'a>) + -> Option<&'a UserIDBundle> { let iter = ffi_param_ref_mut!(iter); iter.next() diff --git a/openpgp/examples/web-of-trust.rs b/openpgp/examples/web-of-trust.rs index 71ddbc4f..123d4a53 100644 --- a/openpgp/examples/web-of-trust.rs +++ b/openpgp/examples/web-of-trust.rs @@ -38,7 +38,7 @@ fn main() { match cert { Ok(cert) => { let keyid = cert.keyid(); - for uidb in cert.userids().bindings() { + for uidb in cert.userids().bundles() { for tps in uidb.certifications() { for issuer in tps.get_issuers() { println!("{}, {:?}, {}", diff --git a/openpgp/src/autocrypt.rs b/openpgp/src/autocrypt.rs index c99ee4e1..22dfa40d 100644 --- a/openpgp/src/autocrypt.rs +++ b/openpgp/src/autocrypt.rs @@ -109,7 +109,7 @@ impl AutocryptHeader { let mut acc = Vec::new(); // The primary key and the most recent selfsig. - let primary = cert.primary_key().binding(); + let primary = cert.primary_key().bundle(); acc.push(primary.key().clone().mark_role_primary().into()); primary.self_signatures().iter().take(1) .for_each(|s| acc.push(s.clone().into())); diff --git a/openpgp/src/cert/amalgamation.rs b/openpgp/src/cert/amalgamation.rs index cd9b2079..10ee8d5b 100644 --- a/openpgp/src/cert/amalgamation.rs +++ b/openpgp/src/cert/amalgamation.rs @@ -3,7 +3,7 @@ use std::time::SystemTime; use crate::{ Cert, - cert::components::ComponentBinding, + cert::components::ComponentBundle, Error, packet::Signature, Result, @@ -15,24 +15,24 @@ use crate::{ #[derive(Debug, Clone)] pub struct ComponentAmalgamation<'a, C>{ cert: &'a Cert, - binding: &'a ComponentBinding<C>, + bundle: &'a ComponentBundle<C>, } impl<'a, C> std::ops::Deref for ComponentAmalgamation<'a, C> { type Target = C; fn deref(&self) -> &Self::Target { - self.binding.component() + self.bundle.component() } } impl<'a, C> ComponentAmalgamation<'a, C> { /// Creates a new amalgamation. - pub(crate) fn new(cert: &'a Cert, binding: &'a ComponentBinding<C>) -> Self + pub(crate) fn new(cert: &'a Cert, bundle: &'a ComponentBundle<C>) -> Self { Self { cert, - binding, + bundle, } } @@ -41,9 +41,9 @@ impl<'a, C> ComponentAmalgamation<'a, C> { self.cert } - /// Returns this component's component binding. - pub fn binding(&self) -> &'a ComponentBinding<C> { - &self.binding + /// Returns this component's bundle. + pub fn bundle(&self) -> &'a ComponentBundle<C> { + &self.bundle } /// Returns the components's binding signature as of the reference @@ -56,7 +56,7 @@ impl<'a, C> ComponentAmalgamation<'a, C> { where T: Into<Option<time::SystemTime>> { let time = time.into().unwrap_or_else(SystemTime::now); - self.binding.binding_signature(policy, time) + self.bundle.binding_signature(policy, time) } /// Sets the reference time for the amalgamation. @@ -86,14 +86,14 @@ impl<'a, C> ComponentAmalgamation<'a, C> { impl<'a> ComponentAmalgamation<'a, crate::packet::UserID> { /// Returns a reference to the User ID. pub fn userid(&self) -> &crate::packet::UserID { - self.binding().userid() + self.bundle().userid() } } impl<'a> ComponentAmalgamation<'a, crate::packet::UserAttribute> { /// Returns a reference to the User Attribute. pub fn user_attribute(&self) -> &crate::packet::UserAttribute { - self.binding().user_attribute() + self.bundle().user_attribute() } } @@ -134,7 +134,7 @@ impl<'a, C> ValidComponentAmalgamation<'a, C> /// If there is more than one, than one is selected in a /// deterministic, but undefined manner. pub(super) fn primary(cert: &'a Cert, - iter: std::slice::Iter<'a, ComponentBinding<C>>, + iter: std::slice::Iter<'a, ComponentBundle<C>>, policy: &'a dyn Policy, t: SystemTime) -> Option<ValidComponentAmalgamation<'a, C>> { @@ -298,7 +298,7 @@ impl<'a, C> Amalgamation<'a> for ValidComponentAmalgamation<'a, C> { /// /// Note: this does not return whether the certificate is valid. fn revoked(&self) -> RevocationStatus<'a> { - self.binding._revoked(self.policy(), self.time, + self.bundle._revoked(self.policy(), self.time, false, Some(self.binding_signature)) } } diff --git a/openpgp/src/cert/bindings.rs b/openpgp/src/cert/bindings.rs index 83d319a2..40a326d8 100644 --- a/openpgp/src/cert/bindings.rs +++ b/openpgp/src/cert/bindings.rs @@ -173,7 +173,7 @@ impl UserID { /// let bob = bob.merge_packets(vec![certificate.into()])?; /// /// // Check that we have a certification on the userid. - /// assert_eq!(bob.userids().bindings().nth(0).unwrap() + /// assert_eq!(bob.userids().bundles().nth(0).unwrap() /// .certifications().len(), 1); /// # Ok(()) } pub fn certify<S, H, T>(&self, signer: &mut dyn Signer, cert: &Cert, @@ -315,7 +315,7 @@ impl UserAttribute { /// let bob = bob.merge_packets(vec![certificate.into()])?; /// /// // Check that we have a certification on the userid. - /// assert_eq!(bob.user_attributes().bindings().nth(0).unwrap() + /// assert_eq!(bob.user_attributes().bundles().nth(0).unwrap() /// .certifications().len(), /// 1); /// # Ok(()) } diff --git a/openpgp/src/cert/builder.rs b/openpgp/src/cert/builder.rs index f950b484..c09d90ae 100644 --- a/openpgp/src/cert/builder.rs +++ b/openpgp/src/cert/builder.rs @@ -668,7 +668,7 @@ mod tests { let now = cert.primary_key().creation_time() + 5 * s; // The subkeys may be created a tad later. let key = cert.primary_key().key(); - let sig = &cert.primary_key().binding().self_signatures()[0]; + let sig = &cert.primary_key().bundle().self_signatures()[0]; assert!(sig.key_alive(key, now).is_ok()); assert!(sig.key_alive(key, now + 590 * s).is_ok()); assert!(! sig.key_alive(key, now + 610 * s).is_ok()); diff --git a/openpgp/src/cert/component_iter.rs b/openpgp/src/cert/component_iter.rs index 9cd9cada..879c673c 100644 --- a/openpgp/src/cert/component_iter.rs +++ b/openpgp/src/cert/component_iter.rs @@ -6,8 +6,8 @@ use crate::{ cert::{ Cert, components::{ - ComponentBinding, - ComponentBindingIter, + ComponentBundle, + ComponentBundleIter, Amalgamation, ComponentAmalgamation, ValidComponentAmalgamation, @@ -25,7 +25,7 @@ use crate::{ /// By default, `ComponentIter` returns all components without context. pub struct ComponentIter<'a, C> { cert: &'a Cert, - iter: ComponentBindingIter<'a, C>, + iter: ComponentBundleIter<'a, C>, } impl<'a, C> fmt::Debug for ComponentIter<'a, C> { @@ -46,11 +46,11 @@ impl<'a, C> Iterator for ComponentIter<'a, C> { impl<'a, C> ComponentIter<'a, C> { /// Returns a new `ComponentIter` instance. pub(crate) fn new(cert: &'a Cert, - iter: std::slice::Iter<'a, ComponentBinding<C>>) -> Self + iter: std::slice::Iter<'a, ComponentBundle<C>>) -> Self where Self: 'a { ComponentIter { - cert, iter: ComponentBindingIter { iter: Some(iter), }, + cert, iter: ComponentBundleIter { iter: Some(iter), }, } } @@ -78,7 +78,7 @@ impl<'a, C> ComponentIter<'a, C> { /// A component binding is similar to a component amalgamation, /// but is not bound to a specific time. It contains the /// component and all relevant signatures. - pub fn bindings(self) -> ComponentBindingIter<'a, C> { + pub fn bundles(self) -> ComponentBundleIter<'a, C> { self.iter } } @@ -94,7 +94,7 @@ impl<'a, C> ComponentIter<'a, C> { pub struct ValidComponentIter<'a, C> { // This is an option to make it easier to create an empty ValidComponentIter. cert: &'a Cert, - iter: ComponentBindingIter<'a, C>, + iter: ComponentBundleIter<'a, C>, policy: &'a dyn Policy, // The time. @@ -125,7 +125,7 @@ impl<'a, C> Iterator for ValidComponentIter<'a, C> loop { let ca = ComponentAmalgamation::new(self.cert, self.iter.next()?); - t!("Considering component: {:?}", ca.binding()); + t!("Considering component: {:?}", ca.bundle() |