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