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?
                +2 
                A: 
                
                
              Use the openssl gem
OpenSSL::BN::rand
You can specify the size you need - like so OpenSSL::BN::rand(212)
                  abdollar
                   2010-09-28 23:28:46
                
              Awesome, thanks! Where can I find the documentation on this? I've checked ruby-doc.org but all I can find is stuff on OpenSSL::HMAC and a few others.
                  Jarsen
                   2010-09-29 16:36:23
                Also, is there a function that makes sure it's prime?
                  Jarsen
                   2010-09-29 17:23:31
                Also try OpenSSL::BN::generate_prime(500)
                  abdollar
                   2010-09-29 17:38:14
                in terms of documention look at openssl documentation rather than the gem
                  abdollar
                   2010-09-29 17:38:34
                I cannot see BN_is_prime in the ruby openssl gem. You could file a bug to add that or add that to the gem yourself.
                  abdollar
                   2010-09-29 17:44:04