Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Generating Large Prime Numbers for Diffie-Hellman in Ruby

I'm writing an implementation of a diffie-hellman key exchange in ruby for a project for one of my university classes. I need to generate large (secure) prime numbers of at least 500 bits length. Any ideas? Should I use the OpenSSL library? If so, what functions would you recommend?

like image 355
Jarsen Avatar asked Nov 05 '22 08:11

Jarsen


1 Answers

Use the openssl gem

OpenSSL::BN::rand

You can specify the size you need - like so OpenSSL::BN::rand(212)

like image 192
abdollar Avatar answered Nov 15 '22 12:11

abdollar