0

I'm trying to generate an RSA keypair in ruby with:

OpenSSL::PKey::RSA.generate(aReallyLongBignum, 65537)

but I am getting the following error:

bignum too big to convert into long

However it works in python using RSA.construct. Is there any way for this to work in ruby? I've looked everywhere. Really lost here. I am not trying to only take a section of this number at a time, I need to be able to pass the whole number to RSA.generate

  • @jww this is not a duplicate, that question is regarding operating on only part of a long number in a string, I need to pass the whole number in one peice – Sawyer Charles Jul 22 '16 at 13:58
  • OK, taking your word on it. Sorry about that. Please *Edit* the question, and provide more code. ***`aReallyLongBignum`*** needs to be fully specified with a sample value. (Origianl dup citation: [RangeError: bignum too big to convert into `long'](http://stackoverflow.com/q/10024212)). – jww Jul 22 '16 at 21:39

1 Answers1

1

I was able to solve this using OpenSSL::BN and setting it after creating an instance of OpenSSL::Pkey::RSA

key   = OpenSSL::PKey::RSA.new
key.e = OpenSSL::BN.new(65537)
key.n = OpenSSL::BN.new(aReallyLongBignum)