On Donnerstag, 29. August 2002 16:58, [EMAIL PROTECTED] wrote:
> Hi Nils,

Hi Vignesh,

[...]
> >    RSA_Keys->n=BN_new();
> >    BN_init(RSA_Keys->n);
>
> BN_init() is unnecessary, because BN_new() initialize
> the BIGNUM structure.
>
> [...]
>
> > else if( !(RSA_Keys->n->d = (BN_ULONG *)malloc((ModBinLen+1)
> > *BN_BITS2))) {
> >       printf("RSA_Keys->n->d is NULL\n");
> >       exit(1);
> >    }
>
> 1. use OPENSSL_malloc()
> 2. set the BIGNUM->dmax value to ModBinLen+1
> 3. 1. and 2. are unnecessary because the BN functions automatically
>    allocate the required memory.
> __________________________________________________
> I think we might need to allocate memory as BN_new() only allocates memory
> for
> the BIGNUM pointer, but does it allocate memory for the inner pointers?

Yes, BN_new() only allocates memory for the BIGNUM structure and 
initialize it. But BN_bin2bn() (and all other BIGNUM functions) allocate, iff
necessary, sufficient memory ( the bn_expand() macro tests whether
BIGNUM->dmax (this value contains the size of the BIGNUM->d array) is 
large enough and, if not, allocates enough memory ).

Bye,
Nils
______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    [EMAIL PROTECTED]
Automated List Manager                           [EMAIL PROTECTED]

Reply via email to