diff options
Diffstat (limited to 'openpgp/src/types/mod.rs')
-rw-r--r-- | openpgp/src/types/mod.rs | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/openpgp/src/types/mod.rs b/openpgp/src/types/mod.rs index 01ada8f7..ac6811d5 100644 --- a/openpgp/src/types/mod.rs +++ b/openpgp/src/types/mod.rs @@ -21,6 +21,18 @@ pub use self::server_preferences::KeyServerPreferences; mod timestamp; pub use timestamp::{Timestamp, Duration}; +/// Removes padding bytes from bitfields. +/// +/// Returns the size of the original bitfield, i.e. the number of +/// bytes the output has to be padded to when serialized. +pub(crate) fn bitfield_remove_padding(b: &mut Vec<u8>) -> usize { + let pad_to = b.len(); + while b.last() == Some(&0) { + b.pop(); + } + pad_to +} + /// The OpenPGP public key algorithms as defined in [Section 9.1 of /// RFC 4880], and [Section 5 of RFC 6637]. /// |