Re: Using Crypt::DSA



Sisyphus <sisyphus1@xxxxxxxxxxxxxxxxx> wrote:
>
> Do you have Convert::PEM installed ? It's not a pre-requisite for
> Crypt::DSA, but it might help you get at the answers you want. I
> don't understand PEM format at all - if you're in the same boat
> then maybe there's something in the openssl/doc/crypto/pem.pod
> for you.

I've decided for now that just writing out $key->pub_key is sufficient
for my purposes (to create a public key file). I can read in that hex
value and use it to sign a messages.

But now, I've run into another snag with Crypt::DSA. How in the world
do I write out a signature to a file, in a format that can be read
in by another script for the purpose of verifying the signed message?

I tried taking the signature object created by the sign() method,
base64 encoding it and writing it out. When I read that in, base64
decode it and populate a new signature object with it, verify()
complains, I think because I didn't first serialize the signature
(into an ASN.1 encoded format).

The CPAN docs say there's supposed to be a $sig->serialize method
on a signature object. But it appears this isn't true. Not only
does my script fail, complaining about the absence of such a method, but
looking at the source code for Crypt::RSA::Signature seems to reveal
that there is, in fact, no serialize method defined on a signature object.

So, once again, assuming I've signed a message, creating a signature
object, how do I write that signature to a file so it can be used
as input to a verify script?

BTW: if I do the sign and verify in the same script, passing the
signature object returned by the sign() method to the verify() method,
that works fine.

I'd really appreciate a pointer on this.

Thanks.

Mike
.