pub enum Encoding {
Der,
Ber,
Cer,
}Expand description
ASN.1 encoding rules
Specifies which encoding rules to use when encoding or decoding ASN.1 data. Different encoding rules have different levels of strictness and features.
Variants§
Der
Distinguished Encoding Rules (deterministic subset of BER)
DER is a strict subset of BER that ensures deterministic encoding. It is commonly used in cryptographic applications where canonical encoding is required (e.g., X.509 certificates).
Ber
Basic Encoding Rules (most flexible)
BER is the most flexible encoding, allowing multiple ways to encode the same data. It supports indefinite length encoding and other features not available in DER.
Cer
Canonical Encoding Rules (similar to DER but for streaming)
CER is designed for streaming applications where the total length of a value may not be known in advance. The encoding rules are:
- Constructed types whose content exceeds 1 000 bytes must use
indefinite-length encoding (terminated by end-of-contents octets
0x00 0x00). Shorter constructed types use definite length. - Primitive types always use definite-length encoding.
- All other DER constraints (e.g. minimal integer encoding, TRUE=0xFF) remain in force.
CER is rarely used in practice; DER is preferred for certificates and most cryptographic protocols.