Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 RSA encryption algorithms
Index -> General Programming
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Dratino




PostPosted: Wed Nov 09, 2011 10:28 am   Post subject: RSA encryption algorithms

I wrote a program to generate pairs of RSA keys the other day in Python, but it seems incredibly inefficient (it usually takes about 2-3 seconds to generate a 512-bit key, and 6-10 seconds to generate a 1024-bit key).

However, it's not so much the keypair generation that I'm worried about, but the time it takes to encrypt a message. Even using an "exponentiation by squaring" algorithm, it takes my laptop about 0.054 seconds to encrypt a 1024-bit message. Is there something I'm doing wrong, or do I just have a really crummy laptop? (Or, does RSA really just take that long to encrypt stuff. It could be the case that I'm worried about nothing.)
Sponsor
Sponsor
Sponsor
sponsor
Insectoid




PostPosted: Wed Nov 09, 2011 11:02 am   Post subject: RE:RSA encryption algorithms

If you look on the RSA website, you'll find that "With the typical modular exponentiation algorithms used to implement the RSA algorithm, public key operations take O(k^2) steps, private key operations take O(k^3) steps, and key generation takes O(k^4) steps, where k is the number of bits in the modulus."

I dunno how big your modulus is, but O(K^4) gets very slow, very quickly.
Brightguy




PostPosted: Wed Nov 09, 2011 11:47 am   Post subject: Re: RSA encryption algorithms

Dratino @ Wed Nov 09, 2011 10:28 am wrote:
Even using an "exponentiation by squaring" algorithm, it takes my laptop about 0.054 seconds to encrypt a 1024-bit message.

This might just be the python overhead. But encryption should be the fastest RSA operation, assuming you take your public key exponent to be O(1). If you use fast multiplication, you can encrypt messages in nearly linear time.
Display posts from previous:   
   Index -> General Programming
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 3 Posts ]
Jump to:   


Style:  
Search: