Canonical Encoding Rules

Canonical Encoding Rules (CER) are a subset of the Basic Encoding Rules. They eliminate some of the additional flexibility provided by BER.

All valid CER encodings are valid BER encodings. Whereas BER allows multiple ways to encode most values, in CER only a single one of those ways is allowed for a given value (e.g., in BER, a BOOLEAN a value of 00 is FALSE and any non-zero value is TRUE, while in CER, 00 is FALSE and FF is TRUE, and values 01-FE are false).

CER is similar to DER in most ways. The major differences are as follows:

  • DER uses definite-length encoding, while CER uses indefinite-length encoding.
  • DER requires string types to be encoded in the primitive form, while CER requires that string types be encoded in the primitive form if they are less than 1000 octets long, and in the constructed form with 1000 byte segments (except for possibly the last sentence) if they are more than 1000 bytes long.
  • In DER components of a SET must be sorted at runtime. In CER components of a SET are presorted based on the tags, using the same algorithm that is utilized in PER.


Age ::= INTEGER (0..7)
firstGrade Age ::= 6
-- 02 01 06

Related Topics