summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeal H. Walfield <neal@pep.foundation>2020-04-02 20:15:30 +0200
committerNeal H. Walfield <neal@pep.foundation>2020-04-02 20:27:31 +0200
commit9390bee56cd0b9d6307cb165858037049b079a36 (patch)
tree6a36f3039fb735d7841a8967503521ef8182d66b
parentce988033886608d9473b0a133dc10a188fc82432 (diff)
openpgp: Change Cert::subkeys to return KeyAmalgamations.
- Change `Cert::subkeys` to return `KeyAmalgamation`s instead of `KeyBundle`s.
-rw-r--r--openpgp/src/cert/builder.rs2
-rw-r--r--openpgp/src/cert/keyiter.rs13
-rw-r--r--openpgp/src/cert/mod.rs8
3 files changed, 11 insertions, 12 deletions
diff --git a/openpgp/src/cert/builder.rs b/openpgp/src/cert/builder.rs
index 0362b323..e727881e 100644
--- a/openpgp/src/cert/builder.rs
+++ b/openpgp/src/cert/builder.rs
@@ -530,7 +530,7 @@ mod tests {
.set_primary_key_flags(KeyFlags::default())
.add_subkey(KeyFlags::default().set_certification(true), None, None)
.generate().unwrap();
- let sig_pkts = cert1.subkeys().next().unwrap().self_signatures[0].hashed_area();
+ let sig_pkts = cert1.subkeys().next().unwrap().bundle().self_signatures[0].hashed_area();
match sig_pkts.lookup(SubpacketTag::KeyFlags).unwrap().value() {
SubpacketValue::KeyFlags(ref ks) => assert!(ks.for_certification()),
diff --git a/openpgp/src/cert/keyiter.rs b/openpgp/src/cert/keyiter.rs
index 0cfc3e23..5f44fb99 100644
--- a/openpgp/src/cert/keyiter.rs
+++ b/openpgp/src/cert/keyiter.rs
@@ -2,6 +2,7 @@ use std::fmt;
use std::convert::TryInto;
use std::time::SystemTime;
use std::borrow::Borrow;
+use std::slice;
use crate::{
KeyHandle,
@@ -35,9 +36,8 @@ pub struct KeyIter<'a, P, R>
// This is an option to make it easier to create an empty KeyIter.
cert: Option<&'a Cert>,
primary: bool,
- subkey_iter: UnfilteredKeyBundleIter<'a,
- key::PublicParts,
- key::SubordinateRole>,
+ subkey_iter: slice::Iter<'a, KeyBundle<key::PublicParts,
+ key::SubordinateRole>>,
// If not None, filters by whether a key has a secret.
secret: Option<bool>,
@@ -189,7 +189,7 @@ impl<'a, P, R> KeyIter<'a, P, R>
KeyIter {
cert: Some(cert),
primary: false,
- subkey_iter: cert.subkeys(),
+ subkey_iter: cert.subkeys.iter(),
// The filters.
secret: None,
@@ -451,9 +451,8 @@ pub struct ValidKeyIter<'a, P, R>
// This is an option to make it easier to create an empty ValidKeyIter.
cert: Option<&'a Cert>,
primary: bool,
- subkey_iter: UnfilteredKeyBundleIter<'a,
- key::PublicParts,
- key::SubordinateRole>,
+ subkey_iter: slice::Iter<'a, KeyBundle<key::PublicParts,
+ key::SubordinateRole>>,
// The policy.
policy: &'a dyn Policy,
diff --git a/openpgp/src/cert/mod.rs b/openpgp/src/cert/mod.rs
index f4433a6d..41710f32 100644
--- a/openpgp/src/cert/mod.rs
+++ b/openpgp/src/cert/mod.rs
@@ -661,10 +661,10 @@ impl Cert {
}
/// Returns an iterator over the Cert's subkeys.
- pub(crate) fn subkeys(&self) -> UnfilteredKeyBundleIter<key::PublicParts,
- key::SubordinateRole>
+ pub(crate) fn subkeys(&self) -> ComponentIter<Key<key::PublicParts,
+ key::SubordinateRole>>
{
- UnfilteredKeyBundleIter { iter: Some(self.subkeys.iter()) }
+ ComponentIter::new(self, self.subkeys.iter())
}
/// Returns an iterator over the Cert's unknown components.
@@ -2526,7 +2526,7 @@ mod test {
where T: Into<Option<time::SystemTime>>
{
!destructures_to!(RevocationStatus::NotAsFarAsWeKnow
- = cert.subkeys().nth(0).unwrap().revoked(p, t))
+ = cert.subkeys().nth(0).unwrap().bundle().revoked(p, t))
}
let tests : [(&str, Box<dyn Fn(&dyn Policy, &Cert, _) -> bool>); 2] = [