Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: GnuPG: gcrypt

RSA Key Gen: Fast in Test App, Slow in Real App.

 

 

GnuPG gcrypt RSS feed   Index | Next | Previous | View Threaded


spizamme at hotmail

Sep 18, 2006, 7:35 PM

Post #1 of 6 (4364 views)
Permalink
RSA Key Gen: Fast in Test App, Slow in Real App.

I made a test app to test RSA key generation and whatnot using gcrypt
directly. Generating a 128bit key pair is almost instant in the test app.
It takes less than a second. When I try using it in my real application (a
game), however, it takes several seconds to generate the key. The libraries
and function calls are identical. Any idea what the causes for the speed
differences are? I'm using Visual Studio 7.0 on Windows XP. I'm not using
secure memory or multithreading.
--
View this message in context: http://www.nabble.com/RSA-Key-Gen%3A-Fast-in-Test-App%2C-Slow-in-Real-App.-tf2296684.html#a6380989
Sent from the GnuPG - Libgcrypt - Dev mailing list archive at Nabble.com.


_______________________________________________
Gcrypt-devel mailing list
Gcrypt-devel [at] gnupg
http://lists.gnupg.org/mailman/listinfo/gcrypt-devel


bradh at frogmouth

Oct 1, 2006, 5:20 PM

Post #2 of 6 (4194 views)
Permalink
Re: RSA Key Gen: Fast in Test App, Slow in Real App. [In reply to]

On Tuesday 19 September 2006 12:35, jitspoe wrote:
> I made a test app to test RSA key generation and whatnot using gcrypt
> directly. Generating a 128bit key pair is almost instant in the test app.
> It takes less than a second. When I try using it in my real application (a
> game), however, it takes several seconds to generate the key. The
> libraries and function calls are identical. Any idea what the causes for
> the speed differences are? I'm using Visual Studio 7.0 on Windows XP. I'm
> not using secure memory or multithreading.
On the face of it, you are doing something different between your test
application and the real application. Try cutting down a copy of your real
application towards your test application.

You really haven't provided enough information to say more. However generating
RSA keys "instantly" sounds a bit suspicious - perhaps you should review your
code again.

Brad


spizamme at hotmail

Oct 4, 2006, 7:52 PM

Post #3 of 6 (4164 views)
Permalink
Re: RSA Key Gen: Fast in Test App, Slow in Real App. [In reply to]

Brad Hards wrote:
>
> On the face of it, you are doing something different between your test
> application and the real application. Try cutting down a copy of your real
> application towards your test application.
>
> You really haven't provided enough information to say more. However
> generating
> RSA keys "instantly" sounds a bit suspicious - perhaps you should review
> your
> code again.
>
> Brad
>

Thanks for the reply. Sorry if I didn't elaborate enough. The test code
and the application code are identical. The only difference is that one is
standalone, just for testing the functions, and the other is embedded into
my application. The same gcrypt functions are called and in the same order.
All I'm doing is generating a 128bit RSA key pair. I can post the source
code if you're interested. Once the first RSA key has been generated,
generating another is almost instant, so I'm guessing it's initializing some
kind of prime table. I haven't delved into the gcrypt code to find out.
--
View this message in context: http://www.nabble.com/RSA-Key-Gen%3A-Fast-in-Test-App%2C-Slow-in-Real-App.-tf2296684.html#a6651937
Sent from the GnuPG - Libgcrypt - Dev mailing list archive at Nabble.com.


_______________________________________________
Gcrypt-devel mailing list
Gcrypt-devel [at] gnupg
http://lists.gnupg.org/mailman/listinfo/gcrypt-devel


wk at gnupg

Oct 5, 2006, 2:11 AM

Post #4 of 6 (4186 views)
Permalink
Re: RSA Key Gen: Fast in Test App, Slow in Real App. [In reply to]

On Thu, 5 Oct 2006 04:52, jitspoe said:

> All I'm doing is generating a 128bit RSA key pair. I can post the source
> code if you're interested. Once the first RSA key has been generated,
> generating another is almost instant, so I'm guessing it's initializing some
> kind of prime table. I haven't delved into the gcrypt code to find out.

That is because the entropy pool of the RNG has been filled and the
second key utilizes the left over entropy. Make sure to properly
setup the RNG.

BTW, a 128 bit RSA key is pretty useless except for learning how to
break it.


Salam-Shalom,

Werner


_______________________________________________
Gcrypt-devel mailing list
Gcrypt-devel [at] gnupg
http://lists.gnupg.org/mailman/listinfo/gcrypt-devel


spizamme at hotmail

Oct 6, 2006, 12:56 PM

Post #5 of 6 (4151 views)
Permalink
Re: RSA Key Gen: Fast in Test App, Slow in Real App. [In reply to]

Werner Koch wrote:
>
> That is because the entropy pool of the RNG has been filled and the
> second key utilizes the left over entropy. Make sure to properly
> setup the RNG.
>
> BTW, a 128 bit RSA key is pretty useless except for learning how to
> break it.
>
>
> Salam-Shalom,
>
> Werner
>

Thanks for the reply. I'm aware that 128bit RSA isn't very powerful, but in
the way I was planning to use it, it didn't need to be. I'm just sending a
single random string for verification purposes. I actually realized that
RSA wasn't even necessary and just went with some simple hashing instead,
but I'm still curious about the key generation time.

Is there any documentation on how to set up the RNG? What do I need to
call? gcry_fast_random_poll()? I couldn't find anything else that looked
like an initialization function.
--
View this message in context: http://www.nabble.com/RSA-Key-Gen%3A-Fast-in-Test-App%2C-Slow-in-Real-App.-tf2296684.html#a6686275
Sent from the GnuPG - Libgcrypt - Dev mailing list archive at Nabble.com.


_______________________________________________
Gcrypt-devel mailing list
Gcrypt-devel [at] gnupg
http://lists.gnupg.org/mailman/listinfo/gcrypt-devel


spizamme at hotmail

Nov 29, 2006, 10:33 PM

Post #6 of 6 (4041 views)
Permalink
Re: RSA Key Gen: Fast in Test App, Slow in Real App. [In reply to]

You were correct about it being the RNG. I found that simply calling
gcry_randomize() paused for several seconds. The slow_gatherer_windowsNT()
function seems to be the culprit. More specifically, the
RegQueryValueEx(HKEY_PERFORMANCE_DATA, "Global", NULL, NULL, (LPBYTE)
pPerfData, &dwSize); call. I guess the console app didn't use this for
whatever reason? Any suggestions on how I would improve this performance?
Looking through the code, the only way I see to do it would be to create a
seed file.
--
View this message in context: http://www.nabble.com/RSA-Key-Gen%3A-Fast-in-Test-App%2C-Slow-in-Real-App.-tf2296684.html#a7614339
Sent from the GnuPG - Libgcrypt - Dev mailing list archive at Nabble.com.


_______________________________________________
Gcrypt-devel mailing list
Gcrypt-devel [at] gnupg
http://lists.gnupg.org/mailman/listinfo/gcrypt-devel

GnuPG gcrypt RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.