diff options
-rw-r--r-- | examples/guide-exploring-openpgp.rs | 2 | ||||
-rw-r--r-- | guide/src/chapter_02.md | 8 | ||||
-rw-r--r-- | guide/src/chapter_03.md | 4 | ||||
-rw-r--r-- | openpgp/examples/generate-encrypt-decrypt.rs | 2 | ||||
-rw-r--r-- | openpgp/src/autocrypt.rs | 2 | ||||
-rw-r--r-- | openpgp/src/crypto/hash.rs | 2 | ||||
-rw-r--r-- | openpgp/src/packet/pkesk.rs | 10 | ||||
-rw-r--r-- | openpgp/src/packet/signature/mod.rs | 4 | ||||
-rw-r--r-- | openpgp/src/parse/stream.rs | 4 | ||||
-rw-r--r-- | openpgp/src/serialize/stream.rs | 2 | ||||
-rw-r--r-- | openpgp/src/serialize/tpk.rs | 8 | ||||
-rw-r--r-- | openpgp/src/tpk/bindings.rs | 2 | ||||
-rw-r--r-- | openpgp/src/tpk/builder.rs | 8 | ||||
-rw-r--r-- | openpgp/src/tpk/keyiter.rs | 8 | ||||
-rw-r--r-- | openpgp/src/tpk/mod.rs | 80 | ||||
-rw-r--r-- | openpgp/src/tpk/parser/grammar.lalrpop | 6 | ||||
-rw-r--r-- | openpgp/src/tpk/parser/lexer.rs | 4 | ||||
-rw-r--r-- | sqv/src/sqv.rs | 2 | ||||
-rw-r--r-- | tool/src/commands/decrypt.rs | 2 | ||||
-rw-r--r-- | tool/src/commands/inspect.rs | 4 |
20 files changed, 82 insertions, 82 deletions
diff --git a/examples/guide-exploring-openpgp.rs b/examples/guide-exploring-openpgp.rs index c8e51e9b..c5aba0dc 100644 --- a/examples/guide-exploring-openpgp.rs +++ b/examples/guide-exploring-openpgp.rs @@ -62,7 +62,7 @@ fn main() { // List subkeys. for (i, s) in tpk.subkeys().enumerate() { println!("{}: Fingerprint: {}, {} self-signature(s), {} certification(s)", - i, s.subkey().fingerprint(), + i, s.key().fingerprint(), s.selfsigs().len(), s.certifications().len()); } diff --git a/guide/src/chapter_02.md b/guide/src/chapter_02.md index 7794436e..b6463033 100644 --- a/guide/src/chapter_02.md +++ b/guide/src/chapter_02.md @@ -119,7 +119,7 @@ fn main() { # { # // The encryption key is the first and only subkey. # let key = self.secret.subkeys().nth(0) -# .map(|binding| binding.subkey().clone()) +# .map(|binding| binding.key().clone()) # .unwrap(); # # // The secret key is not encrypted. @@ -253,7 +253,7 @@ fn generate() -> openpgp::Result<openpgp::TPK> { # { # // The encryption key is the first and only subkey. # let key = self.secret.subkeys().nth(0) -# .map(|binding| binding.subkey().clone()) +# .map(|binding| binding.key().clone()) # .unwrap(); # # // The secret key is not encrypted. @@ -387,7 +387,7 @@ fn encrypt(sink: &mut Write, plaintext: &str, recipient: &openpgp::TPK) # { # // The encryption key is the first and only subkey. # let key = self.secret.subkeys().nth(0) -# .map(|binding| binding.subkey().clone()) +# .map(|binding| binding.key().clone()) # .unwrap(); # # // The secret key is not encrypted. @@ -535,7 +535,7 @@ impl<'a> DecryptionHelper for Helper<'a> { { // The encryption key is the first and only subkey. let key = self.secret.subkeys().nth(0) - .map(|binding| binding.subkey().clone()) + .map(|binding| binding.key().clone()) .unwrap(); // The secret key is not encrypted. diff --git a/guide/src/chapter_03.md b/guide/src/chapter_03.md index 80d5cc1c..0d8e9996 100644 --- a/guide/src/chapter_03.md +++ b/guide/src/chapter_03.md @@ -53,9 +53,9 @@ fn main() { // Iterate over subkeys. assert_eq!(tpk.subkeys().count(), 2); - assert_eq!(tpk.subkeys().nth(0).unwrap().subkey().fingerprint().to_string(), + assert_eq!(tpk.subkeys().nth(0).unwrap().key().fingerprint().to_string(), "67A4 8753 A380 A6B3 B7DF 7DC5 E6C6 897A 4CEF 8924"); - assert_eq!(tpk.subkeys().nth(1).unwrap().subkey().fingerprint().to_string(), + assert_eq!(tpk.subkeys().nth(1).unwrap().key().fingerprint().to_string(), "185C DAA1 2723 0423 19E4 7F67 108F 2CAF 9034 356D"); } ``` diff --git a/openpgp/examples/generate-encrypt-decrypt.rs b/openpgp/examples/generate-encrypt-decrypt.rs index b48c3d29..c0360f33 100644 --- a/openpgp/examples/generate-encrypt-decrypt.rs +++ b/openpgp/examples/generate-encrypt-decrypt.rs @@ -110,7 +110,7 @@ impl<'a> DecryptionHelper for Helper<'a> { { // The encryption key is the first and only subkey. let key = self.secret.subkeys().nth(0) - .map(|binding| binding.subkey().clone()) + .map(|binding| binding.key().clone()) .unwrap(); // The secret key is not encrypted. diff --git a/openpgp/src/autocrypt.rs b/openpgp/src/autocrypt.rs index 86c1ccfc..de0053e2 100644 --- a/openpgp/src/autocrypt.rs +++ b/openpgp/src/autocrypt.rs @@ -120,7 +120,7 @@ impl AutocryptHeader { continue; } - acc.push(skb.subkey().clone().into_packet(Tag::PublicSubkey)?); + acc.push(skb.key().clone().into_packet(Tag::PublicSubkey)?); skb.selfsigs().iter().take(1) .for_each(|s| acc.push(s.clone().into())); } diff --git a/openpgp/src/crypto/hash.rs b/openpgp/src/crypto/hash.rs index 78b13d8e..0828b834 100644 --- a/openpgp/src/crypto/hash.rs +++ b/openpgp/src/crypto/hash.rs @@ -453,7 +453,7 @@ mod test { let h = Signature::subkey_binding_hash( selfsig, tpk.primary(), - binding.subkey()).unwrap(); + binding.key()).unwrap(); if &h[..2] != selfsig.hash_prefix() { eprintln!("{:?}: {:?}", i, binding); eprintln!(" Hash: {:?}", h); diff --git a/openpgp/src/packet/pkesk.rs b/openpgp/src/packet/pkesk.rs index c92fafe1..cb05425a 100644 --- a/openpgp/src/packet/pkesk.rs +++ b/openpgp/src/packet/pkesk.rs @@ -224,7 +224,7 @@ mod tests { crate::tests::message("encrypted-to-testy.gpg")).unwrap(); let mut keypair = tpk.subkeys().next().unwrap() - .subkey().clone().into_keypair().unwrap(); + .key().clone().into_keypair().unwrap(); let pkg = pile.descendants().skip(0).next().clone(); @@ -245,7 +245,7 @@ mod tests { crate::tests::message("encrypted-to-testy-new.pgp")).unwrap(); let mut keypair = tpk.subkeys().next().unwrap() - .subkey().clone().into_keypair().unwrap(); + .key().clone().into_keypair().unwrap(); let pkg = pile.descendants().skip(0).next().clone(); @@ -266,7 +266,7 @@ mod tests { crate::tests::message("encrypted-to-testy-nistp256.pgp")).unwrap(); let mut keypair = tpk.subkeys().next().unwrap() - .subkey().clone().into_keypair().unwrap(); + .key().clone().into_keypair().unwrap(); let pkg = pile.descendants().skip(0).next().clone(); @@ -287,7 +287,7 @@ mod tests { crate::tests::message("encrypted-to-testy-nistp384.pgp")).unwrap(); let mut keypair = tpk.subkeys().next().unwrap() - .subkey().clone().into_keypair().unwrap(); + .key().clone().into_keypair().unwrap(); let pkg = pile.descendants().skip(0).next().clone(); @@ -308,7 +308,7 @@ mod tests { crate::tests::message("encrypted-to-testy-nistp521.pgp")).unwrap(); let mut keypair = tpk.subkeys().next().unwrap() - .subkey().clone().into_keypair().unwrap(); + .key().clone().into_keypair().unwrap(); let pkg = pile.descendants().skip(0).next().clone(); diff --git a/openpgp/src/packet/signature/mod.rs b/openpgp/src/packet/signature/mod.rs index acd2a4d0..4bb52af8 100644 --- a/openpgp/src/packet/signature/mod.rs +++ b/openpgp/src/packet/signature/mod.rs @@ -1098,9 +1098,9 @@ mod test { } for sk in tpk.subkeys() { - let result = sig.verify(sk.subkey()).unwrap_or(false); + let result = sig.verify(sk.key()).unwrap_or(false); eprintln!(" Subkey {:?}: {:?}", - sk.subkey().fingerprint(), result); + sk.key().fingerprint(), result); if result { good += 1; } diff --git a/openpgp/src/parse/stream.rs b/openpgp/src/parse/stream.rs index f94d9f5e..b4cc89ff 100644 --- a/openpgp/src/parse/stream.rs +++ b/openpgp/src/parse/stream.rs @@ -516,7 +516,7 @@ impl<'a, H: VerificationHelper> Verifier<'a, H> { } for (j, skb) in tpk.subkeys().enumerate() { - let key = skb.subkey(); + let key = skb.key(); if can_sign(key, skb.binding_signature()) { v.keys.insert(key.keyid(), (i, j + 1)); @@ -1301,7 +1301,7 @@ impl<'a, H: VerificationHelper + DecryptionHelper> Decryptor<'a, H> { } for (j, skb) in tpk.subkeys().enumerate() { - let key = skb.subkey(); + let key = skb.key(); if can_sign(key, skb.binding_signature()) { v.keys.insert(key.keyid(), (i, j + 1)); } diff --git a/openpgp/src/serialize/stream.rs b/openpgp/src/serialize/stream.rs index ad3a152c..b7b90a44 100644 --- a/openpgp/src/serialize/stream.rs +++ b/openpgp/src/serialize/stream.rs @@ -974,7 +974,7 @@ impl<'a> Encryptor<'a> { // Gather all encryption-capable subkeys. let subkeys = tpk.subkeys().filter_map(|skb| { - let key = skb.subkey(); + let key = skb.key(); if can_encrypt(key, skb.binding_signature()) { Some(key) } else { diff --git a/openpgp/src/serialize/tpk.rs b/openpgp/src/serialize/tpk.rs index 73daaf78..988512c4 100644 --- a/openpgp/src/serialize/tpk.rs +++ b/openpgp/src/serialize/tpk.rs @@ -108,7 +108,7 @@ impl TPK { continue; } - PacketRef::PublicSubkey(k.subkey()).serialize(o)?; + PacketRef::PublicSubkey(k.key()).serialize(o)?; for s in k.self_revocations() { serialize_sig(o, s)?; } @@ -208,7 +208,7 @@ impl SerializeInto for TPK { } for k in self.subkeys() { - l += PacketRef::PublicSubkey(k.subkey()).serialized_len(); + l += PacketRef::PublicSubkey(k.key()).serialized_len(); for s in k.self_revocations() { l += PacketRef::Signature(s).serialized_len(); @@ -445,7 +445,7 @@ impl<'a> TSK<'a> { continue; } - serialize_key(o, k.subkey(), Tag::PublicSubkey, Tag::SecretSubkey)?; + serialize_key(o, k.key(), Tag::PublicSubkey, Tag::SecretSubkey)?; for s in k.self_revocations() { serialize_sig(o, s)?; } @@ -577,7 +577,7 @@ impl<'a> SerializeInto for TSK<'a> { } for k in self.tpk.subkeys() { - l += serialized_len_key(k.subkey(), + l += serialized_len_key(k.key(), Tag::PublicSubkey, Tag::SecretSubkey); for s in k.self_revocations() { diff --git a/openpgp/src/tpk/bindings.rs b/openpgp/src/tpk/bindings.rs index 81cd3b7c..7ad7f4c9 100644 --- a/openpgp/src/tpk/bindings.rs +++ b/openpgp/src/tpk/bindings.rs @@ -91,7 +91,7 @@ impl Key { /// /// // Generate the revocation for the first and only Subkey. /// let revocation = - /// tpk.subkeys().nth(0).unwrap().subkey() + /// tpk.subkeys().nth(0).unwrap().key() /// .revoke(&mut keypair, &tpk, /// ReasonForRevocation::KeyRetired, /// b"Smells funny.", None, None)?; diff --git a/openpgp/src/tpk/builder.rs b/openpgp/src/tpk/builder.rs index 3191d1e3..e735975a 100644 --- a/openpgp/src/tpk/builder.rs +++ b/openpgp/src/tpk/builder.rs @@ -461,7 +461,7 @@ mod tests { .generate().unwrap(); assert_eq!(tpk2.primary().pk_algo(), PublicKeyAlgorithm::RSAEncryptSign); - assert_eq!(tpk2.subkeys().next().unwrap().subkey().pk_algo(), + assert_eq!(tpk2.subkeys().next().unwrap().key().pk_algo(), PublicKeyAlgorithm::RSAEncryptSign); } @@ -488,7 +488,7 @@ mod tests { .generate().unwrap(); assert_eq!(tpk1.primary().pk_algo(), PublicKeyAlgorithm::RSAEncryptSign); - assert_eq!(tpk1.subkeys().next().unwrap().subkey().pk_algo(), + assert_eq!(tpk1.subkeys().next().unwrap().key().pk_algo(), PublicKeyAlgorithm::RSAEncryptSign); assert_eq!(tpk1.userids().count(), 1); } @@ -500,12 +500,12 @@ mod tests { .generate().unwrap(); assert_eq!(tpk1.primary().pk_algo(), PublicKeyAlgorithm::EdDSA); - assert_eq!(tpk1.subkeys().next().unwrap().subkey().pk_algo(), + assert_eq!(tpk1.subkeys().next().unwrap().key().pk_algo(), PublicKeyAlgorithm::ECDH); assert_match!( crate::crypto::mpis::PublicKey::ECDH { curve: crate::constants::Curve::Cv25519, .. - } = tpk1.subkeys().next().unwrap().subkey().mpis()); + } = tpk1.subkeys().next().unwrap().key().mpis()); assert_eq!(tpk1.userids().count(), 1); } diff --git a/openpgp/src/tpk/keyiter.rs b/openpgp/src/tpk/keyiter.rs index 2e78555b..0083f4c3 100644 --- a/openpgp/src/tpk/keyiter.rs +++ b/openpgp/src/tpk/keyiter.rs @@ -7,7 +7,7 @@ use crate::{ packet::KeyFlags, packet::Signature, TPK, - tpk::SubkeyBindingIter, + tpk::KeyBindingIter, }; /// An iterator over all `Key`s (both the primary key and any subkeys) @@ -26,7 +26,7 @@ pub struct KeyIter<'a> { // This is an option to make it easier to create an empty KeyIter. tpk: Option<&'a TPK>, primary: bool, - subkey_iter: SubkeyBindingIter<'a>, + subkey_iter: KeyBindingIter<'a>, // If not None, only returns keys with the specified flags. flags: Option<KeyFlags>, @@ -89,7 +89,7 @@ impl<'a> Iterator for KeyIter<'a> { self.subkey_iter.next() .map(|sk_binding| (sk_binding.binding_signature(), sk_binding.revoked(None), - sk_binding.subkey(),))? + sk_binding.key(),))? }; t!("Considering key: {:?}", key); @@ -206,7 +206,7 @@ impl<'a> KeyIter<'a> { KeyIter { tpk: None, primary: false, - subkey_iter: SubkeyBindingIter { iter: None }, + subkey_iter: KeyBindingIter { iter: None }, // The filters. flags: None, diff --git a/openpgp/src/tpk/mod.rs b/openpgp/src/tpk/mod.rs index 6565fa49..b5bf6b59 100644 --- a/openpgp/src/tpk/mod.rs +++ b/openpgp/src/tpk/mod.rs @@ -110,7 +110,7 @@ fn active_revocation(sigs: &[Signature], revs: &[Signature], t: time::Tm) } /// A subkey and any associated signatures. -pub type SubkeyBinding = ComponentBinding<Key>; +pub type KeyBinding = ComponentBinding<Key>; /// A User ID and any associated signatures. pub type UserIDBinding = ComponentBinding<UserID>; @@ -229,12 +229,12 @@ impl<C> ComponentBinding<C> { impl ComponentBinding<Key> { /// Returns a reference to the key. - pub fn subkey(&self) -> &Key { + pub fn key(&self) -> &Key { self.component() } /// Returns a mut reference to the key. - fn subkey_mut(&mut self) -> &mut Key { + fn key_mut(&mut self) -> &mut Key { self.component_mut() } } @@ -414,7 +414,7 @@ impl<'a, I: Iterator<Item=Packet>> TPKParser<'a, I> { /// return true; /// } /// for binding in tpk.subkeys() { - /// if binding.subkey().keyid() == some_keyid { + /// if binding.key().keyid() == some_keyid { /// return true; /// } /// } @@ -717,13 +717,13 @@ impl<'a> ExactSizeIterator for UserAttributeBindingIter<'a> { fn len(&self) -> usize { self.iter.len() } } -/// An iterator over `SubkeyBinding`s. -pub struct SubkeyBindingIter<'a> { - iter: Option<slice::Iter<'a, SubkeyBinding>>, +/// An iterator over `KeyBinding`s. +pub struct KeyBindingIter<'a> { + iter: Option<slice::Iter<'a, KeyBinding>>, } -impl<'a> Iterator for SubkeyBindingIter<'a> { - type Item = &'a SubkeyBinding; +impl<'a> Iterator for KeyBindingIter<'a> { + type Item = &'a KeyBinding; fn next(&mut self) -> Option<Self::Item> { match self.iter { @@ -733,7 +733,7 @@ impl<'a> Iterator for SubkeyBindingIter<'a> { } } -impl<'a> ExactSizeIterator for SubkeyBindingIter<'a> { +impl<'a> ExactSizeIterator for KeyBindingIter<'a> { fn len(&self) -> usize { match self.iter { Some(ref iter) => iter.len(), @@ -831,7 +831,7 @@ pub struct TPK { userids: Vec<UserIDBinding>, user_attributes: Vec<UserAttributeBinding>, - subkeys: Vec<SubkeyBinding>, + subkeys: Vec<KeyBinding>, // Unknown components, e.g., some UserAttribute++ packet from the // future. @@ -1186,9 +1186,9 @@ impl TPK { /// Returns an iterator over the TPK's valid subkeys. /// - /// A valid `SubkeyBinding` has at least one good self-signature. - pub fn subkeys(&self) -> SubkeyBindingIter { - SubkeyBindingIter { iter: Some(self.subkeys.iter()) } + /// A valid `KeyBinding` has at least one good self-signature. + pub fn subkeys(&self) -> KeyBindingIter { + KeyBindingIter { iter: Some(self.subkeys.iter()) } } /// Returns an iterator over the TPK's valid unknown components. @@ -1213,7 +1213,7 @@ impl TPK { /// subkeys, along with the corresponding signatures. /// /// Note: since a primary key is different from a binding, the - /// iterator is over `Key`s and not `SubkeyBindings`. + /// iterator is over `Key`s and not `KeyBindings`. /// Furthermore, the primary key has no binding signature. Here, /// the signature carrying the primary key's key flags is /// returned. There are corner cases where no such signature @@ -1356,12 +1356,12 @@ impl TPK { } for binding in self.subkeys.iter_mut() { - check!(format!("subkey {}", binding.subkey().keyid()), + check!(format!("subkey {}", binding.key().keyid()), binding, selfsigs, verify_subkey_binding, - binding.subkey()); - check!(format!("subkey {}", binding.subkey().keyid()), + binding.key()); + check!(format!("subkey {}", binding.key().keyid()), binding, self_revocations, verify_subkey_revocation, - binding.subkey()); + binding.key()); } // See if the signatures that didn't validate are just out of @@ -1425,12 +1425,12 @@ impl TPK { } for binding in self.subkeys.iter_mut() { - check_one!(format!("subkey {}", binding.subkey().keyid()), + check_one!(format!("subkey {}", binding.key().keyid()), binding.selfsigs, sig, - verify_subkey_binding, binding.subkey()); - check_one!(format!("subkey {}", binding.subkey().keyid()), + verify_subkey_binding, binding.key()); + check_one!(format!("subkey {}", binding.key().keyid()), binding.self_revocations, sig, - verify_subkey_revocation, binding.subkey()); + verify_subkey_revocation, binding.key()); } // Keep them for later. @@ -1789,21 +1789,21 @@ impl TPK { // user ids, we can't do the final sort here, because we rely // on the self-signatures. self.subkeys.sort_by( - |a, b| Key::public_cmp(a.subkey(), b.subkey())); + |a, b| Key::public_cmp(a.key(), b.key())); // And, dedup them. // // If the public keys match, but only one of them has a secret // key, then merge the key and keep the secret key. self.subkeys.dedup_by(|a, b| { - if Key::public_cmp(a.subkey(), b.subkey()) == Ordering::Equal - && (a.subkey().secret() == b.subkey().secret() - || a.subkey().secret().is_none() - || b.subkey().secret().is_none()) + if Key::public_cmp(a.key(), b.key()) == Ordering::Equal + && (a.key().secret() == b.key().secret() + || a.key().secret().is_none() + || b.key().secret().is_none()) { // Recall: if a and b are equal, a will be dropped. - if b.subkey().secret().is_none() && a.subkey().secret().is_some() { - b.subkey_mut().set_secret(a.subkey_mut().set_secret(None)); + if b.key().secret().is_none() && a.key().secret().is_some() { + b.key_mut().set_secret(a.key_mut().set_secret(None)); } b.selfsigs.append(&mut a.selfsigs); @@ -1881,13 +1881,13 @@ impl TPK { } // Creation time (more recent first). - let cmp = b.subkey().creation_time().cmp(&a.subkey().creation_time()); + let cmp = b.key().creation_time().cmp(&a.key().creation_time()); if cmp != Ordering::Equal { return cmp; } // Fallback to the lexicographical comparison. - a.subkey().mpis().cmp(&b.subkey().mpis()) + a.key().mpis().cmp(&b.key().mpis()) }); // In case we have subkeys bound to the primary, it must be @@ -2069,7 +2069,7 @@ impl TPK { return true; } self.subkeys().any(|sk| { - sk.binding_signature().is_some() && sk.subkey().secret().is_some() + sk.binding_signature().is_some() && sk.key().secret().is_some() }) } } @@ -2145,7 +2145,7 @@ mod test { assert_eq!(tpk.user_attributes.len(), 0); assert_eq!(tpk.subkeys.len(), 1, "number of subkeys"); - assert_eq!(tpk.subkeys[0].subkey().creation_time().to_pgp().unwrap(), + assert_eq!(tpk.subkeys[0].key().creation_time().to_pgp().unwrap(), 1511355130); assert_eq!(tpk.subkeys[0].selfsigs[0].hash_prefix(), &[ 0xb7, 0xb9 ]); @@ -2411,7 +2411,7 @@ mod test { ]); let mut subkeys = tpk.subkeys() - .map(|sk| Some(sk.subkey().keyid())) + .map(|sk| Some(sk.key().keyid())) .collect::<Vec<Option<KeyID>>>(); subkeys.sort(); assert_eq!(subkeys, @@ -2442,7 +2442,7 @@ mod test { assert_eq!(tpk.user_attributes.len(), 1); let mut subkeys = tpk.subkeys() - .map(|sk| Some(sk.subkey().keyid())) + .map(|sk| Some(sk.key().keyid())) .collect::<Vec<Option<KeyID>>>(); subkeys.sort(); assert_eq!(subkeys, @@ -2926,7 +2926,7 @@ mod test { assert!(tsk.is_tsk()); let subkey_count = tsk.subkeys().len(); assert!(subkey_count > 0); - assert!(tsk.subkeys().all(|k| k.subkey().secret().is_some())); + assert!(tsk.subkeys().all(|k| k.key().secret().is_some())); // This will write out the tsk as a tpk, i.e., without any // private bits. @@ -2937,19 +2937,19 @@ mod test { let tpk = TPK::from_bytes(&tpk_bytes[ |