In message <[EMAIL PROTECTED]> on Mon, 03 May 2004 18:15:48 +0000, Carlos Cabaņero <[EMAIL PROTECTED]> said:
charlychango> I'm giving a look to the code of OpenSSL as I'm very charlychango> interested in RSA encryptation / decryp. specially for a charlychango> subject called Discrete Math. My problem is that I have charlychango> to work on an algorithm by myself and, of course, I'm charlychango> trying to implement and understand some things that OSSL charlychango> uses like the Arbitrary Precision Numbers (BIGNUM). charlychango> charlychango> What I can't understand is how the function BN_bin2bn charlychango> works (or at least, I know what it does but I think charlychango> doesn't do it correctly). For example, imagine that I charlychango> have to transform the string "1234" to the BIGNUM->d charlychango> (that it's a pointer to a long): If the string "1234" is to be interpreted as a hexadecimal number, you should use BN_hex2bn(). If it's to be interpreted as a decimal number, you should use BN_dec2bn(). BN_bin2bn() is supposed to be used when you get a number in raw binary form. If you have the number 1234 stored in a unsigned char array (in big-endian form, which is required by BN_bin2bn()), then it could look like this (I trust you understand C enough to understand what this does): unsigned char raw_input[] = { 4, 210 }; /* 1234 = 4 * 256 + 210 */ BIGNUM *bn = BN_bin2bn(raw_input, sizeof(raw_input)); ----- Please consider sponsoring my work on free software. See http://www.free.lp.se/sponsoring.html for details. -- Richard Levitte \ Tunnlandsvägen 52 \ [EMAIL PROTECTED] [EMAIL PROTECTED] \ S-168 36 BROMMA \ T: +46-708-26 53 44 \ SWEDEN \ Procurator Odiosus Ex Infernis -- [EMAIL PROTECTED] Member of the OpenSSL development team: http://www.openssl.org/ 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 User Support Mailing List [EMAIL PROTECTED] Automated List Manager [EMAIL PROTECTED]