How to deal with a slow SecureRandom generator?

后端 未结 17 1216
时光说笑
时光说笑 2020-11-22 11:56

If you want a cryptographically strong random numbers in Java, you use SecureRandom. Unfortunately, SecureRandom can be very slow. If it uses

17条回答
  •  无人共我
    2020-11-22 12:36

    I faced same issue. After some Googling with the right search terms, I came across this nice article on DigitalOcean.

    haveged is a potential solution without compromising on security.

    I am merely quoting the relevant part from the article here.

    Based on the HAVEGE principle, and previously based on its associated library, haveged allows generating randomness based on variations in code execution time on a processor. Since it's nearly impossible for one piece of code to take the same exact time to execute, even in the same environment on the same hardware, the timing of running a single or multiple programs should be suitable to seed a random source. The haveged implementation seeds your system's random source (usually /dev/random) using differences in your processor's time stamp counter (TSC) after executing a loop repeatedly

    How to install haveged

    Follow the steps in this article. https://www.digitalocean.com/community/tutorials/how-to-setup-additional-entropy-for-cloud-servers-using-haveged

    I have posted it here

提交回复
热议问题