In message <[EMAIL PROTECTED]> on Fri, 11 Oct 2002 18:36:44 
-0700, David Brumley <[EMAIL PROTECTED]> said:

dbrumley> I've discovered a possible {bug,something unexpected} in
dbrumley> BN_dec2bn() in bn_print.c. I'll call it my "problem" until
dbrumley> confirmed.
[...]
dbrumley> The problem seems to be calling BN_dec2bn with an already
dbrumley> allocated BIGNUM that's been previously used.  Inside
dbrumley> BN_dec2bn the code is something like:
dbrumley> int BN_dec2bn(BIGNUM **bn, const char *a){
dbrumley>   BIGNUM *ret = NULL;
dbrumley>   ...
dbrumley>   if(*bn == NULL){
dbrumley>    ret = BN_new();
dbrumley>   } else {
dbrumley>    ret = *bn;
dbrumley>    BN_zero(ret);   // Call this line a
dbrumley>   }
dbrumley>   .. yadada ..
dbrumley>   while(*a) {
dbrumley>        ...
dbrumley>        BN_mul_word(ret,BN_DEC_CONV);  //call this line b
dbrumley>        BN_add_word(ret, l);
dbrumley>        ....
dbrumley>   }
dbrumley>   *bn = ret;
dbrumley>   ...
dbrumley> }
dbrumley> 
dbrumley> This function appears to want to decide whether or not the
dbrumley> parameter bn has already been allocated.

Correct.

dbrumley> If not, allocated a fresh BIGNUM.  If so, zero out the
dbrumley> bignum (e.g. line a).  However, BN_zero() doesn't actually
dbrumley> zero out all of the BIGNUM structure, i.e.  d[1-top] isn't
dbrumley> zeroed out, only d[0] in struct BIGNUM.

Correct, but it does change top (sets it to 0) as well, so talking
about the range d[1-top] is a moot point.

dbrumley> The problem seems to be manifested in BN_dec2bn() because of
dbrumley> the BN_mul_words and BN_add_words (e.g. line b).  Since the
dbrumley> upper parts of d aren't cleared out, those routines end up
dbrumley> adding to whatever junk happened to be left in d from the
dbrumley> previous iteration.

Perhaps there's a bug in those.

Can you send us a small piece of code that actually shows the problem?
Please send us the result that you get, so we can compare.

-- 
Richard Levitte   \ Spannv�gen 38, II \ [EMAIL PROTECTED]
Redakteur@Stacken  \ S-168 35  BROMMA  \ T: +46-8-26 52 47
                    \      SWEDEN       \ or +46-708-26 53 44
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
Development Mailing List                       [EMAIL PROTECTED]
Automated List Manager                           [EMAIL PROTECTED]

Reply via email to