• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
  • Knute Snortum
Sheriffs:
  • Liutauras Vilda
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Joe Ess
  • salvin francis
  • fred rosenberger

Java 8 FIPS 140-2 compliant random number generator

 
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need to write a random number generator that uses an algorithm that is FIPS 140-2 compliant/certified. I am having a tough time finding anything that will work for me. Anyone done this before?

Using Java 8. Development environment is Mac OSX and servers are CentOs 7.
 
Sheriff
Posts: 4720
309
IntelliJ IDE Python Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why write your own when one is already available in the Java standard library? SecureRandom
 
Adrian Enns
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't think the numbers generated are random enough using the Sun cryptography algorithms available. None of the algorithms are FIPS 140-2 certified. I definitely would like to define my API using SecureRandom or with an implementation of SecureRandom, I'm not planning on reinventing the wheel there.
 
Tim Cooke
Sheriff
Posts: 4720
309
IntelliJ IDE Python Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From the first line of SecureRandom JavaDoc

SecureRandom JavaDoc wrote:
This class provides a cryptographically strong random number generator (RNG).

A cryptographically strong random number minimally complies with the statistical random number generator tests specified in FIPS 140-2


Is that not what you're looking for?
 
Adrian Enns
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I might have missed that. I should be good then. Is there any algorithm better than others? Or should this be enough? SecureRandom rand = SecureRandom.getInstance("SHA1PRNG", "SUN");
 
Tim Cooke
Sheriff
Posts: 4720
309
IntelliJ IDE Python Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I couldn't say if there are better or worse algorithms out there, I'm sure there are. I do know that you would be wise to avoid the Random library if robust randomness is required, as is your case. It has been found to be fairly easy to predict upcoming values given a sequence of previous generated values.
 
You guys haven't done this much, have ya? I suggest you study this tiny ad:
Sauce Labs - World's Largest Continuous Testing Cloud for Websites and Mobile Apps
https://coderanch.com/t/722574/Sauce-Labs-World-Largest-Continuous
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!