D
Dani Pardo
Hi, I'm trying to encrypt some data with an RSA public key, this is
the code which is failing:
------------------------------------
require 'openssl'
f=File.open('public_key.txt')
rsa = OpenSSL:Key::RSA
rsa.n = OpenSSL::BN.new f.gets
rsa.e = OpenSSL::BN.new f.gets
encrypted_data = rsa.public_encrypt('Hi')
puts "Size: " + encrypted_data.size.to_s
------------------------------------
In Windows, using ruby-1.8.6, I says that the size of the encrypted
data is 51 bytes, where in reality the encrypted data should be 64
bytes.
In Linux, using ruby-1.8.5, the same code just gives an error:
$ ruby test.rb
test.rb:9:in `public_encrypt': no inverse (OpenSSL:Key::RSAError)
from test.rb:9
I'm stunned.. I've even checked ossl_pkey_rsa.c and I haven't seen
anything wrong. Any help appreciated.
the code which is failing:
------------------------------------
require 'openssl'
f=File.open('public_key.txt')
rsa = OpenSSL:Key::RSA
rsa.n = OpenSSL::BN.new f.gets
rsa.e = OpenSSL::BN.new f.gets
encrypted_data = rsa.public_encrypt('Hi')
puts "Size: " + encrypted_data.size.to_s
------------------------------------
In Windows, using ruby-1.8.6, I says that the size of the encrypted
data is 51 bytes, where in reality the encrypted data should be 64
bytes.
In Linux, using ruby-1.8.5, the same code just gives an error:
$ ruby test.rb
test.rb:9:in `public_encrypt': no inverse (OpenSSL:Key::RSAError)
from test.rb:9
I'm stunned.. I've even checked ossl_pkey_rsa.c and I haven't seen
anything wrong. Any help appreciated.