Trait rocket::mtls::oid::asn1_rs::ToDer

source ·
pub trait ToDer: DynTagged {
    // Required methods
    fn to_der_len(&self) -> Result<usize, Error>;
    fn write_der_header(
        &self,
        writer: &mut dyn Write,
    ) -> Result<usize, SerializeError>;
    fn write_der_content(
        &self,
        writer: &mut dyn Write,
    ) -> Result<usize, SerializeError>;

    // Provided methods
    fn to_der_vec(&self) -> Result<Vec<u8>, SerializeError> { ... }
    fn to_der_vec_raw(&self) -> Result<Vec<u8>, SerializeError> { ... }
    fn write_der(&self, writer: &mut dyn Write) -> Result<usize, SerializeError> { ... }
    fn write_der_raw(
        &self,
        writer: &mut dyn Write,
    ) -> Result<usize, SerializeError> { ... }
}
Available on crate feature mtls only.
Expand description

Common trait for all objects that can be encoded using the DER representation

§Examples

Objects from this crate can be encoded as DER:

use asn1_rs::{Integer, ToDer};

let int = Integer::from(4u32);
let mut writer = Vec::new();
let sz = int.write_der(&mut writer).expect("serialization failed");

assert_eq!(&writer, &[0x02, 0x01, 0x04]);

Many of the primitive types can also directly be encoded as DER:

use asn1_rs::ToDer;

let mut writer = Vec::new();
let sz = 4.write_der(&mut writer).expect("serialization failed");

assert_eq!(&writer, &[0x02, 0x01, 0x04]);

Required Methods§

source

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

Get the length of the object, 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.

Provided Methods§

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.

§Examples
use asn1_rs::{Integer, ToDer};

let int = Integer::from(4u32);
let mut writer = Vec::new();
let sz = int.write_der(&mut writer).expect("serialization failed");

assert_eq!(&writer, &[0x02, 0x01, 0x04]);
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.

Implementations on Foreign Types§

source§

impl ToDer for &[u8]

source§

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

source§

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

source§

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

source§

impl ToDer for (Class, bool, Tag)

source§

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

source§

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

source§

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

source§

impl ToDer for bool

source§

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

source§

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

source§

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

source§

impl ToDer for i8

source§

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

source§

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

source§

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

source§

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

source§

impl ToDer for i16

source§

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

source§

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

source§

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

source§

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

source§

impl ToDer for i32

source§

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

source§

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

source§

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

source§

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

source§

impl ToDer for i64

source§

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

source§

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

source§

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

source§

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

source§

impl ToDer for i128

source§

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

source§

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

source§

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

source§

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

source§

impl ToDer for u8

source§

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

source§

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

source§

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

source§

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

source§

impl ToDer for u16

source§

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

source§

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

source§

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

source§

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

source§

impl ToDer for u32

source§

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

source§

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

source§

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

source§

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

source§

impl ToDer for u64

source§

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

source§

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

source§

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

source§

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

source§

impl ToDer for u128

source§

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

source§

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

source§

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

source§

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

source§

impl ToDer for ()

source§

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

source§

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

source§

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

source§

impl<'a> ToDer for &'a str

source§

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

source§

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

source§

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

source§

impl<'a, T> ToDer for &'a T
where T: ToDer, &'a T: DynTagged,

source§

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

source§

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

source§

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

Implementors§

source§

impl ToDer for Length

source§

impl ToDer for Real

source§

impl ToDer for Header<'_>

source§

impl ToDer for Oid<'_>

source§

impl ToDer for String

source§

impl ToDer for Any<'_>

source§

impl ToDer for BitString<'_>

source§

impl ToDer for BmpString<'_>

source§

impl ToDer for Boolean

source§

impl ToDer for Enumerated

source§

impl ToDer for GeneralString<'_>

source§

impl ToDer for GeneralizedTime

source§

impl ToDer for GraphicString<'_>

source§

impl ToDer for Ia5String<'_>

source§

impl ToDer for Integer<'_>

source§

impl ToDer for Null

source§

impl ToDer for NumericString<'_>

source§

impl ToDer for ObjectDescriptor<'_>

source§

impl ToDer for OctetString<'_>

source§

impl ToDer for PrintableString<'_>

source§

impl ToDer for Sequence<'_>

source§

impl ToDer for Set<'_>

source§

impl ToDer for TeletexString<'_>

source§

impl ToDer for UniversalString<'_>

source§

impl ToDer for UtcTime

source§

impl ToDer for Utf8String<'_>

source§

impl ToDer for VideotexString<'_>

source§

impl ToDer for VisibleString<'_>

source§

impl<'a, T> ToDer for TaggedParser<'a, Explicit, T>
where T: ToDer,

source§

impl<'a, T> ToDer for TaggedParser<'a, Implicit, T>
where T: ToDer,

source§

impl<T> ToDer for Option<T>
where T: ToDer,

source§

impl<T> ToDer for BTreeSet<T>
where T: ToDer,

source§

impl<T> ToDer for HashSet<T>
where T: ToDer,

source§

impl<T> ToDer for Vec<T>
where T: ToDer,

source§

impl<T> ToDer for SequenceOf<T>
where T: ToDer,

source§

impl<T> ToDer for SetOf<T>
where T: ToDer,

source§

impl<T, const CLASS: u8, const TAG: u32> ToDer for TaggedValue<T, Explicit, CLASS, TAG>
where T: ToDer,

source§

impl<T, const CLASS: u8, const TAG: u32> ToDer for TaggedValue<T, Implicit, CLASS, TAG>
where T: ToDer,