From: Jake <[EMAIL PROTECTED]>
Perfectly normal, it's called normalising. The bignum as well as the
"bin" are considered to be ordered with the most significant byet
first, which means you have an unneeded leading zero, which is
discarded, just as you'd eliminiate the leading zeroes in the decimal
number 0010, resulting in 10.
crypto> the following program outputs:
crypto>
crypto> -----------------------
crypto> what the heck?
crypto> 0 41
crypto> 41 81
crypto> 81 c1
crypto> c1 1
crypto> 1 42
crypto> 42 82
crypto> 82 c2
crypto> c2 0
crypto> -----------------------
crypto>
crypto> is this the expected behavior?
crypto>
crypto>
crypto> #include <stdio.h>
crypto> #include <string.h>
crypto> #include <openssl/bn.h>
crypto>
crypto> static unsigned char data[8]={0x00,0x41,0x81,0xc1,0x01,0x42,0x82,0xc2};
crypto>
crypto> int main(int argc, char* argv[])
crypto> {
crypto> unsigned char aa[8];
crypto> BIGNUM *a;
crypto> int i;
crypto>
crypto> memset(aa, 0, 8);
crypto> a = BN_new();
crypto>
crypto> BN_bin2bn(data, 8, a);
crypto> BN_bn2bin(a, aa);
crypto>
crypto> if (memcmp(aa, data, 8) != 0)
crypto> printf("what the heck?\n");
crypto>
crypto> for (i = 0; i < 8; i++)
crypto> printf("%2x %2x\n", data[i], aa[i]);
crypto> }
--
Richard Levitte \ Spannv�gen 38, II \ [EMAIL PROTECTED]
Redakteur@Stacken \ S-168 35 BROMMA \ T: +46-8-26 52 47
\ SWEDEN \ or +46-733-72 88 11
Procurator Odiosus Ex Infernis -- [EMAIL PROTECTED]
Member of the OpenSSL development team: http://www.openssl.org/
Software Engineer, GemPlus: http://www.gemplus.com/
Unsolicited commercial email is subject to an archival fee of $400.
See <http://www.stacken.kth.se/~levitte/mail/> for more info.
______________________________________________________________________
OpenSSL Project http://www.openssl.org
Development Mailing List [EMAIL PROTECTED]
Automated List Manager [EMAIL PROTECTED]