Problem with calling unmanaged function from VC++

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: darkhonor (alex_at_darkhonor-dot-com.no-spam.invalid)
Date: 04/23/04


Date: 23 Apr 2004 17:38:06 -0500

I'm very new to Windows development, all
of my background is in Linux, so please bear with me. I am working
on a class project and just for fun I'm building a frontend using
VC++ 2003. The project uses the OpenSSL crypto libraries
(specifically the BIGNUM functions). The offending code is:

                         if (this->rbtnSetKeysize->Checked) {
                                 this->intKeysize = 512;
                                 // Load the Prime Number and calculate the Secret Value
                                 this->statusBar1->Text = "Generating Prime and Secret
values...";
                                 this->bnPrime = BN_generate_prime(NULL,
this->intKeysize, 1, NULL, NULL, NULL, NULL);
                                 this->bnTmp = BN_generate_prime(NULL, this->intKeysize,
1, NULL, NULL, NULL, NULL);
                                 BN_mod(this->bnSecret, this->bnTmp, this->bnPrime,
this->bnctxContext);
                                 this->statusBar1->Text = "Prime and Secret values
generated.";
                         } else {
                                 this->statusBar1->Text = "Loading Prime Number from
File...";

                                 FileStream *fs = new
FileStream(this->txtInputFile->Text,
FileMode::Open, FileAccess::Read,
FileShare::None);
                                 StreamReader *sr = new StreamReader(fs);
                                 BN_hex2bn(&bnPrime, sr->ReadLine());
                                 fs->Close();

                                 this->intKeysize = BN_num_bits(this->bnPrime);
                                 this->statusBar1->Text = "Generating Secret
Value...";
                                 this->bnTmp = BN_generate_prime(NULL, this->intKeysize,
1, NULL, NULL, NULL, NULL);
                                 BN_mod(this->bnSecret, this->bnTmp, this->bnPrime,
this->bnctxContext);
                                 this->statusBar1->Text = "Secret Value
Generated";
                         } // End If

I am trying to call the BN_hex2bn function, which takes the address of
a dynamic BIGNUM as a parameter. I have bnPrime declared as a BIGNUM
* variable. However, when the call to the function in the snippet
below goes through the compiler, I get the following error:

error C2664: 'BN_hex2bn': cannot convert parameter 1 from 'BIGNUM
*__gc *' to 'BIGNUM **'

Any ideas? I'm having other problems as well, but I figured I
wouldn't hit you all at once. Thanks for your help.

Alex