Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Encoding Rules: DER, BER, CER

Constants and enumerations

NameTypeDescription
Encoding.DEREncodingDistinguished Encoding Rules
Encoding.BEREncodingBasic Encoding Rules
Encoding.CEREncodingCanonical Encoding Rules
SyntaErrorexception classRaised on ASN.1 parse or encode failures
__version__strPackage version string (from Cargo.toml)

Encoding

Pass an Encoding value when constructing a Decoder or Encoder:

import synta

# DER — deterministic, used for X.509 certificates and PKCS structures
decoder = synta.Decoder(data, synta.Encoding.DER)

# BER — accepts indefinite-length forms (PKCS#7, LDAP, SNMP)
decoder = synta.Decoder(data, synta.Encoding.BER)

# CER — canonical streaming subset of BER
decoder = synta.Decoder(data, synta.Encoding.CER)

The Decoder and Encoder classes accept any Encoding value. Most PKI standards mandate DER. Use BER when reading PKCS#7 files from older tools that emit indefinite-length encodings.

API types

import synta

# DER encoder example
encoder = synta.Encoder(synta.Encoding.DER)
encoder.encode_integer(42)
out = encoder.finish()   # b'\x02\x01\x2a'

See Decoder and Encoder for full API reference.