Skip to content

EEncodingRule

Jay edited this page Oct 3, 2026 · 2 revisions

EEncodingRule

#include <certpp/asn1/decoder.hpp> --- certpp::asn1

Represents the ASN.1 encoding rules. EAENC_BER: Basic Encoding Rules EAENC_DER: Distinguished Encoding Rules EAENC_CER: Canonical Encoding Rules

Enumerators

Enumerator Value Meaning
EAENC_BER 0
EAENC_DER
EAENC_CER

Example

The rule set is not decoration -- it decides which encodings are legal. These bytes are a valid (if wasteful) BER OCTET STRING whose length uses the long form below 128, and an invalid DER one; read X.509 input with EAENC_DER or a hand-crafted non-canonical length slips past.

const uint8_t data[] = { 0x04, 0x81, 0x05, 0x01, 0x02, 0x03, 0x04, 0x05 };
SReadOnlyByteSpan source(data, sizeof(data));

CTag tag;
SReadOnlyByteSpan content;
size_t bytesRead = 0;

if (CDecoder::readEncodedValue(source, EAENC_BER, tag, content, bytesRead)) {
    // accepted: BER permits any well-formed length form
}

if (!CDecoder::readEncodedValue(source, EAENC_DER, tag, content, bytesRead)) {
    // rejected: DER and CER both require the minimal length form
}

Reference generated from certpp/asn1/decoder.hpp at commit 0834b29 (v1.0.1). The header is authoritative --- if this page disagrees with it, the header is right and this page needs regenerating.

Clone this wiki locally