GithubHelp home page GithubHelp logo

fortuna's Introduction

Fortuna

This is an implementation of the Fortuna PRNG, read more at wikipedia or in the book Cryptographic Engineering by Bruce Schneier.

Usage

Add it as a maven dependency

<dependency>
    <groupId>com.grunka.random.fortuna</groupId>
    <artifactId>fortuna</artifactId>
    <version>2.2</version>
</dependency>

or clone and build (nothing more than mvn install is needed) and add to classpath.

Due to reasons there are a couple of ways to create an instance. Either the constructor or the methods createInstance on com.grunka.random.fortuna.Fortuna. Both of these ways create a subclass of Javas own Random class so this can be used wherever that would be used. The instance created should be reused. It is thread safe, creation time is noticeable, and you do not gain anything by recreating it. Due to the background threads collecting entropy running continuously you should call shutdown on the instance if you will actually not use the instance anymore.

There is an included runnable class for outputting random data for testing purposes. com.grunka.random.fortuna.Dump. Dump outputs a specified number of megabytes of random data that can be used in other tools that analyze random data.

Details

For specifics either read the book referenced above and have a look at the code. Below are some descriptions of the specific choices taken for this implementation.

Block cipher

The block cipher used is a public domain implementation of AES-256, in the code it uses the original name Rijndael. The reason for not using Javas own implementation is to avoid the system configuration changes needed to be allowed to use it since Java in its default configuration only allows up to 128-bit keys.

Entropy sources

For entropy sources I've selected several system dependant sources that are available to the Java runtime. In the current version there are nine sources. For most of the values only the two least significant bytes are used which ensures that the values are fairly unpredictable even though they are polled often.

fortuna's People

Contributors

chrisnew avatar dependabot[bot] avatar grunka avatar svendiedrichsen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fortuna's Issues

Prefered way to build jar file

Hi, more of a question, whats the prefered way to build te jar?
Becuase at the moment I'm using a nodejs fortuna as a rest service to generate random integers.

Thanks

[RFE] Turn this lib into an OSGI module

To allow this library to be usable in an OSGI environment turn it into a module containing the proper OSGI meta data. You could use the BND maven plugin for this.

Java heap space on .ints()

Something like

fortuna.ints(game.getNumbermin(), game.getNumbermax()).boxed().collect(Collectors.toList())

cause a Java Heap Space error

at java.util.Arrays.copyOf(Arrays.java:3181) ~[na:1.8.0_172] at java.util.ArrayList.grow(ArrayList.java:265) ~[na:1.8.0_172] at java.util.ArrayList.ensureExplicitCapacity(ArrayList.java:239) ~[na:1.8.0_172] at java.util.ArrayList.ensureCapacityInternal(ArrayList.java:231) ~[na:1.8.0_172] at java.util.ArrayList.add(ArrayList.java:462) ~[na:1.8.0_172] at java.util.stream.Collectors$$Lambda$26/830048777.accept(Unknown Source) ~[na:na] at java.util.stream.ReduceOps$3ReducingSink.accept(ReduceOps.java:169) ~[na:1.8.0_172] at java.util.stream.IntPipeline$4$1.accept(IntPipeline.java:250) ~[na:1.8.0_172] at java.util.Random$RandomIntsSpliterator.forEachRemaining(Random.java:1044) ~[na:1.8.0_172] at java.util.Spliterator$OfInt.forEachRemaining(Spliterator.java:693) ~[na:1.8.0_172] at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481) ~[na:1.8.0_172] at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471) ~[na:1.8.0_172] at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708) ~[na:1.8.0_172] at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) ~[na:1.8.0_172] at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:499) ~[na:1.8.0_172]

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.