1

OID's it seems are a way to represent a tree like structure.

Eg 1.3.6.1 being iso(1).org(3).did(6).internet(1)

The encoding scheme used most commonly seems to be BER and I am confused about the encoding of the first two digits. Why are the first two digits encoded into a single byte and why is it like this:

int first_digit = first_byte / 40;
int second_byte = first_byte % 40;

Is it assumed that the first two bytes are always small numbers and hence can be 'stored' easily in one byte? If so I can understand that.

But why the use of the magic number 40? Why 40?

eg. the first byte in above 1.3.xxx case would be encoded as 43.

4

1 回答 1

2

引用教授的“ASN.1 Complete”一书。John Larmouth,第 3.14 节(该书可从http://www.oss.com/asn1/resources/books-whitepapers-pubs/larmouth-asn1-book.pdf免费获得):

编码前两个弧的八位字节(在 1986 年)被认为不可能有大的值,并且为这两个弧使用两个八位字节是“一件坏事”。因此引入了“优化”(强制性)。

好吧,有三个顶级弧,我们可以在单个八位字节中容纳多达 128 个弧(0 到 127)的编码,并使用上述“更多位”概念。128除以3大约是40!让我们假设前两个顶级弧永远不会有超过 40 个子弧,并将前 40 个伪弧分配给顶级弧 0,接下来的 40 个分配给顶级弧 1,其余的分配给顶级弧。水平弧 2。

于 2015-09-02T11:16:58.350 回答