[][src]Trait asn1_der::traits::FromDerEncoded

pub trait FromDerEncoded where
    Self: Sized
{ fn from_der_encoded(data: Vec<u8>) -> Result<Self>;
fn with_der_encoded(data: &[u8]) -> Result<Self>; }

A trait to parse DER-encoded data into a typed representation

Required methods

fn from_der_encoded(data: Vec<u8>) -> Result<Self>

Decodes some DER-encoded data and converts them into Self

Parameters:

  • data: The DER-encoded data to parse and to convert into Self

Returns either the successfully parsed object or on error:

  • Asn1DerError::NotEnoughBytes if the overall length is zero, the length-field is too short or the payload is shorter than the annotated length
  • Asn1DerError::InvalidEncoding if the length-field is invalid or if the encoded type does not conform to the DER-encoding rules
  • Asn1DerError::Unsupported if the length is greater than std::usize::MAX or if the encoded object is unsupported by this implementation (e.g. an integer that is too large)
  • Asn1DerError::InvalidTag if the tag annotates an incompatible type

fn with_der_encoded(data: &[u8]) -> Result<Self>

Decodes some DER-encoded data and converts them into Self

Warning: During the parsing we'll create a copy of the payload. However, the copying happens only if the object is valid and will be parsed to a DerObject and the copy includes only the payload (and not any other remaining data).

Parameters:

  • data: The DER-encoded data to parse and to convert into Self

Returns either the successfully parsed object or on error:

  • Asn1DerError::NotEnoughBytes if the overall length is zero, the length-field is too short or the payload is shorter than the annotated length
  • Asn1DerError::InvalidEncoding if the length-field is invalid or if the encoded type does not conform to the DER-encoding rules
  • Asn1DerError::Unsupported if the length is greater than std::usize::MAX or if the encoded object is unsupported by this implementation (e.g. an integer that is too large)
  • Asn1DerError::InvalidTag if the tag annotates an incompatible type
Loading content...

Implementations on Foreign Types

impl FromDerEncoded for ()[src]

impl FromDerEncoded for bool[src]

impl FromDerEncoded for Vec<u8>[src]

impl FromDerEncoded for String[src]

impl FromDerEncoded for u64[src]

impl<T> FromDerEncoded for Vec<T> where
    T: FromDerObject
[src]

Loading content...

Implementors

impl FromDerEncoded for DerObject[src]

fn from_der_encoded(data: Vec<u8>) -> Result<Self>[src]

Create a Generic-object from DER-encoded data

Parameters:

  • data: The DER-encoded data to parse

Returns either the successfully parsed object or on error:

  • Asn1DerError::NotEnoughBytes if the overall length is zero, the length-field is too short or the payload is shorter than the annotated length
  • Asn1DerError::InvalidEncoding if the length-field is invalid
  • Asn1DerError::Unsupported if the length is greater than std::usize::MAX

fn with_der_encoded(data: &[u8]) -> Result<Self>[src]

Create a Generic-object by decoding the DER-encoded data

Warning: The resulting object will contain a copy of the payload. However, the copying happens only if the object is valid and will be parsed and the copy includes only the payload (and not any other remaining data).

Parameters:

  • data: The DER-encoded data to parse; the data may be longer than the object

Returns either the successfully parsed object or on error:

  • Asn1DerError::NotEnoughBytes if the overall length is zero, the length-field is too short or the payload is shorter than the annotated length
  • Asn1DerError::InvalidEncoding if the length-field is invalid
  • Asn1DerError::Unsupported if the length is greater than std::usize::MAX
Loading content...