pub struct Der<'a, W: Write + 'a> { /* private fields */ }
Expand description
Helper for writing DER that automattically encoes tags and content lengths.
Implementations§
source§impl<'a, W: Write> Der<'a, W>
impl<'a, W: Write> Der<'a, W>
sourcepub fn new(writer: &'a mut W) -> Self
pub fn new(writer: &'a mut W) -> Self
Create a new Der
structure that writes values to the given writer.
sourcepub fn positive_integer(&mut self, input: &[u8]) -> Result<()>
pub fn positive_integer(&mut self, input: &[u8]) -> Result<()>
Write the given input as a positive integer.
sourcepub fn nested<F: FnOnce(&mut Der<'_, Vec<u8>>) -> Result<()>>(
&mut self,
tag: Tag,
func: F
) -> Result<()>
pub fn nested<F: FnOnce(&mut Der<'_, Vec<u8>>) -> Result<()>>(
&mut self,
tag: Tag,
func: F
) -> Result<()>
Write a nested structure by passing in a handling function that writes to an intermediate
Vec
before writing the whole sequence to self
.
sourcepub fn sequence<F: FnOnce(&mut Der<'_, Vec<u8>>) -> Result<()>>(
&mut self,
func: F
) -> Result<()>
pub fn sequence<F: FnOnce(&mut Der<'_, Vec<u8>>) -> Result<()>>(
&mut self,
func: F
) -> Result<()>
Write a SEQUENCE
by passing in a handling function that writes to an intermediate Vec
before writing the whole sequence to self
.
sourcepub fn raw(&mut self, input: &[u8]) -> Result<()>
pub fn raw(&mut self, input: &[u8]) -> Result<()>
Write raw bytes to self
. This does not calculate length or apply. This should only be used
when you know you are dealing with bytes that are already DER encoded.
sourcepub fn bit_string(&mut self, unused_bits: u8, bit_string: &[u8]) -> Result<()>
pub fn bit_string(&mut self, unused_bits: u8, bit_string: &[u8]) -> Result<()>
Write a BIT STRING
.
sourcepub fn octet_string(&mut self, octet_string: &[u8]) -> Result<()>
pub fn octet_string(&mut self, octet_string: &[u8]) -> Result<()>
Write an OCTET STRING
.