I'm unable to verify a PSS-signed signature in Perl using Crypt::RSA and Crypt::RSA::SS::PSS.
Here's the situation:
I have a device that has a 1024-bit RSA key, and signs data using PSS, SHA1 and AES-128.
I extract the device's public key successfully, save it in a file with PEM_write_RSA_PUBKEY()
I am able to verify this in C/C++ using RSA_verify_PKCS1_PSS(), and also using openssl on the command line, like this:
echo -n hello | openssl dgst -verify pubkey.pem -signature hello.sig -sha1 \ -sigopt rsa_padding_mode:pss -sigopt rsa_pss_saltlen:20
Where:
I'm trying to do the above in Perl, using Crypt::RSA and Crypt::RSA::SS::PSS, and can't get it to work.
I've tested those two modules and I *am* able to generate and verify a PSS signature in Perl when generating my own key, like this:
So, instead of creating my own RSA key I read in a public key using something like this:#### use Crypt::RSA; use Crypt::RSA::SS::PSS; my ($message, $rsa, $pss, $signature, $verify); my ($public, $private); # The message to be encrypted # $message = "hello"; # Generate RSA key # $rsa = new Crypt::RSA; ($public, $private) = $rsa->keygen( Size => 1024, Filename => "key" ); # Generate PSS signature # $pss = new Crypt::RSA::SS::PSS; $signature = $pss->sign ( Message => $message, Key => $private ) || die $pss->errstr; $verify = $pss->verify ( Message => $message, Key => $public, Signature => $signature) || die $pss->errstr; # $verify returns true, it worked. ####
Where "key.public" contains the device's public key, converted to a decimal string, inserted into the "n" field of the structure that is read/written by Crypt::RSA::Key::Public.#### $publicKey = new Crypt::RSA::Key::Public (Filename => "key.public"); …. # I pack the 256 character (128 byte) hex string of the signature # that's generated by the device. $signature = pack ("H*", '03808458…..73E92'); ####
But I can't get it to verify :-(
Methinks I should be able to indicate that it should be using SHA1 and AES-128 (as opposed to, say, Blowfish). Am I barking up the wrong tree?
Thanks….
In reply to Help verifying RSA PSS signature in Perl with Crypt::RSA and Crypt::RSA::SS::PSS by cryptques
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |