summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJustus Winter <justus@sequoia-pgp.org>2020-07-28 16:48:21 +0200
committerJustus Winter <justus@sequoia-pgp.org>2020-07-28 17:02:21 +0200
commitb9f1dac59c758826c7c92541d01f447179a1e4d2 (patch)
treea9c9f465e6433715edb749c21c0a6ae6f0197877
parentc5f44ce753f3b56338311b9dc9d1d3de86307fa3 (diff)
openpgp: Reimplement the KeyFlags struct using Bitfield.
- This also drops the implementation of PartialOrd since we did not use it in the key selection after all. - Fixes #525.
-rw-r--r--autocrypt/src/cert.rs8
-rw-r--r--openpgp/examples/encrypt-for.rs4
-rw-r--r--openpgp/examples/pad.rs4
-rw-r--r--openpgp/src/cert/amalgamation/key.rs14
-rw-r--r--openpgp/src/cert/amalgamation/key/iter.rs26
-rw-r--r--openpgp/src/cert/bindings.rs8
-rw-r--r--openpgp/src/cert/builder.rs52
-rw-r--r--openpgp/src/cert/mod.rs2
-rw-r--r--openpgp/src/packet/signature/subpacket.rs6
-rw-r--r--openpgp/src/policy.rs10
-rw-r--r--openpgp/src/serialize.rs4
-rw-r--r--openpgp/src/serialize/cert.rs2
-rw-r--r--openpgp/src/types/key_flags.rs450
-rw-r--r--openpgp/src/types/mod.rs12
-rw-r--r--openpgp/src/types/timestamp.rs4
-rw-r--r--sqv/tests/revoked-key.rs8
-rw-r--r--tool/src/commands/key.rs4
-rw-r--r--tool/src/sq.rs8
18 files changed, 313 insertions, 313 deletions
diff --git a/autocrypt/src/cert.rs b/autocrypt/src/cert.rs
index dd7b29e1..d0b1fdc1 100644
--- a/autocrypt/src/cert.rs
+++ b/autocrypt/src/cert.rs
@@ -29,12 +29,12 @@ pub fn cert_builder<'a, V, U>(version: V, userid: Option<U>)
})
.set_primary_key_flags(
KeyFlags::default()
- .set_certification(true)
- .set_signing(true))
+ .set_certification()
+ .set_signing())
.add_subkey(
KeyFlags::default()
- .set_transport_encryption(true)
- .set_storage_encryption(true),
+ .set_transport_encryption()
+ .set_storage_encryption(),
None,
None);
diff --git a/openpgp/examples/encrypt-for.rs b/openpgp/examples/encrypt-for.rs
index 359101ca..e1b580ef 100644
--- a/openpgp/examples/encrypt-for.rs
+++ b/openpgp/examples/encrypt-for.rs
@@ -24,8 +24,8 @@ fn main() {
}
let mode = match args[1].as_ref() {
- "at-rest" => KeyFlags::default().set_storage_encryption(true),
- "for-transport" => KeyFlags::default().set_transport_encryption(true),
+ "at-rest" => KeyFlags::default().set_storage_encryption(),
+ "for-transport" => KeyFlags::default().set_transport_encryption(),
x => panic!("invalid mode: {:?}, \
must be either 'at-rest' or 'for-transport'",
x),
diff --git a/openpgp/examples/pad.rs b/openpgp/examples/pad.rs
index e34c354d..d0c7a759 100644
--- a/openpgp/examples/pad.rs
+++ b/openpgp/examples/pad.rs
@@ -24,8 +24,8 @@ fn main() {
}
let mode = match args[1].as_ref() {
- "at-rest" => KeyFlags::default().set_storage_encryption(true),
- "for-transport" => KeyFlags::default().set_transport_encryption(true),
+ "at-rest" => KeyFlags::default().set_storage_encryption(),
+ "for-transport" => KeyFlags::default().set_transport_encryption(),
x => panic!("invalid mode: {:?}, \
must be either 'at-rest' or 'for-transport'",
x),
diff --git a/openpgp/src/cert/amalgamation/key.rs b/openpgp/src/cert/amalgamation/key.rs
index 341dc912..9bca8002 100644
--- a/openpgp/src/cert/amalgamation/key.rs
+++ b/openpgp/src/cert/amalgamation/key.rs
@@ -1538,8 +1538,8 @@ impl<'a, P, R, R2> ValidKeyAmalgamation<'a, P, R, R2>
/// # .generate()?;
/// for ka in cert.keys().with_policy(p, None) {
/// if ka.has_any_key_flag(KeyFlags::empty()
- /// .set_storage_encryption(true)
- /// .set_transport_encryption(true))
+ /// .set_storage_encryption()
+ /// .set_transport_encryption())
/// {
/// // `ka` is encryption capable.
/// }
@@ -1602,7 +1602,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(true))
+ self.has_any_key_flag(KeyFlags::default().set_certification())
}
/// Returns whether the key is signing capable.
@@ -1635,7 +1635,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(true))
+ self.has_any_key_flag(KeyFlags::default().set_signing())
}
/// Returns whether the key is authentication capable.
@@ -1669,7 +1669,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(true))
+ self.has_any_key_flag(KeyFlags::default().set_authentication())
}
/// Returns whether the key is storage-encryption capable.
@@ -1716,7 +1716,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(true))
+ self.has_any_key_flag(KeyFlags::default().set_storage_encryption())
}
/// Returns whether the key is transport-encryption capable.
@@ -1763,7 +1763,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(true))
+ self.has_any_key_flag(KeyFlags::default().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 01ca55c6..f1d66c0c 100644
--- a/openpgp/src/cert/amalgamation/key/iter.rs
+++ b/openpgp/src/cert/amalgamation/key/iter.rs
@@ -865,8 +865,8 @@ impl<'a, P, R> ValidKeyAmalgamationIter<'a, P, R>
/// for ka in cert.keys()
/// .with_policy(p, None)
/// .key_flags(KeyFlags::empty()
- /// .set_transport_encryption(true)
- /// .set_storage_encryption(true))
+ /// .set_transport_encryption()
+ /// .set_storage_encryption())
/// {
/// // Valid encryption-capable keys.
/// # i += 1;
@@ -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(true))
+ self.key_flags(KeyFlags::default().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(true))
+ self.key_flags(KeyFlags::default().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(true))
+ self.key_flags(KeyFlags::default().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(true))
+ self.key_flags(KeyFlags::default().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(true))
+ self.key_flags(KeyFlags::default().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(true);
+ let flags = KeyFlags::default().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(true);
+ let flags = KeyFlags::default().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(true);
+ let flags = KeyFlags::default().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(true);
+ let flags = KeyFlags::default().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(true);
+ let flags = KeyFlags::default().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(true))
+ .key_flags(KeyFlags::default().set_authentication())
.count(),
1);
}
diff --git a/openpgp/src/cert/bindings.rs b/openpgp/src/cert/bindings.rs
index 57c96038..a5a32976 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(true);
+ /// let flags = KeyFlags::default().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(true))
+ /// .set_primary_key_flags(KeyFlags::default().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(true))
+ /// .set_primary_key_flags(KeyFlags::default().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(true))
+ /// .set_primary_key_flags(KeyFlags::default().set_certification())
/// .add_user_attribute(user_attr)
/// .generate()?;
///
diff --git a/openpgp/src/cert/builder.rs b/openpgp/src/cert/builder.rs
index a17efb02..8cf54d0c 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(true),
+ flags: KeyFlags::default().set_certification(),
expiration: None,
ciphersuite: None,
},
@@ -255,8 +255,8 @@ impl CertBuilder {
ciphersuite: ciphersuite.into().unwrap_or(Default::default()),
primary: KeyBlueprint {
flags: KeyFlags::default()
- .set_certification(true)
- .set_signing(true),
+ .set_certification()
+ .set_signing(),
expiration: Some(
time::SystemTime::now()
+ time::Duration::new(3 * 52 * 7 * 24 * 60 * 60, 0)),
@@ -265,8 +265,8 @@ impl CertBuilder {
subkeys: vec![
KeyBlueprint {
flags: KeyFlags::default()
- .set_transport_encryption(true)
- .set_storage_encryption(true),
+ .set_transport_encryption()
+ .set_storage_encryption(),
expiration: None,
ciphersuite: None,
}
@@ -520,12 +520,12 @@ impl CertBuilder {
/// assert_eq!(cert.keys().count(), 2);
/// let ka = cert.with_policy(p, None)?.keys().nth(1).unwrap();
/// assert_eq!(ka.key_flags(),
- /// Some(KeyFlags::empty().set_signing(true)));
+ /// Some(KeyFlags::empty().set_signing()));
/// # Ok(())
/// # }
/// ```
pub fn add_signing_subkey(self) -> Self {
- self.add_subkey(KeyFlags::default().set_signing(true), None, None)
+ self.add_subkey(KeyFlags::default().set_signing(), None, None)
}
/// Adds a subkey suitable for transport encryption.
@@ -558,12 +558,12 @@ impl CertBuilder {
/// assert_eq!(cert.keys().count(), 2);
/// let ka = cert.with_policy(p, None)?.keys().nth(1).unwrap();
/// assert_eq!(ka.key_flags(),
- /// Some(KeyFlags::empty().set_transport_encryption(true)));
+ /// Some(KeyFlags::empty().set_transport_encryption()));
/// # Ok(())
/// # }
/// ```
pub fn add_transport_encryption_subkey(self) -> Self {
- self.add_subkey(KeyFlags::default().set_transport_encryption(true),
+ self.add_subkey(KeyFlags::default().set_transport_encryption(),
None, None)
}
@@ -597,12 +597,12 @@ impl CertBuilder {
/// assert_eq!(cert.keys().count(), 2);
/// let ka = cert.with_policy(p, None)?.keys().nth(1).unwrap();
/// assert_eq!(ka.key_flags(),
- /// Some(KeyFlags::empty().set_storage_encryption(true)));
+ /// Some(KeyFlags::empty().set_storage_encryption()));
/// # Ok(())
/// # }
/// ```
pub fn add_storage_encryption_subkey(self) -> Self {
- self.add_subkey(KeyFlags::default().set_storage_encryption(true),
+ self.add_subkey(KeyFlags::default().set_storage_encryption(),
None, None)
}
@@ -636,12 +636,12 @@ impl CertBuilder {
/// assert_eq!(cert.keys().count(), 2);
/// let ka = cert.with_policy(p, None)?.keys().nth(1).unwrap();
/// assert_eq!(ka.key_flags(),
- /// Some(KeyFlags::empty().set_certification(true)));
+ /// Some(KeyFlags::empty().set_certification()));
/// # Ok(())
/// # }
/// ```
pub fn add_certification_subkey(self) -> Self {
- self.add_subkey(KeyFlags::default().set_certification(true), None, None)
+ self.add_subkey(KeyFlags::default().set_certification(), None, None)
}
/// Adds an authentication-capable subkey.
@@ -674,12 +674,12 @@ impl CertBuilder {
/// assert_eq!(cert.keys().count(), 2);
/// let ka = cert.with_policy(p, None)?.keys().nth(1).unwrap();
/// assert_eq!(ka.key_flags(),
- /// Some(KeyFlags::empty().set_authentication(true)));
+ /// Some(KeyFlags::empty().set_authentication()));
/// # Ok(())
/// # }
/// ```
pub fn add_authentication_subkey(self) -> Self {
- self.add_subkey(KeyFlags::default().set_authentication(true), None, None)
+ self.add_subkey(KeyFlags::default().set_authentication(), None, None)
}
/// Adds a custom subkey.
@@ -715,8 +715,8 @@ impl CertBuilder {
/// .set_creation_time(now)
/// .set_expiration_time(now + 2 * y)
/// .add_subkey(KeyFlags::empty()
- /// .set_storage_encryption(true)
- /// .set_transport_encryption(true),
+ /// .set_storage_encryption()
+ /// .set_transport_encryption(),
/// now + y,
/// None)
/// .generate()?;
@@ -728,8 +728,8 @@ impl CertBuilder {
/// let ka = cert.with_policy(p, None)?.keys().nth(1).unwrap();
/// assert_eq!(ka.key_flags(),
/// Some(KeyFlags::empty()
- /// .set_storage_encryption(true)
- /// .set_transport_encryption(true)));
+ /// .set_storage_encryption()
+ /// .set_transport_encryption()));
/// # Ok(()) }
/// ```
pub fn add_subkey<T, C>(mut self, flags: KeyFlags, expiration: T, cs: C)
@@ -767,13 +767,13 @@ impl CertBuilder {
/// let (cert, rev) =
/// CertBuilder::general_purpose(None,
/// Some("Alice Lovelace <alice@example.org>"))
- /// .set_primary_key_flags(KeyFlags::empty().set_signing(true))
+ /// .set_primary_key_flags(KeyFlags::empty().set_signing())
/// .generate()?;
///
/// // Observe that the primary key's certification capability is
/// // set implicitly.
/// assert_eq!(cert.with_policy(p, None)?.primary_key().key_flags(),
- /// Some(KeyFlags::empty().set_signing(true).set_certification(true)));
+ /// Some(KeyFlags::empty().set_signing().set_certification()));
/// # Ok(()) }
/// ```
pub fn set_primary_key_flags(mut self, flags: KeyFlags) -> Self {
@@ -920,7 +920,7 @@ impl CertBuilder {
// make sure the primary key can sign subkeys
if !self.subkeys.is_empty() {
- self.primary.flags = self.primary.flags.set_certification(true);
+ self.primary.flags = self.primary.flags.set_certification();
}
// Generate & self-sign primary key.
@@ -1034,7 +1034,7 @@ impl CertBuilder {
{
let mut key = self.primary.ciphersuite
.unwrap_or(self.ciphersuite)
- .generate_key(&KeyFlags::default().set_certification(true))?;
+ .generate_key(&KeyFlags::default().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.
@@ -1166,7 +1166,7 @@ mod tests {
let (cert1, _) = CertBuilder::new()
.set_cipher_suite(CipherSuite::Cv25519)
.set_primary_key_flags(KeyFlags::default())
- .add_subkey(KeyFlags::default().set_certification(true), None, None)
+ .add_subkey(KeyFlags::default().set_certification(), None, None)
.generate().unwrap();
let sig_pkts = cert1.subkeys().next().unwrap().bundle().self_signatures[0].hashed_area();
@@ -1237,9 +1237,9 @@ mod tests {
let (cert,_) = CertBuilder::new()
.set_creation_time(now)
.set_expiration_time(now + 600 * s)
- .add_subkey(KeyFlags::default().set_signing(true),
+ .add_subkey(KeyFlags::default().set_signing(),
now + 300 * s, None)
- .add_subkey(KeyFlags::default().set_authentication(true),
+ .add_subkey(KeyFlags::default().set_authentication(),
None, None)
.generate().unwrap();
diff --git a/openpgp/src/cert/mod.rs b/openpgp/src/cert/mod.rs
index 8d7c0349..05178e17 100644
--- a/openpgp/src/cert/mod.rs
+++ b/openpgp/src/cert/mod.rs
@@ -5014,7 +5014,7 @@ Pu1xwz57O4zo1VYf6TqHJzVC3OMvMUM2hhdecMUe5x6GorNaj6g=
let subkey_pub = subkey_sec.clone().take_secret().0;
let builder = signature::SignatureBuilder::new(SignatureType::SubkeyBinding)
.set_key_flags(&KeyFlags::default()
- .set_transport_encryption(true))?;
+ .set_transport_encryption())?;
let binding = subkey_sec.bind(&mut primary_pair, &cert, builder)?;
let cert = Cert::try_from(vec![
diff --git a/openpgp/src/packet/signature/subpacket.rs b/openpgp/src/packet/signature/subpacket.rs
index 6206c42f..d771068d 100644
--- a/openpgp/src/packet/signature/subpacket.rs
+++ b/openpgp/src/packet/signature/subpacket.rs
@@ -2680,8 +2680,8 @@ fn accessors() {
assert_eq!(sig_.policy_uri(), Some(&b"foobar"[..]));
let key_flags = KeyFlags::default()
- .set_certification(true)
- .set_signing(true);
+ .set_certification()
+ .set_signing();
sig = sig.set_key_flags(&key_flags).unwrap();
let sig_ =
sig.clone().sign_hash(&mut keypair, hash.clone()).unwrap();
@@ -2978,7 +2978,7 @@ fn subpacket_test_2() {
length: 2.into(),
critical: false,
value: SubpacketValue::KeyFlags(
- KeyFlags::default().set_certification(true).set_signing(true))
+ KeyFlags::default().set_certification().set_signing())
}));
assert_eq!(sig.features().unwrap(), Features::empty().set_mdc());
diff --git a/openpgp/src/policy.rs b/openpgp/src/policy.rs
index 1cdb39ac..641a756d 100644
--- a/openpgp/src/policy.rs
+++ b/openpgp/src/policy.rs
@@ -1510,7 +1510,7 @@ mod test {
let subkey: key::SecretSubkey
= Key4::generate_rsa(4096)?.into();
let binding = signature::SignatureBuilder::new(SignatureType::SubkeyBinding)
- .set_key_flags(&KeyFlags::default().set_transport_encryption(true))?
+ .set_key_flags(&KeyFlags::default().set_transport_encryption())?
.sign_subkey_binding(&mut pk.clone().into_keypair()?,
&pk, &subkey)?;
@@ -1533,7 +1533,7 @@ mod test {
let subkey: key::SecretSubkey
= key::Key4::generate_ecc(true, Curve::Ed25519)?.into();
let binding = signature::SignatureBuilder::new(SignatureType::SubkeyBinding)
- .set_key_flags(&KeyFlags::default().set_transport_encryption(true))?
+ .set_key_flags(&KeyFlags::default().set_transport_encryption())?
.sign_subkey_binding(&mut pk.clone().into_keypair()?,
&pk, &subkey)?;
@@ -1687,7 +1687,7 @@ mod test {
eprintln!("Trying ECC primary, ECC sub:");
let (cert,_) = CertBuilder::new()
.set_cipher_suite(CipherSuite::Cv25519)
- .add_subkey(KeyFlags::default().set_signing(true), None,
+ .add_subkey(KeyFlags::default().set_signing(), None,
None)
.generate()?;
@@ -1704,7 +1704,7 @@ mod test {
eprintln!("Trying RSA primary, ECC sub:");
let (cert,_) = CertBuilder::new()
.set_cipher_suite(CipherSuite::RSA4k)
- .add_subkey(KeyFlags::default().set_signing(true), None,
+ .add_subkey(KeyFlags::default().set_signing(), None,
CipherSuite::Cv25519)
.generate()?;
@@ -1721,7 +1721,7 @@ mod test {
eprintln!("Trying ECC primary, RSA sub:");
let (cert,_) = CertBuilder::new()
.set_cipher_suite(CipherSuite::Cv25519)
- .add_subkey(KeyFlags::default().set_signing(true), None,
+ .add_subkey(KeyFlags::default().set_signing(), None,
CipherSuite::RSA4k)
.generate()?;
diff --git a/openpgp/src/serialize.rs b/openpgp/src/serialize.rs
index e243e906..a0a7e459 100644
--- a/openpgp/src/serialize.rs
+++ b/openpgp/src/serialize.rs
@@ -1396,7 +1396,7 @@ impl Marshal for SubpacketValue {
PolicyURI(ref p) =>
o.write_all(p)?,
KeyFlags(ref f) =>
- o.write_all(&f.to_vec())?,
+ o.write_all(f.as_slice())?,
SignersUserID(ref uid) =>
o.write_all(uid)?,
ReasonForRevocation { ref code, ref reason } => {
@@ -1459,7 +1459,7 @@ impl MarshalInto for SubpacketValue {
PreferredKeyServer(ref p) => p.len(),
PrimaryUserID(_) => 1,
PolicyURI(ref p) => p.len(),
- KeyFlags(ref f) => f.to_vec().len(),
+ KeyFlags(ref f) => f.as_slice().len(),
SignersUserID(ref uid) => uid.len(),
ReasonForRevocation { ref reason, .. } => 1 + reason.len(),
Features(ref f) => f.as_slice().len(),
diff --git a/openpgp/src/serialize/cert.rs b/openpgp/src/serialize/cert.rs
index a36dfe06..8e85ac29 100644
--- a/openpgp/src/serialize/cert.rs
+++ b/