Connecting Tech Pros Worldwide Forums | Help | Site Map

RSA Key File Problems in ActivePerl

Newbie
 
Join Date: Jun 2007
Posts: 8
#1: Jun 8 '07
Hi everyone!
I'm working on an RSA project that has to communicate with ASP.NET.

Here's my problem:
I'm following the code here:
http://cpan.uwinnipeg.ca/htdocs/Cryp...Crypt/RSA.html

This code by itself runs fine. However, when I start trying to push out the key to an external file (for later use of course) things start to get a little messy.

Expand|Select|Wrap|Line Numbers
  1. use Crypt::RSA;
  2.  
  3. my $rsa = new Crypt::RSA( ES => 'PKCS1v15' );
  4. my $message = "RSA is FUN!!";
  5. my ($public, $private) = $rsa->keygen(
  6.     Identity    => 'PTSIntranetApplications@<RMed by MOD>',
  7.     Size        => 1024,
  8.     Verbosity    => 0,
  9.     Filename    => 'key',
  10. ) or die $rsa->errstr();
  11.  
This Code by itself works okay too. It's only when I try to encrypt it do I run into to problems (note: this is the next set of code right after above code):
Expand|Select|Wrap|Line Numbers
  1. my $pubKey = new Crypt::RSA::Key::Public( Filename => 'key.public');
  2. my $cyphertext = $rsa->encrypt(
  3.     Message    => $message,
  4.     Key        => $pubKey,
  5.     Armour    => 1,
  6. ) or die $rsa->errstr();
  7.  
I then get this error:
Quote:
n is not p*q.
I realize this is from the "Check" function in the RSA object. However, I'm not doing anything to the keys to screw up their values.

Am I doing something wrong? If so, what am I doing and what can I do to fix this problem?

Thanks for your help!

Michael

***EDIT:

I should also note that when using RSA object without any file export/import, it works perfectly fine.

Newbie
 
Join Date: Jun 2007
Posts: 8
#2: Jun 8 '07

re: RSA Key File Problems in ActivePerl


So apparently: I was wrong for a couple things:

1) the error only occurred in the private key not the public key (stupid me)
2) The error only occurred because I wanted to use 1 key from memory and one key from the file.... Obviously, no one likes that.

So it's fixed. Thanks for checking it out if you did. Hope this helps someone!
miller's Avatar
Moderator
 
Join Date: Oct 2006
Location: San Francisco, CA
Posts: 830
#3: Jun 8 '07

re: RSA Key File Problems in ActivePerl


Kudos.

- Miller

PS
I've removed the email address that you included in your original post so that you do not get any spam.
Newbie
 
Join Date: Jun 2007
Posts: 8
#4: Jun 11 '07

re: RSA Key File Problems in ActivePerl


Thank you! :) I appreciate your help! :)
Reply