#!/usr/bin/perl use strict; use Crypt::RSA; print "RSA tester\n"; my $infoToSign = "blah"; my $privateKey = 5; my $rsa = new Crypt::RSA; my ($public, $private) = $rsa->keygen ( Identity => 'RBSClient', Size => 1024, Password => 'passw0rd', Verbosity => 1, ) or die $rsa->errstr(); $private->write( Filename => 'working.private'); $public->write( Filename => 'working.public'); #### $VAR1 = bless( { 'Version' => '1.99', 'Checked' => 0, 'Identity' => 'RBSClient', 'private_encrypted' => bless( { '_phi' => 'Blowfish du2N7P83ABQ cFDt9/0y7IQ 53616c7465645f5f...', '_n' => 'Blowfish MqmrxVsrrHbWw RNNCruuuw 53616c7465645f5f658f18eec5ea...', '_q' => 'Blowfish qC0F63YxDS8KW LUGDfCMcg 53616c7465645f5f...', '_p' => 'Blowfish sNmIMm9AuxeF8 uhD/JHszA 53616c7465645f5f...', '_dp' => 'Blowfish p2z6NZBV1grw lhJye/R4sw 53616c7465645f5f...', '_u' => 'Blowfish HuhTLQDF0TEzo Ln7exXdiw 53616c7465645f5f...', '_dq' => 'Blowfish Yf/aS7U0nI1U GYvagT4J3A 53616c7465645f5f...', '_d' => 'Blowfish SXEnuMNvxaF2y JFTalOnbQ 53616c7465645f5f...', '_e' => 'Blowfish EzK9HcfPA2zj4 wouO9lMww 53616c7465645f5f...' }, 'Tie::EncryptedHash' ), 'Cipher' => 'Blowfish' }, 'Crypt::RSA::Key::Private' ); #### #!/perl/bin/perl package RBS_PrivateKeyWrapper; use strict; sub getPrivateKey() { my $privateKeyFilename = '/var/www/html/certificates/working.private'; my $privateKey = getPrivateKeyPerlRSAEncoded($privateKeyFilename); return $privateKey; } sub getPrivateKeyPerlRSAEncoded($) { my ($privateKeyFilename) = @_; my $privateKey = new Crypt::RSA::Key::Private( Filename => $privateKeyFilename ); return $privateKey; } 1; #### #!/perl/bin/perl use Crypt::RSA; use RBS_PrivateKeyWrapper; my $privateKey = RBS_PrivateKeyWrapper::getPrivateKey(); my $signature = getSignatures($privateKey, $binarySecurityToken, $timestamp, $content); print $signature; #### sub getSignature($$) { my ($privateKey, $infoToSign) = @_; my $rsa = new Crypt::RSA; my $signatureValue = $rsa->sign( Message => $infoToSign, Key => $privateKey,); return $signatureValue; } #### [Mon Oct 26 21:15:33 2009] [error] [client 10.29.12.38] PARI: *** log is not meromorphic at 0. at /usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi/Mat h/Pari.pm line 994. #### sub bitsize ($) { return pari2num(floor(Math::Pari::log(shift)/Matth::Pari::log(2)) + 1); } #### sub AUTOLOAD { $AUTOLOAD =~ /^(?:Math::Pari::)?(.*)/; # warn "Autoloading $1...\n"; # exit 4 if $1 eq 'loadPari'; my $cv = loadPari($1); # goto &$cv; # goto &$AUTOLOAD; # &$cv; &$1; # &$AUTOLOAD; }