Code Monkey home page Code Monkey logo

seedspring's People

Contributors

paragonie-scott avatar paragonie-security 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  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

seedspring's Issues

PHP8 Support?

Hello,

First of all, thanks for this great library.

I recently noticed that master contains some changes that have not been tagged yet, including the changes on composer.json#L18, which removes the restriction from PHP ^5.6.0|^7.0.0 and replaces with >= 5.6. Therefore, making it compatible with PHP8 and PHP8.1.

Would it be possible for you to release a new 1.2.0 tag containing this changes?

Thank you in advance for your consideration

Nonce doesn't change when generating small random integers

When generating integers within a small range (less than 64), the nonce for the getBytes function doesn't change, thus the generation tends to fail often (since it repeatedly generates the same int, which may not be in the desired range).

Example faulty behavior:

$prng = new \ParagonIE\SeedSpring\SeedSpring('JuxJ1XLnBKk7gPAS');
$int = $prng->getInt(0,19);

PHP Fatal error: Uncaught Exception: RNG is broken - too many rejections in .../src/SeedSpring.php:176

$prng = new \ParagonIE\SeedSpring\SeedSpring('JuxJ1XLnBKk7gPAS');
$int = $prng->getInt(0,20);

PHP Fatal error: Uncaught Exception: RNG is broken - too many rejections in .../src/SeedSpring.php:176

etc.

The reason for this is the following: getNonce gets the number random bytes to be generated in the $increment parameter. It then uses this parameter to increase the internal counter the following way:

$incr = (int) \floor(($increment + ($increment % 16)) / 16);
$this->counter += $incr;

Obvously, when this parameter is $increment==1 (as it is, in the cases above), the counter doesn't get incresed ($incr == 0).

Question: what is the reasoning behind the way the counter is increased right now? Wouldn't

$this->counter+=1

be theoretically sufficient?

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.