der_parser::der

Type Alias DerObjectHeader

Source
pub type DerObjectHeader<'a> = Header<'a>;
👎Deprecated since 7.0.0: Use Tag instead
Expand description

DER object header (identifier and length)

This is the same object as BerObjectHeader.

Aliased Type§

struct DerObjectHeader<'a> { /* private fields */ }

Implementations

Source§

impl<'a> Header<'a>

Source

pub const fn new( class: Class, constructed: bool, tag: Tag, length: Length, ) -> Header<'a>

Build a new BER/DER header from the provided values

Source

pub const fn new_simple(tag: Tag) -> Header<'a>

Build a new BER/DER header from the provided tag, with default values for other fields

Source

pub fn with_class(self, class: Class) -> Header<'a>

Set the class of this Header

Source

pub fn with_constructed(self, constructed: bool) -> Header<'a>

Set the constructed flags of this Header

Source

pub fn with_tag(self, tag: Tag) -> Header<'a>

Set the tag of this Header

Source

pub fn with_length(self, length: Length) -> Header<'a>

Set the length of this Header

Source

pub fn with_raw_tag(self, raw_tag: Option<Cow<'a, [u8]>>) -> Header<'a>

Update header to add reference to raw tag

Source

pub const fn class(&self) -> Class

Return the class of this header.

Source

pub const fn constructed(&self) -> bool

Return true if this header has the ‘constructed’ flag.

Source

pub const fn tag(&self) -> Tag

Return the tag of this header.

Source

pub const fn length(&self) -> Length

Return the length of this header.

Source

pub fn raw_tag(&self) -> Option<&[u8]>

Return the raw tag encoding, if it was stored in this object

Source

pub const fn is_primitive(&self) -> bool

Test if object is primitive

Source

pub const fn is_constructed(&self) -> bool

Test if object is constructed

Source

pub const fn assert_class(&self, class: Class) -> Result<(), Error>

Return error if class is not the expected class

Source

pub const fn assert_tag(&self, tag: Tag) -> Result<(), Error>

Return error if tag is not the expected tag

Source

pub const fn assert_primitive(&self) -> Result<(), Error>

Return error if object is not primitive

Source

pub const fn assert_constructed(&self) -> Result<(), Error>

Return error if object is primitive

Source

pub const fn is_universal(&self) -> bool

Test if object class is Universal

Source

pub const fn is_application(&self) -> bool

Test if object class is Application

Source

pub const fn is_contextspecific(&self) -> bool

Test if object class is Context-specific

Source

pub const fn is_private(&self) -> bool

Test if object class is Private

Source

pub const fn assert_definite(&self) -> Result<(), Error>

Return error if object length is definite

Source

pub fn parse_ber_content<'i>( &self, i: &'i [u8], ) -> Result<(&'i [u8], &'i [u8]), Err<Error>>

Get the content following a BER header

Source

pub fn parse_der_content<'i>( &self, i: &'i [u8], ) -> Result<(&'i [u8], &'i [u8]), Err<Error>>

Get the content following a DER header

Trait Implementations

Source§

impl<'a> Clone for Header<'a>

Source§

fn clone(&self) -> Header<'a>

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Debug for Header<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl DynTagged for Header<'_>

Source§

fn tag(&self) -> Tag

Source§

impl From<Tag> for Header<'_>

Source§

fn from(tag: Tag) -> Header<'_>

Converts to this type from the input type.
Source§

impl<'a> FromBer<'a> for Header<'a>

Source§

fn from_ber(bytes: &'a [u8]) -> Result<(&'a [u8], Header<'a>), Err<Error>>

Attempt to parse input bytes into a BER object
Source§

impl<'a> FromDer<'a> for Header<'a>

Source§

fn from_der(bytes: &'a [u8]) -> Result<(&'a [u8], Header<'a>), Err<Error>>

Attempt to parse input bytes into a DER object (enforcing constraints)
Source§

impl<'a> PartialEq for Header<'a>

Compare two BER headers. len fields are compared only if both objects have it set (same for raw_tag)

Source§

fn eq(&self, other: &Header<'_>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl ToDer for Header<'_>

Source§

fn to_der_len(&self) -> Result<usize, Error>

Get the length of the object (including the header), when encoded
Source§

fn write_der_header( &self, writer: &mut dyn Write, ) -> Result<usize, SerializeError>

Attempt to write the DER header to this writer.
Source§

fn write_der_content( &self, _writer: &mut dyn Write, ) -> Result<usize, SerializeError>

Attempt to write the DER content (all except header) to this writer.
Source§

fn write_der_raw(&self, writer: &mut dyn Write) -> Result<usize, SerializeError>

Similar to using to_der, but uses provided values without changes. This can generate an invalid encoding for a DER object.
Source§

fn to_der_vec(&self) -> Result<Vec<u8>, SerializeError>

Write the DER encoded representation to a newly allocated Vec<u8>.
Source§

fn to_der_vec_raw(&self) -> Result<Vec<u8>, SerializeError>

Similar to using to_vec, but uses provided values without changes. This can generate an invalid encoding for a DER object.
Source§

fn write_der(&self, writer: &mut dyn Write) -> Result<usize, SerializeError>

Attempt to write the DER encoded representation (header and content) into this writer. Read more
Source§

impl ToStatic for Header<'_>

Source§

type Owned = Header<'static>

Source§

fn to_static(&self) -> <Header<'_> as ToStatic>::Owned

Source§

impl Eq for Header<'_>