On trying the macros, it gives the following errors

c:\se_simulation2\verificationserver\verifier\verifier\verifier.cpp(201) :
error C2664: 'PEM_ASN1_write' : cannot convert parameter 1 from 'int
(__cdecl *)(void)' to 'i2d_of_void (__cdecl *)'
        This conversion requires a reinterpret_cast, a C-style cast or
function-style cast
c:\se_simulation2\verificationserver\verifier\verifier\verifier.cpp(264) :
error C2664: 'PEM_ASN1_read' : cannot convert parameter 1 from 'char
*(__cdecl *)(void)' to 'd2i_of_void (__cdecl *)'
        This conversion requires a reinterpret_cast, a C-style cast or
function-style cast

I believe its more of a coding problem now, to typecast the pointers
properly rather than anything else, but still I am wondering if you faced
the same issues or not ?


On Fri, Jun 20, 2008 at 5:00 PM, Siddhartha Chhabra <
[EMAIL PROTECTED]> wrote:

> I will try the method that Bill just mentioned and hope that it works,
> Thanks again, but I would still like to know the problem with the way I am
> trying to do stuff.
>
> Thanks
>
> On Fri, Jun 20, 2008 at 4:58 PM, Siddhartha Chhabra <
> [EMAIL PROTECTED]> wrote:
>
>> Thanks for your quick replies, however, I did not understand it clearly, I
>> am very new to OpenSSL
>>
>> Here is what I am doing in my code
>>
>> dsa=DSA_generate_parameters(1024,seed,20,&counter,&h,cb,bio_err);
>> DSA_generate_key(dsa)
>>
>> Now I have the keys generated. Now if I say
>>     SHA1(sigbuf,11,dgst);
>>     //Generate a signature
>>
>>     if (1 == DSA_sign(0, dgst, sizeof(dgst), signature, &siglen, dsa))
>>     {
>>         printf("Succeeded\n");
>>     }
>>
>>
>>     if( 1 == DSA_verify(0,dgst,sizeof(dgst),signature,siglen,dsa))
>>     {
>>         printf("Succeeded\n");
>>     }
>>
>>
>> This works fine. But When I try to save everything in structure dsa to
>> another structure dsa2, barring the private key, to use it at the server for
>> verification, it fails. I am developing a prototype which has exactly these
>> requirements, I do not want the public key to be signed by a CA, just a
>> client signing data X and the server be able to verify it.
>>
>> Can you please say whats wrong with the above code?
>>
>> Thanks a ton
>>
>> On Fri, Jun 20, 2008 at 4:50 PM, Bill Colvin <[EMAIL PROTECTED]>
>> wrote:
>>
>>>  I had a similar problem.  I found I had to define my own macros for
>>> this as they were not in the OpenSSL set.
>>>
>>>
>>>
>>> #define PEM_write_DSAPublicKey(fp,x) \
>>>
>>>         PEM_ASN1_write((int (*)())i2d_DSAPublicKey,\
>>>
>>>             PEM_STRING_DSA_PUBLIC,fp,(char *)x,NULL,NULL,0,NULL,NULL)
>>>
>>>
>>>
>>> #define PEM_read_DSAPublicKey(fp,x,cb,u) (DSA *)PEM_ASN1_read( \
>>>
>>>     (char *(*)())d2i_DSAPublicKey,PEM_STRING_DSA_PUBLIC,fp,(char
>>> **)x,cb,u)
>>>
>>>
>>>
>>>
>>>
>>> /* Then to save the public key to a file referenced by fptr */
>>>
>>>
>>>
>>>         DSA         *dsa_E=NULL;
>>>
>>>
>>>
>>> /*  Generate your DSA key somewhere in here */
>>>
>>>
>>>
>>>         i = PEM_write_DSAPublicKey(fptr, dsa_E );
>>>
>>>
>>>
>>> /*  Transfer the public key file to the remote */
>>>
>>> /*  where the remote does the following assuming that fptr references the
>>> public key file  */
>>>
>>>
>>>
>>>         dsa_E = PEM_read_DSAPublicKey( fptr, NULL, NULL, NULL );
>>>
>>>
>>>
>>>
>>>
>>> Bill
>>>  ------------------------------
>>>
>>> *From:* [EMAIL PROTECTED] [mailto:
>>> [EMAIL PROTECTED] *On Behalf Of *Siddhartha Chhabra
>>> *Sent:* June 20, 2008 7:37 PM
>>> *To:* [email protected]
>>> *Subject:* DSA signing and verification
>>>
>>>
>>>
>>> Hi all,
>>>
>>> I am trying to use DSA_sign and DSA_verify functions to generate a
>>> signature and verify it. If I do this in the same file, that is signing and
>>> then verifying using the public key, things go on smoothly. However, if I
>>> try to save the DSA structure, that is by saving each of the values other
>>> than the private key, which I can later restore and use as a public key to
>>> verify the signature, the verification fails.
>>>
>>> How can I generate a signature at one place (say the client) and verify
>>> it on another process (say a server)? Essentially how can I save the public
>>> key counterpart of the private key that was used to sign in the first place.
>>>
>>> Thanks for the help
>>>
>>>
>>
>

Reply via email to