Thanks and with respect to the users of this site, I've succeeded in creating an Encryption/Decryption procedure for the RSA algorithm.
I also implemented a Miller-Rabin probabilistic primality test.
Now my question is much simpler, but my head really cannot make up an answer.
Suppose I need a key of length
1024, and I've generated two primes, each
512 bits worth. But their product won't necessarily be
1024-bit long, it may be smaller.
What should I do in this case? Discard the primes and try again? Is there a smarter solution?
Thank you very much!
============ UPDATE ===================
Thanks to jug and Gadi A, I've managed to learn that for binary numbers, setting two most significant bits to 1 is enough to gen desired bit-length.
Another challenge is that in my library big numbers may have arbitrary digit base;
So the actual structure is
a_0 mod BASE | a_1 mod BASE | ... | a_(n-1) mod BASE.
What should I do in order to get a key of
n digits length, where all digits have numeric base