Hi Nils,

I have put my doubt in the mail trail below inside
______________________________________________________
my comments....
______________________________________________________

Please let me know what you think.

Vignesh



                                                                                       
                            
                                                                                       
                            
                                                                                       
                            




[EMAIL PROTECTED] wrote:
>
> Hi friends,
>
> RSA_check_key() cores.

RSA_check_key() expects a private key => the RSA structure
must contain valid rsa->p and rsa->q entries otherwise
RSA_check_key() will always produce a core dump
( without p and q you can not verify that a RSA key is valid,
but of course it would be better if RSA_check_key() returns
a error message instead of a core :) .

> The following is what I did ...
[...]
>    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?
I think it is logical to allocate memory as the length of individual
exponent, modulus
the primes for private key and all of the others would be different. Hence
BN_new
would not allocated memory for the inner pointers of the BIGNUM struct.
Vignesh
__________________________________________________
[...]
>
> what am I doing wrong that is causing this problem. Basically what I am
> trying in this program is
> to create a RSA structure using the public key modulus and exponent in
> Base64 format.
>
> Any help would be greatly appreciated.
>
> Also is there any function that does this for me in OPENSSL?

AFAIK there are only functions to read/write a PEM encoded
PKCS#1 RSA public key (PEM_[read|write]_bio_RSAPublicKey).

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






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

Reply via email to