summaryrefslogtreecommitdiffstats
path: root/openpgp/src/cert
diff options
context:
space:
mode:
Diffstat (limited to 'openpgp/src/cert')
-rw-r--r--openpgp/src/cert/amalgamation/key.rs12
-rw-r--r--openpgp/src/cert/amalgamation/key/iter.rs22
-rw-r--r--openpgp/src/cert/bindings.rs8
-rw-r--r--openpgp/src/cert/builder.rs28
-rw-r--r--openpgp/src/cert/mod.rs8
5 files changed, 39 insertions, 39 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);
}
diff --git a/openpgp/src/cert/bindings.rs b/openpgp/src/cert/bindings.rs
index a5a32976..1884fe72 100644
--- a/openpgp/src/cert/bindings.rs
+++ b/openpgp/src/cert/bindings.rs
@@ -38,7 +38,7 @@ impl<P: key::KeyParts> Key<P, key::SubordinateRole> {
/// .parts_into_secret()?.into_keypair()?;
///
/// // Let's add an encryption subkey.
- /// let flags = KeyFlags::default().set_storage_encryption();
+ /// let flags = KeyFlags::empty().set_storage_encryption();
/// assert_eq!(cert.keys().with_policy(p, None).alive().revoked(false)
/// .key_flags(&flags).count(),
/// 0);
@@ -146,7 +146,7 @@ impl UserID {
/// # fn f() -> Result<()> {
/// // Generate a Cert, and create a keypair from the primary key.
/// let (alice, _) = CertBuilder::new()
- /// .set_primary_key_flags(KeyFlags::default().set_certification())
+ /// .set_primary_key_flags(KeyFlags::empty().set_certification())
/// .add_userid("alice@example.org")
/// .generate()?;
/// let mut keypair = alice.primary_key().key().clone()
@@ -154,7 +154,7 @@ impl UserID {
///
/// // Generate a Cert for Bob.
/// let (bob, _) = CertBuilder::new()
- /// .set_primary_key_flags(KeyFlags::default().set_certification())
+ /// .set_primary_key_flags(KeyFlags::empty().set_certification())
/// .add_userid("bob@example.org")
/// .generate()?;
///
@@ -294,7 +294,7 @@ impl UserAttribute {
/// Image::Private(100, vec![0, 1, 2].into_boxed_slice())),
/// ])?;
/// let (bob, _) = CertBuilder::new()
- /// .set_primary_key_flags(KeyFlags::default().set_certification())
+ /// .set_primary_key_flags(KeyFlags::empty().set_certification())
/// .add_user_attribute(user_attr)
/// .generate()?;
///
diff --git a/openpgp/src/cert/builder.rs b/openpgp/src/cert/builder.rs
index 0750143a..1f725732 100644
--- a/openpgp/src/cert/builder.rs
+++ b/openpgp/src/cert/builder.rs
@@ -211,7 +211,7 @@ impl CertBuilder {
creation_time: None,
ciphersuite: CipherSuite::default(),
primary: KeyBlueprint{
- flags: KeyFlags::default().set_certification(),
+ flags: KeyFlags::empty().set_certification(),
validity: None,
ciphersuite: None,
},
@@ -254,7 +254,7 @@ impl CertBuilder {
creation_time: None,
ciphersuite: ciphersuite.into().unwrap_or(Default::default()),
primary: KeyBlueprint {
- flags: KeyFlags::default()
+ flags: KeyFlags::empty()
.set_certification()
.set_signing(),
validity: Some(time::Duration::new(3 * 52 * 7 * 24 * 60 * 60, 0)),
@@ -262,7 +262,7 @@ impl CertBuilder {
},
subkeys: vec![
KeyBlueprint {
- flags: KeyFlags::default()
+ flags: KeyFlags::empty()
.set_transport_encryption()
.set_storage_encryption(),
validity: None,
@@ -551,7 +551,7 @@ impl CertBuilder {
/// # }
/// ```
pub fn add_signing_subkey(self) -> Self {
- self.add_subkey(KeyFlags::default().set_signing(), None, None)
+ self.add_subkey(KeyFlags::empty().set_signing(), None, None)
}
/// Adds a subkey suitable for transport encryption.
@@ -589,7 +589,7 @@ impl CertBuilder {
/// # }
/// ```
pub fn add_transport_encryption_subkey(self) -> Self {
- self.add_subkey(KeyFlags::default().set_transport_encryption(),
+ self.add_subkey(KeyFlags::empty().set_transport_encryption(),
None, None)
}
@@ -628,7 +628,7 @@ impl CertBuilder {
/// # }
/// ```
pub fn add_storage_encryption_subkey(self) -> Self {
- self.add_subkey(KeyFlags::default().set_storage_encryption(),
+ self.add_subkey(KeyFlags::empty().set_storage_encryption(),
None, None)
}
@@ -667,7 +667,7 @@ impl CertBuilder {
/// # }
/// ```
pub fn add_certification_subkey(self) -> Self {
- self.add_subkey(KeyFlags::default().set_certification(), None, None)
+ self.add_subkey(KeyFlags::empty().set_certification(), None, None)
}
/// Adds an authentication-capable subkey.
@@ -705,7 +705,7 @@ impl CertBuilder {
/// # }
/// ```
pub fn add_authentication_subkey(self) -> Self {
- self.add_subkey(KeyFlags::default().set_authentication(), None, None)
+ self.add_subkey(KeyFlags::empty().set_authentication(), None, None)
}
/// Adds a custom subkey.
@@ -1062,7 +1062,7 @@ impl CertBuilder {
{
let mut key = self.primary.ciphersuite
.unwrap_or(self.ciphersuite)
- .generate_key(&KeyFlags::default().set_certification())?;
+ .generate_key(&KeyFlags::empty().set_certification())?;
key.set_creation_time(creation_time)?;
let mut sig = signature::SignatureBuilder::new(SignatureType::DirectKey)
// GnuPG wants at least a 512-bit hash for P521 keys.
@@ -1182,7 +1182,7 @@ mod tests {
let p = &P::new();
let (cert1, _) = CertBuilder::new()
.set_cipher_suite(CipherSuite::Cv25519)
- .set_primary_key_flags(KeyFlags::default())
+ .set_primary_key_flags(KeyFlags::empty())
.add_transport_encryption_subkey()
.generate().unwrap();
assert!(cert1.primary_key().with_policy(p, None).unwrap().for_certification());
@@ -1193,8 +1193,8 @@ mod tests {
fn gen_wired_subkeys() {
let (cert1, _) = CertBuilder::new()
.set_cipher_suite(CipherSuite::Cv25519)
- .set_primary_key_flags(KeyFlags::default())
- .add_subkey(KeyFlags::default().set_certification(), None, None)
+ .set_primary_key_flags(KeyFlags::empty())
+ .add_subkey(KeyFlags::empty().set_certification(), None, None)
.generate().unwrap();
let sig_pkts = cert1.subkeys().next().unwrap().bundle().self_signatures[0].hashed_area();
@@ -1265,9 +1265,9 @@ mod tests {
let (cert,_) = CertBuilder::new()
.set_creation_time(now)
.set_validity_period(600 * s)
- .add_subkey(KeyFlags::default().set_signing(),
+ .add_subkey(KeyFlags::empty().set_signing(),
300 * s, None)
- .add_subkey(KeyFlags::default().set_authentication(),
+ .add_subkey(KeyFlags::empty().set_authentication(),
None, None)
.generate().unwrap();
diff --git a/openpgp/src/cert/mod.rs b/openpgp/src/cert/mod.rs
index f932292a..75695e82 100644
--- a/openpgp/src/cert/mod.rs
+++ b/openpgp/src/cert/mod.rs
@@ -4073,7 +4073,7 @@ mod test {
let (bind1, rev1, bind2, rev2) = {
let bind1 = signature::SignatureBuilder::new(SignatureType::DirectKey)
.set_features(&Features::sequoia()).unwrap()
- .set_key_flags(&KeyFlags::default()).unwrap()
+ .set_key_flags(&KeyFlags::empty()).unwrap()
.set_signature_creation_time(t1).unwrap()
.set_key_validity_period(Some(time::Duration::new(10 * 52 * 7 * 24 * 60 * 60, 0))).unwrap()
.set_preferred_hash_algorithms(vec![HashAlgorithm::SHA512]).unwrap()
@@ -4087,7 +4087,7 @@ mod test {
let bind2 = signature::SignatureBuilder::new(SignatureType::DirectKey)
.set_features(&Features::sequoia()).unwrap()
- .set_key_flags(&KeyFlags::default()).unwrap()
+ .set_key_flags(&KeyFlags::empty()).unwrap()
.set_signature_creation_time(t3).unwrap()
.set_key_validity_period(Some(time::Duration::new(10 * 52 * 7 * 24 * 60 * 60, 0))).unwrap()
.set_preferred_hash_algorithms(vec![HashAlgorithm::SHA512]).unwrap()
@@ -4751,7 +4751,7 @@ Pu1xwz57O4zo1VYf6TqHJzVC3OMvMUM2hhdecMUe5x6GorNaj6g=
for i in 0..N {
let binding = signature::SignatureBuilder::new(SignatureType::DirectKey)
.set_features(&Features::sequoia()).unwrap()
- .set_key_flags(&KeyFlags::default()).unwrap()
+ .set_key_flags(&KeyFlags::empty()).unwrap()
.set_signature_creation_time(t1).unwrap()
// Vary this...
.set_key_validity_period(Some(
@@ -5017,7 +5017,7 @@ Pu1xwz57O4zo1VYf6TqHJzVC3OMvMUM2hhdecMUe5x6GorNaj6g=
key::Key4::generate_ecc(false, Curve::Cv25519)?.into();
let subkey_pub = subkey_sec.clone().take_secret().0;
let builder = signature::SignatureBuilder::new(SignatureType::SubkeyBinding)
- .set_key_flags(&KeyFlags::default()
+ .set_key_flags(&KeyFlags::empty()
.set_transport_encryption())?;
let binding = subkey_sec.bind(&mut primary_pair, &cert, builder)?;