summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJustus Winter <justus@sequoia-pgp.org>2023-07-03 13:46:15 +0200
committerJustus Winter <justus@sequoia-pgp.org>2023-07-18 17:06:52 +0200
commit40b77ed618fa93432b3bb4e3ba8a43c5f2e2cb2a (patch)
tree2cbec3f1797453576de6203099659692d4b08b41
parent3f38bd10eda9ea51130ffa40b716e7ea3364db82 (diff)
openpgp: Add accessors for the underlying Bitfields.
- Fixes #775.
-rw-r--r--openpgp/NEWS3
-rw-r--r--openpgp/src/packet/signature/subpacket.rs6
-rw-r--r--openpgp/src/types/features.rs10
-rw-r--r--openpgp/src/types/key_flags.rs10
-rw-r--r--openpgp/src/types/server_preferences.rs10
5 files changed, 39 insertions, 0 deletions
diff --git a/openpgp/NEWS b/openpgp/NEWS
index ae196d0a..3c734164 100644
--- a/openpgp/NEWS
+++ b/openpgp/NEWS
@@ -34,6 +34,9 @@
- parse::PacketParserBuilder::automatic_hashing
- types::AEADAlgorithm::GCM
- types::Bitfield
+ - types::Features::as_bitfield
+ - types::KeyFlags::as_bitfield
+ - types::KeyServerPreferences::as_bitfield
** Deprecated functionality
- cert::Preferences::preferred_aead_algorithms
- packet::signature::SignatureBuilder::set_preferred_aead_algorithms
diff --git a/openpgp/src/packet/signature/subpacket.rs b/openpgp/src/packet/signature/subpacket.rs
index 6f341b0e..45e1d5ab 100644
--- a/openpgp/src/packet/signature/subpacket.rs
+++ b/openpgp/src/packet/signature/subpacket.rs
@@ -1334,6 +1334,12 @@ impl NotationDataFlags {
Self::new(&[0, 0, 0, 0]).unwrap()
}
+ /// Returns a reference to the underlying
+ /// [`Bitfield`](crate::types::Bitfield).
+ pub fn as_bitfield(&self) -> &crate::types::Bitfield {
+ &self.0
+ }
+
/// Returns a slice containing the raw values.
pub(crate) fn as_slice(&self) -> &[u8] {
self.0.as_bytes()
diff --git a/openpgp/src/types/features.rs b/openpgp/src/types/features.rs
index 4d5ac748..65144e25 100644
--- a/openpgp/src/types/features.rs
+++ b/openpgp/src/types/features.rs
@@ -116,6 +116,16 @@ impl Features {
Self::new(&v[..]).set_mdc()
}
+ /// Returns a reference to the underlying [`Bitfield`].
+ pub fn as_bitfield(&self) -> &Bitfield {
+ &self.0
+ }
+
+ /// Returns a mutable reference to the underlying [`Bitfield`].
+ pub fn as_bitfield_mut(&mut self) -> &mut Bitfield {
+ &mut self.0
+ }
+
/// Compares two feature sets for semantic equality.
///
/// `Features`' implementation of `PartialEq` compares two feature
diff --git a/openpgp/src/types/key_flags.rs b/openpgp/src/types/key_flags.rs
index cc95ff2e..aa8f12f0 100644
--- a/openpgp/src/types/key_flags.rs
+++ b/openpgp/src/types/key_flags.rs
@@ -160,6 +160,16 @@ impl KeyFlags {
KeyFlags::new(&[])
}
+ /// Returns a reference to the underlying [`Bitfield`].
+ pub fn as_bitfield(&self) -> &Bitfield {
+ &self.0
+ }
+
+ /// Returns a mutable reference to the underlying [`Bitfield`].
+ pub fn as_bitfield_mut(&mut self) -> &mut Bitfield {
+ &mut self.0
+ }
+
/// Returns a slice containing the raw values.
pub(crate) fn as_bytes(&self) -> &[u8] {
self.0.as_bytes()
diff --git a/openpgp/src/types/server_preferences.rs b/openpgp/src/types/server_preferences.rs
index b3a19fae..ef989bf6 100644
--- a/openpgp/src/types/server_preferences.rs
+++ b/openpgp/src/types/server_preferences.rs
@@ -98,6 +98,16 @@ impl KeyServerPreferences {
Self::new(&[])
}
+ /// Returns a reference to the underlying [`Bitfield`].
+ pub fn as_bitfield(&self) -> &Bitfield {
+ &self.0
+ }
+
+ /// Returns a mutable reference to the underlying [`Bitfield`].
+ pub fn as_bitfield_mut(&mut self) -> &mut Bitfield {
+ &mut self.0
+ }
+
/// Returns a slice containing the raw values.
pub(crate) fn as_bytes(&self) -> &[u8] {
self.0.as_bytes()