Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Node.js's crypto.randomBytes() accepts size 0 #1

Open
Mickael-van-der-Beek opened this issue Sep 17, 2014 · 1 comment
Open

Node.js's crypto.randomBytes() accepts size 0 #1

Mickael-van-der-Beek opened this issue Sep 17, 2014 · 1 comment
Labels
Milestone

Comments

@Mickael-van-der-Beek
Copy link

The following code:

var size = 0;
crypto.randomBytes(size, function (e, buffer) {
    if (e) {
        return callback(e);
    }

    callback(e, buffer.toString('hex'));
});

will return an empty (length of 0) SlowBuffer.

This is a bug in Node.js's core module crypto.
The similar crypto.pseudoRandomBytes() method would return the same value.

@Mickael-van-der-Beek Mickael-van-der-Beek added this to the 1.0 milestone Sep 17, 2014
@Mickael-van-der-Beek
Copy link
Author

The following issue:

and it's corresponding commit:

might fix this.

It still needs to be tested though.

Mickael-van-der-Beek pushed a commit that referenced this issue Sep 17, 2014
…e bugs so that the code runs in the expected way.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant