编码规则的区别:
1. DER
为确保编码的唯一性,出现了CER和DER两种编码方案,它们均为BER子集。
其中DER只使用定长编码,CER基于不定长编码。

2. PER
在PER中,tag从不传送,length和value如果双方都知道,也不需传送。
因此,其编码更精简,效率更高。

The key difference between them is that DER uses the definite
length form of encoding while CER uses the indefinite length
form. DER is more suitable for the small encoded values,
while CER is more suitable for the large ones.

Whereas the basic encoding rules give the sender of an encoding
various choices as to how data values may be encoded,
the canonical and distinguished encoding rules select just one
encoding from those allowed by the basic encoding rules, eliminating
all of the sender's options. The canonical and distinguished encoding
rules differ from each other in the set of restrictions that they
place on the basic encoding rules.

The distinguished encoding rules is more suitable than the canonical
encoding rules if the encoded value is small enough to fit into the
available memory and there is a need to rapidly skip over some nested
values. The canonical encoding rules is more suitable than the distinguished
encoding rules if there is a need to encode values that are so large that
they cannot readily fit into the available memory or it is necessary to
encode and transmit a part of a value before the entire value is available.
The basic encoding rules is more suitable than the canonical or distinguished
encoding rules if the encoding contains a set value or set-of value and there
is no need for the restrictions that the canonical and distinguished encoding
rules impose

Structure of an encoding:
a) identifier octets (see 8.1.2);
b) length octets (see 8.1.3);
c) contents octets (see 8.1.4);
d) end-of-contents octets (see 8.1.5).(可选)