Page 1 of 1
RSA Encryption
Posted: Fri Sep 14, 2007 4:40 am
by devendra-m
when I choose small values of p and q then it becomes very easy to find p and q from n. And when I choose large values of p and q then the calculation becomes so huge that even bc math cannot handle the values. Is there any simple way to implement RSA.
Posted: Fri Sep 14, 2007 5:05 am
by stereofrog
I's suggest using built-in functions (mcrypt or openssl) for cryptography.
Posted: Fri Sep 14, 2007 5:42 am
by devendra-m
But I need public key encryption method. Because I have to encrypt username and password before passing it to the server
Posted: Fri Sep 14, 2007 8:18 am
by Begby
Can't you connect over https?
You can always use PGP too if you really need to use public key encryption.
Posted: Fri Sep 14, 2007 10:39 pm
by feyd
bc math can handle those values. I've used it to calculate values well into hundreds of hundreds of places.
Posted: Sat Sep 15, 2007 2:29 am
by volka
devendra-m wrote:But I need public key encryption method. Because I have to encrypt username and password before passing it to the server
isn't that supposed to be a strong suit of openssl?
Posted: Mon Sep 17, 2007 1:40 am
by devendra-m
when i try to calculate pow(3434,45435435) the server takes too much time and apparently just hangs. In this case I am not being able to calculate large values which is a must for RSA. I have implemented RSA with small values of p and q which is obviously not secured but I am not being able to take large values like 768 bits which is secured.
Posted: Mon Sep 17, 2007 7:18 am
by Begby
didja look at bcmath as was suggested? Are you reading any of these replies?
Posted: Mon Sep 17, 2007 11:30 pm
by devendra-m
I am reading replies but you are understanding my problem, my problem is not about calculation, my problem is bcpow(large values,large values) takes so much time that you can have a cup of coffee at that time. In that case how can I implement RSA.
Posted: Tue Sep 18, 2007 7:10 am
by feyd
As with all large computations it is often beneficial to have the values precalculated if at all possible.
Posted: Wed Sep 19, 2007 1:23 pm
by GloriousEremite
If memory serves, you don't really need to calculate any huge exponentials when applying RSA because the operations are done modulo some other number. Maybe
bcpowmod would do the trick? Also see
http://en.wikipedia.org/wiki/Exponentiation_by_squaring
Posted: Fri Sep 21, 2007 3:56 am
by devendra-m
thank you all for your time. My problem of calculation has been solved. I have found the algorithm which can calculate the power modulo of 1024 bits number in a minute.
Posted: Fri Sep 21, 2007 12:30 pm
by John Cartwright
devendra-m wrote:thank you all for your time. My problem of calculation has been solved. I have found the algorithm which can calculate the power modulo of 1024 bits number in a minute.
Care to share?