Sawyer Charles
Sawyer Charles

Reputation: 126

Ruby error "bignum too big to convert into long"

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

Upvotes: 0

Views: 947

Answers (1)

Sawyer Charles
Sawyer Charles

Reputation: 126

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)

Upvotes: 1

Related Questions