Yeah, here is a working example. This script shows 2 ways, one is saving the key to a file and reading it back in, the other, just hard codes the file contents into a variable. I tried a few things to avoid a temp file, but no luck. There is a Content type for the write, but it dosn't seem to work for \scalar....it still writes a file.
#!/usr/bin/perl
use warnings;
use strict;
use Crypt::DSA;
use Crypt::DSA::Key;
my $dsa = Crypt::DSA->new;
my $key = $dsa->keygen(Size => 512, Verbosity => 1);
$key->write( Type => 'PEM', Filename => 'zsave');
my $sig_msg = 'yadda yaddax yadda';
#my $key1 = Crypt::DSA::Key->new( Type=>'PEM', Filename => 'zsave' );
#this is the Content of the file zsave
my $pem =
'-----BEGIN DSA PRIVATE KEY-----
MIH3AgEAAkEAuu/8bF0QtFaU8Eo3XzJzyuwyfIEoCvYxzcx5dGkTa7przkVGPaJp
n6uEPIueBQEP21+SmfebPpkbKF98gw+MSwIVAMGFQpGtsAWNedBzQ85p0CkTuKYZ
AkBLciRf48J8u/LYz2FejmaPs88sKPt/mNLLfzOUz6LO0HqjXOq6vD0WzGcek0Z6
VK9JD3r9eyclPNvsArZ7v/LaAkBxM58UjEqschS9r7Je28kCQ4eYC4lhkRq+pAot
/kh86LBlohQZ6A6zgCyPiKNLT5VQ29vKW49f36XjYrIDUk21AhQdRFsMvKVp+W5C
7L7i0FLp3tYb6w==
-----END DSA PRIVATE KEY-----';
my $key1 = Crypt::DSA::Key->new( Type=>'PEM', Content => $pem );
print "$key1\n";
my $sig = $dsa->sign(Message=>$sig_msg, Key => $key1 );
I'm not really a human, but I play one on earth.
flash japh
| [reply] [d/l] |
Well, here is a way to avoid the temp file, not in the docs but it works.
#!/usr/bin/perl
use warnings;
use strict;
use Crypt::DSA;
use Crypt::DSA::Key;
my $dsa = Crypt::DSA->new;
my $key = $dsa->keygen(Size => 512, Verbosity => 1);
my $pem = $key->write( Type => 'PEM');
print "pem-> $pem\n";
my $sig_msg = 'yadda yaddax yadda';
my $key1 = Crypt::DSA::Key->new( Type=>'PEM', Content => $pem );
print "$key1\n";
my $sig = $dsa->sign(Message=>$sig_msg, Key => $key1 );
I'm not really a human, but I play one on earth.
flash japh
| [reply] [d/l] |
| [reply] [d/l] [select] |