Cipher.getInstance is too slow
Asked Answered
M

1

0

I have the following line of code that is taking less than a second on my computer (windows 7) and about 20 seconds on a Redhat server :

Cipher cipher = Cipher.getInstance(TRANSFORMATION);

where TRANSFORMATION is defind as :

private static final String TRANSFORMATION = "Blowfish/ECB/PKCS5Padding";

What could be the source of such behaviour ?

Thanks.

Misshape answered 13/2, 2014 at 14:56 Comment(0)
G
1

Initialization of the Bouncy Castle provider and - probably - a slow /dev/random.

Giza answered 13/2, 2014 at 15:4 Comment(5)
Thanks for the quick answer, but I don't want you to be mislead by the mention of redhat and windows because I have also tested on another redhat and it is taking less than a second too.Misshape
A different CPU (e.g. a newer Intel) can already change the characteristics of /dev/random, so take a look at that.Giza
In the case that /dev/random is slow what can I do about it ?Misshape
Check which applications use /dev/random and where possible switch them over to /dev/urandom. Or add devices that generate entropy for /dev/random. I had a similar issue on Ubuntu with a Java application. I'll check if there is an easy solution targeting Java. BTW you can easily check the speed of /dev/random by simply reading bytes from it (using dd command). Note that it should be a bit slow.Giza
Its also happening in eclipse too. What can I do to fast it up?Cinnabar

© 2022 - 2024 — McMap. All rights reserved.