Welcome to the Monastery | |
PerlMonks |
Re: Crypt funby btrott (Parson) |
on Mar 27, 2001 at 02:26 UTC ( [id://67358]=note: print w/replies, xml ) | Need Help?? |
Your get_pubkey function better be returning a Crypt::RSA::Key::Public object. That's a public key object in the
Crypt::RSA world. Because that's the thing you're passing to Crypt::RSA, and that's what it expects. $public_key, in other words, should be an object of type Crypt::RSA::Key::Public. That's why you're getting the "Can't call method n" on $public_key error: because you're probably giving it a string or something, and the string obviously can't support method calls. So what you should be doing is having your get_pubkey return a Crypt::RSA::Key::Public object. How do you do that? Well, you create such an object, then fill it with values. An RSA public key should have two components: n, the RSA modulus; and e, the exponent. This is used when doing public-key encryption on a message. So, in get_pubkey, you can create a public key object: and then fill it the values, which you're apparently getting from *somewhere* (your base64-decoded string?): Perhaps, in your case, $n and $e are in your @fields array. I don't know, because that's specific to your code. Then return $key from your function. Take a look at the source of Crypt::RSA::Key for another example. The generate method generates a set of public and private keys from scratch (finding primes, deriving key attributes, etc.).
In Section
Seekers of Perl Wisdom
|
|