• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

Java 8 FIPS 140-2 compliant random number generator

 
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Marshal
Posts: 5562
326
IntelliJ IDE Python Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Marshal
Posts: 5562
326
IntelliJ IDE Python Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Marshal
Posts: 5562
326
IntelliJ IDE Python Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Whose rules are you playing by? This tiny ad doesn't respect those rules:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic