"Dr. Stephen Henson" wrote: > > On Sun, Feb 09, 2003, Ken Murchison wrote: > > > > > > > Nils Larsch wrote: > > > > > > Ken Murchison wrote: > > > > What is the correct way to convert a DSA key struct into a u_char buffer > > > > for use with EVP_VerifyFinal()? Is there a generic way to do this > > > > regardless of the signature key algorithm? The value of the EVP > > > > interface seems lost if I have to call different key preparation > > > > functions depending on algorithm used for the signature. > > > > > > EVP_VerifyFinal() expects the public key in a EVP_PKEY structure, > > > so why do you want to convert the key into a unsigned char buffer ? > > > Perhaps I misunderstood you, so what do you have and what do you > > > want to have ? > > > > Sorry, I misspoke. EVP_VerifyFinal() expects the _signature_ as a > > u_char buffer. How do I convert a DSA_SIG structure into a u_char > > buffer? For RSA sigs, I just convert the signature value using > > BN_bn2bin() (with padding if the length of the sig value < length of > > modulus). > > > > Well one standard for DSA signatures (used by certificates, S/MIME, TLS et > al) encodes the signature as the DER encoding of a Dss-Sig-Value structure. > Anything following that standard can just feed it directly into > EVP_VerifyFinal(). > > If the format used isn't of that form then you can populate the DSA_SIG > structure (which is the same as for Dss-Sig-Value) then follow the normal > conventions for determining its encoding: that is call i2d_DSA_SIG(). See > the various i2d_XXX manual pages for more info and the FAQ.
I'm trying to verify a PGP sig, so I guess I'll put 'r' and 's' into a DSA_SIG and call i2d_DSA_SIG(). > > This is the part that bothers me. AFAICT the EVP signature API doesn't > > abstract the algorithm specific handling of the signature. Is this by > > design, an oversight, or am I missing something? > > > > Can you be a bit more specific about what you mean? Sure. I would've thought that there would be an EVP_Verify interface where it would take a void *, which in the case of RSA would be a BN *, and in the case of DSA would be a DSA_SIG *. Or do something analogous to EVP_PKEY -- have a EVP_SIG_assign() which takes the sig data, creates a EVP_SIG * which is then fed into EVP_VerifyFinal(). -- Kenneth Murchison Oceana Matrix Ltd. Software Engineer 21 Princeton Place 716-662-8973 x26 Orchard Park, NY 14127 --PGP Public Key-- http://www.oceana.com/~ken/ksm.pgp ______________________________________________________________________ OpenSSL Project http://www.openssl.org User Support Mailing List [EMAIL PROTECTED] Automated List Manager [EMAIL PROTECTED]