I'm trying to integrate RSA encryption and signing into a couple of
Perl programs on Windows, using Crypt::RSA. I have no problem
generating keys and using them immediately for encryption, decryption,
signing, and verification. My problems have been with storing the
keys I've created for later use... kind of crucial to actually
building a working cryptosystem.
The solution would seem to be based on Crypt::RSA::Key::Public and
::Private, with their write() methods. But, no matter how I've tried
using those classes, the objects I get are just not working. When I
write() either type of key (public or private) to a file and then look
at that file in a text editor, all I see is what looks some
Data::Dumper output of the key objects -- and it's even incomplete,
not listing all of the data that I know is there:
$VAR1 = bless( { # This is what's written to file for a public key
'Version' => '1.91'
}, 'Crypt::RSA::Key::Public' );
$VAR1 = bless( { # This is what's written to file for a private key
'Version' => '1.91',
'Identity' => 'Foo Bar <[EMAIL PROTECTED]>',
'private_encrypted' => bless( {},
'Tie::EncryptedHash' ),
'Cipher' => 'Blowfish'
}, 'Crypt::RSA::Key::Private' );
When I read those files back into my program and try to use them for
the usual things (encryption, decryption, etc.) it fails, stating the
obvious: Incomplete key.
My suspicion is that the ::Key::Private and Key::Public objects are
not getting tied correctly to the keys I've generated, so that the
written files don't have the actual key data. But I can see no way to
do this... the module documentation certainly says nothing about it.
Here's one of the ways I've tried to make it work, stripped down to
its basics:
my $rsa_obj = Crypt::RSA->new();
my ( $pb, $pv ) = $rsa_obj->keygen(
Identity => $id,
Password => $pk,
Size => $sz,
Verbosity => $vb,
);
my $file_public = Crypt::RSA::Key::Public->new();
$file_public->write( Filename => 'test.public.txt' );
my $file_private = Crypt::RSA::Key::Private->new(
Identity => $id,
Password => $pk,
Cipher => $cp,
);
$file_private->write( Filename => 'test.private.txt' );
There is obviously no connection here between the generated keys and
the management objects, but I can't figure out how to connect them so
that the keys actually get written correctly to file. Should I be
trying to use inheritance to do the keygen() thing to the
::Key::Private and ::Key::Public objects? But those seem to be two
separate things when the keys must be generated as a pair. I'm so
confused! :O
Please help,
-Brian
ps- It would be really nice if there was an "Armour" option for the
keys, so that I wasn't dealing with Data::Dumper format; there is such
an option for encryption and signing output, works quite nicely. Of
course, if I could just get the write() thing to work I could roll my
own text encoding.
_________________________
Brian H. Oak CISSP CISA
Acorn Networks & Security
<http://acornnetsec.com/>
_______________________________________________
Perl-Win32-Users mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs