From: Dani Pardo Date: 2008-10-17T19:54:48+09:00 Subject: RSA public_encrypt bug? 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::PKey::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::PKey::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. -- Dani.