Hi Jo,
Thanks very much for your assistance. I agree that that docs leave some room for development. I think I did read somewhere that check_key only checks for the presence of the various parameters. I think I discarded that from my mind, as it didn't make a lot of sense. I can see if I included the parameters or not, I don't think I need a function to tell me. Nevertheless, I made the changes that you suggested and the check_key function now returns true.
The next thing that I tried to do was to append the following to the code:
my $buf = 't'; $cipher = $rsa->encrypt($buf);
The returned the following error: "RSA.xs:227: OpenSSL error: data too large for key size at ./rsa.pl line 37."
I understand that for RSA to work, the input has to be less than the key. Given that they key reports to be 319 bits, it's hard to see how $buf = 't' pushes it over the edge, regardless of how it's encoded. I've tried to find some code examples of Crypt:Openssl::RSA but they are very hard to come by. A lot of them read the data from a file, so I had a go at that too:
open(my $fd, '<:raw', 'test') or die("Failed to open file: $!"); binmode($fd); read($fd, my $buf, 4); close($fd);
That yielded the same error. It's not clear how data should be passed to $rsa->encrypt. The manual seems to say "binary string" (their quotes). I tried dumping the public and private keys using get_public_key_string and get_private_key_string and then using them to encrypt and decrypt some arbitary ("test") data with the openssl command and that worked just fine, so I think the keys must be good
I am also starting to wonder if it would be easier to do the decryption maths myself with use bignum; or if I'm just opening an even bigger can of worms?
Any advise would be gratefully receieved.
Thanks,In reply to Re: Importing keys into Crypt::Openssl::RSA
by BOfH
in thread Importing keys into Crypt::Openssl::RSA
by BOfH
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |