In message <[EMAIL PROTECTED]> on Wed, 6 Jul 2005 09:07:23 -0700, "Choudhary, 
Bimalendu" <[EMAIL PROTECTED]> said:

bchoudhary> 2) When I send the serial number 0x81 the der encoded
bchoudhary>    serial number is
bchoudhary> 
bchoudhary> 02 02 00 81
bchoudhary> 
bchoudhary> 4) When I send the serial number 0x8111 the der encoded
bchoudhary>    serial number is 
bchoudhary> 
bchoudhary> 02 03 00 81 11
bchoudhary> 
bchoudhary> The problem here is that in case 2) and 4) there is a
bchoudhary> extra byte 00 appended in front of the actual serial
bchoudhary> number given in the command line.
bchoudhary> 
bchoudhary> Can any one tell me why the length is being increased and
bchoudhary> an extra 00 is added in front of the serial number in this
bchoudhary> two cases.
bchoudhary> 
bchoudhary> It happens foe any serial number starting with hex digit 8
bchoudhary> or above and number of digit in the serial number is even.

ASN.1 Complete (downloadable from http://www.oss.com/asn1/larmouth.html),
Section 3.3 (Encoding an INTEGER value) explains it.  Basically, the
integer is a 2-complement value.  This means '02 01 81' would be
interpreted as (decimal) -127, while '02 02 00 81' is correctly
interpreted as (decimal) 129.

Cheers,
Richard

-----
Please consider sponsoring my work on free software.
See http://www.free.lp.se/sponsoring.html for details.

-- 
Richard Levitte                         [EMAIL PROTECTED]
                                        http://richard.levitte.org/

"When I became a man I put away childish things, including
 the fear of childishness and the desire to be very grown up."
                                                -- C.S. Lewis
______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    openssl-users@openssl.org
Automated List Manager                           [EMAIL PROTECTED]

Reply via email to