Search code examples
encodingasn.1der

ANS1 DER encoding


Can anybody confirm this:

ASN.1 DER already requires that integers start with a zero bit if non-negative.

I looked from the ANS1 DER specification but didnt find anything about that.


Solution

  • "The contents octets shall be a two's complement binary number equal to the integer value" says X.690, #8.3. This specifies what you seek.

    In addition to that:

    If the contents octets of an integer value encoding consist of more than one octet, then the bits of the first octet and bit 8 of the second octet: a) shall not all be ones; and b) shall not all be zero. These rules ensure that an integer value is always encoded in the smallest possible number of octets.