summaryrefslogtreecommitdiffstats
path: root/openpgp/src/cert/amalgamation
diff options
context:
space:
mode:
authorJustus Winter <justus@sequoia-pgp.org>2020-08-05 11:53:22 +0200
committerJustus Winter <justus@sequoia-pgp.org>2020-08-05 13:05:09 +0200
commit7d4090c4c862e6f38f5a17a9ad77484bf219909d (patch)
treef70a89f90b06616557b151bea15b63d7e2e81a7d /openpgp/src/cert/amalgamation
parent78e9b6626ba96fa918f53e524720d595a6bb9340 (diff)
openpgp: Don't implement Default for the Bitflags types.
- See #525.
Diffstat (limited to 'openpgp/src/cert/amalgamation')
-rw-r--r--openpgp/src/cert/amalgamation/key.rs12
-rw-r--r--openpgp/src/cert/amalgamation/key/iter.rs22
2 files changed, 17 insertions, 17 deletions
diff --git a/openpgp/src/cert/amalgamation/key.rs b/openpgp/src/cert/amalgamation/key.rs
index 78f34f5d..beea857d 100644
--- a/openpgp/src/cert/amalgamation/key.rs
+++ b/openpgp/src/cert/amalgamation/key.rs
@@ -1548,7 +1548,7 @@ impl<'a, P, R, R2> ValidKeyAmalgamation<'a, P, R, R2>
pub fn has_any_key_flag<F>(&self, flags: F) -> bool
where F: Borrow<KeyFlags>
{
- let our_flags = self.key_flags().unwrap_or_default();
+ let our_flags = self.key_flags().unwrap_or_else(KeyFlags::empty);
!(&our_flags & flags.borrow()).is_empty()
}
@@ -1599,7 +1599,7 @@ impl<'a, P, R, R2> ValidKeyAmalgamation<'a, P, R, R2>
/// [Section 12.1 of RFC 4880]: https://tools.ietf.org/html/rfc4880#section-5.2.3.21
/// [`ValidKeyAmalgamation::key_flags`]: #method.key_flags
pub fn for_certification(&self) -> bool {
- self.has_any_key_flag(KeyFlags::default().set_certification())
+ self.has_any_key_flag(KeyFlags::empty().set_certification())
}
/// Returns whether the key is signing capable.
@@ -1632,7 +1632,7 @@ impl<'a, P, R, R2> ValidKeyAmalgamation<'a, P, R, R2>
///
/// [`ValidKeyAmalgamation::key_flags`]: #method.key_flags
pub fn for_signing(&self) -> bool {
- self.has_any_key_flag(KeyFlags::default().set_signing())
+ self.has_any_key_flag(KeyFlags::empty().set_signing())
}
/// Returns whether the key is authentication capable.
@@ -1666,7 +1666,7 @@ impl<'a, P, R, R2> ValidKeyAmalgamation<'a, P, R, R2>
/// [`ValidKeyAmalgamation::key_flags`]: #method.key_flags
pub fn for_authentication(&self) -> bool
{
- self.has_any_key_flag(KeyFlags::default().set_authentication())
+ self.has_any_key_flag(KeyFlags::empty().set_authentication())
}
/// Returns whether the key is storage-encryption capable.
@@ -1713,7 +1713,7 @@ impl<'a, P, R, R2> ValidKeyAmalgamation<'a, P, R, R2>
/// [`ValidKeyAmalgamation::key_flags`]: #method.key_flags
pub fn for_storage_encryption(&self) -> bool
{
- self.has_any_key_flag(KeyFlags::default().set_storage_encryption())
+ self.has_any_key_flag(KeyFlags::empty().set_storage_encryption())
}
/// Returns whether the key is transport-encryption capable.
@@ -1760,7 +1760,7 @@ impl<'a, P, R, R2> ValidKeyAmalgamation<'a, P, R, R2>
/// [`ValidKeyAmalgamation::key_flags`]: #method.key_flags
pub fn for_transport_encryption(&self) -> bool
{
- self.has_any_key_flag(KeyFlags::default().set_transport_encryption())
+ self.has_any_key_flag(KeyFlags::empty().set_transport_encryption())
}
/// Returns how long the key is live.
diff --git a/openpgp/src/cert/amalgamation/key/iter.rs b/openpgp/src/cert/amalgamation/key/iter.rs
index f1d66c0c..d14fdc0b 100644
--- a/openpgp/src/cert/amalgamation/key/iter.rs
+++ b/openpgp/src/cert/amalgamation/key/iter.rs
@@ -947,7 +947,7 @@ impl<'a, P, R> ValidKeyAmalgamationIter<'a, P, R>
/// [Section 12.1 of RFC 4880]: https://tools.ietf.org/html/rfc4880#section-5.2.3.21
/// [`ValidKeyAmalgamation::key_flags`]: struct.ValidKeyAmalgamation.html#method.key_flags
pub fn for_certification(self) -> Self {
- self.key_flags(KeyFlags::default().set_certification())
+ self.key_flags(KeyFlags::empty().set_certification())
}
/// Returns signing-capable keys.
@@ -990,7 +990,7 @@ impl<'a, P, R> ValidKeyAmalgamationIter<'a, P, R>
///
/// [`ValidKeyAmalgamation::for_signing`]: struct.ValidKeyAmalgamation.html#method.for_signing
pub fn for_signing(self) -> Self {
- self.key_flags(KeyFlags::default().set_signing())
+ self.key_flags(KeyFlags::empty().set_signing())
}
/// Returns authentication-capable keys.
@@ -1033,7 +1033,7 @@ impl<'a, P, R> ValidKeyAmalgamationIter<'a, P, R>
///
/// [`ValidKeyAmalgamation::for_authentication`]: struct.ValidKeyAmalgamation.html#method.for_authentication
pub fn for_authentication(self) -> Self {
- self.key_flags(KeyFlags::default().set_authentication())
+ self.key_flags(KeyFlags::empty().set_authentication())
}
/// Returns encryption-capable keys for data at rest.
@@ -1076,7 +1076,7 @@ impl<'a, P, R> ValidKeyAmalgamationIter<'a, P, R>
///
/// [`ValidKeyAmalgamation::for_storage_encryption`]: struct.ValidKeyAmalgamation.html#method.for_storage_encryption
pub fn for_storage_encryption(self) -> Self {
- self.key_flags(KeyFlags::default().set_storage_encryption())
+ self.key_flags(KeyFlags::empty().set_storage_encryption())
}
/// Returns encryption-capable keys for data in transit.
@@ -1119,7 +1119,7 @@ impl<'a, P, R> ValidKeyAmalgamationIter<'a, P, R>
///
/// [`ValidKeyAmalgamation::for_transport_encryption`]: struct.ValidKeyAmalgamation.html#method.for_transport_encryption
pub fn for_transport_encryption(self) -> Self {
- self.key_flags(KeyFlags::default().set_transport_encryption())
+ self.key_flags(KeyFlags::empty().set_transport_encryption())
}
/// Returns keys that are alive.
@@ -1533,7 +1533,7 @@ mod test {
let p = &P::new();
let (cert, _) = CertBuilder::new()
.generate().unwrap();
- let flags = KeyFlags::default().set_transport_encryption();
+ let flags = KeyFlags::empty().set_transport_encryption();
assert_eq!(cert.keys().with_policy(p, None).key_flags(flags).count(), 0);
}
@@ -1544,7 +1544,7 @@ mod test {
let (cert, _) = CertBuilder::new()
.add_transport_encryption_subkey()
.generate().unwrap();
- let flags = KeyFlags::default().set_transport_encryption();
+ let flags = KeyFlags::empty().set_transport_encryption();
assert_eq!(cert.keys().with_policy(p, None).key_flags(flags).count(), 1);
}
@@ -1556,7 +1556,7 @@ mod test {
.add_transport_encryption_subkey()
.add_signing_subkey()
.generate().unwrap();
- let flags = KeyFlags::default().set_transport_encryption();
+ let flags = KeyFlags::empty().set_transport_encryption();
assert_eq!(cert.keys().with_policy(p, None).key_flags(flags).count(), 1);
}
@@ -1567,7 +1567,7 @@ mod test {
let (cert, _) = CertBuilder::new()
.add_transport_encryption_subkey()
.generate().unwrap();
- let flags = KeyFlags::default().set_transport_encryption();
+ let flags = KeyFlags::empty().set_transport_encryption();
let now = SystemTime::now()
- std::time::Duration::new(52 * 7 * 24 * 60 * 60, 0);
@@ -1581,7 +1581,7 @@ mod test {
let (cert, _) = CertBuilder::new()
.add_certification_subkey()
.generate().unwrap();
- let flags = KeyFlags::default().set_certification();
+ let flags = KeyFlags::empty().set_certification();
assert_eq!(cert.keys().with_policy(p, None).key_flags(flags).count(),
2);
@@ -1611,7 +1611,7 @@ mod test {
.for_signing().count(),
1);
assert_eq!(cert.keys().with_policy(p, None).alive().revoked(false)
- .key_flags(KeyFlags::default().set_authentication())
+ .key_flags(KeyFlags::empty().set_authentication())
.count(),
1);
}