Original Post
I've decided to use RSA as the asymmetric encryption system for my network engine (Along with Blowfish or possibly AES for the symmetric side) and I'm looking for help doing some optimizations for my implementation. Currently it takes a rather large amount of time to generate 1024 bit keys (I'm not how long on average, because I haven't ran it for very long), and an average of about 6 seconds to generate a 512 bit key. This is way longer than it should be, and I'm not sure why. Here's the code as of June 23 http://nick.weihs.googlepages.com/rsa.zip The bulk of the implementation is put into the large integer class. I have the 4 standard arithmetic ops as well as left/right shifting. I'm using the square and multiply method for modular exponentiation: http://en.wikipedia.org/wiki/Modular_exponentiation I'm using the Rabin-Miller test for primality testing (as well as testing the first 70 or so primes initially): http://en.wikipedia.org/wiki/Miller-Rabin The method I'm using for sampling prime numbers is to generate a random number, multiply by 6 and add 1. This is the main area that I'm looking for improvement in, since it is such a naive method. Any advice/comments are useful.