RSA 1024 in certificate

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

RSA 1024 in certificate

majorsoul
why does the DER encoding of public key modulus begins with
02 81 81 00 and not with 02 81 80 ??
Reply | Threaded
Open this post in threaded view
|

Re: RSA 1024 in certificate

jimmy-6
majorsoul (sent by Nabble.com) wrote:
> why does the DER encoding of public key modulus begins with
> 02 81 81 00 and not with 02 81 80 ??

ASN.1 specifies integers cannot be negative. so the leading zero makes
it positive.


-jb
______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
Development Mailing List                       [hidden email]
Automated List Manager                           [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: RSA 1024 in certificate

Jack Lloyd
On Mon, Feb 06, 2006 at 10:50:18PM +0530, jimmy wrote:
> majorsoul (sent by Nabble.com) wrote:
> >why does the DER encoding of public key modulus begins with
> >02 81 81 00 and not with 02 81 80 ??
>
> ASN.1 specifies integers cannot be negative. so the leading zero makes
> it positive.

Not quite; integers _can_ be negative in ASN.1. They are represented in
2s-complement, so a leading high bit signifies an negative number. So, when you
want to encode a positive number that would happen to have the high bit set
(such as a 8*n bit RSA modulus), you need to add a leading zero byte.

-J

______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
Development Mailing List                       [hidden email]
Automated List Manager                           [hidden email]