From: _Stud Date: 2007-11-27T20:50:03+09:00 Subject: Problems with OpenSSL => RSA To understand why I wrote the following code, I wanted to ensure confidentiality by encrypting some information. I also wanted to maintain non-reputability by encrypting the string with the senders private RSA key. In this configuration, the string is first encrypted with Alice's private key and then Bob's public key. To decrypt, Bob is the only one who can decrypt the data, and he knows the data came from Alice because her public RSA key is also needed. It doesn't work :-( The error message doesn't make sense to me, so I'm hoping someone can enlighten me. Maybe I'm not using the libraries correctly. Thanks for the help. /-------------------------------------------------------------------------------------/ $stdout = $stderr = File.new("RSA.log","w") priv_alice= OpenSSL::PKey::RSA.new(1024) pub_alice = priv_alice.public_key priv_bob = OpenSSL::PKey::RSA.new(1024) pub_bob = priv_bob.public_key string = "Ruby rocks!" encrypted1 = priv_alice.private_encrypt(string) encrypted2 = pub_bob.public_encrypt(encrypted1) decrypted2 = priv_bob.private_decrypt(encrypted2) decrypted1 = pub_alice.public_decrypt(decrypted2) puts decrypted1 /-------------------------------------------------------------------------------------/ RSA.rb:13:in `public_encrypt': data too large for key size (OpenSSL::PKey::RSAError) from RSA.rb:13