Expand description
§tsumiki-der
DER (Distinguished Encoding Rules) parsing and encoding.
This crate implements DER encoding as defined in ITU-T X.690.
§What is DER?
DER is a binary encoding format for ASN.1 data structures. It uses a Tag-Length-Value (TLV) structure where:
- Tag: Identifies the data type (INTEGER, SEQUENCE, etc.)
- Length: The size of the value in bytes
- Value: The actual data
§Example
use tsumiki::decoder::Decoder;
use tsumiki_der::Der;
// DER-encoded SEQUENCE with one INTEGER (value 42)
let bytes = vec![0x30, 0x03, 0x02, 0x01, 0x2a];
// Parse DER
let der: Der = bytes.decode()?;
assert_eq!(der.elements().len(), 1);§Encoding
use tsumiki::encoder::Encoder;
use tsumiki_der::{Der, Tlv, Tag, PrimitiveTag};
// Create DER structure
let tlv = Tlv::new_primitive(Tag::Primitive(PrimitiveTag::Integer, 0x02), vec![0x2a]);
let der = Der::new(vec![tlv]);
// Encode to bytes
let bytes: Vec<u8> = der.encode()?;Modules§
- error
- Error types for DER parsing and encoding operations.
Structs§
- Der
- Represents a DER (Distinguished Encoding Rules) encoded structure.
- Tlv
- Tag-Length-Value structure representing a single DER element.
Enums§
- Primitive
Tag - Primitive ASN.1 tag types.
- Tag
- Represents a DER tag that identifies the type of data in a TLV structure.
Constants§
- TAG_
CONSTRUCTED - Tag byte constructed flag (bit 5).