Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a perl implementation of SHA256withRSA

I need to be able to craft JSON Web Token signatures (which only accepts 'RSASSA-PKCS1-V1_5-SIGN with the SHA-256 hash function' signatures), but the obvious CPAN contender for this task (Crypt::RSA) will only generate signatures using MD2, MD5 or SHA1.

Is there another library somewhere that will do what I want? If necessary I should be able to do a bit of hacking to get there, but that wouldn't be too pretty.

like image 768
Cebjyre Avatar asked Aug 27 '12 12:08

Cebjyre


1 Answers

I was able to find a module that did what I wanted: Crypt::OpenSSL::RSA

my $rsa = Crypt::OpenSSL::RSA->new_private_key($key);
$rsa->use_sha256_hash;
my $signature = $rsa->sign($message);

So much easier than extending Crypt::RSA, but it was oddly kind of difficult to find.

like image 160
Cebjyre Avatar answered Oct 11 '22 16:10

Cebjyre