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

Deprecate mixed async crypto #2170

Closed
wants to merge 1 commit into from
Closed

Deprecate mixed async crypto #2170

wants to merge 1 commit into from

Conversation

jonathanong
Copy link
Contributor

deprecates async usage of .randomBytes()

@Fishrock123 Fishrock123 added the semver-minor PRs that contain new features and should be released in the next minor version. label Jul 12, 2015
@Fishrock123
Copy link
Contributor

Possibly waiting on #1704

@mscdex mscdex added the crypto Issues and PRs related to the crypto subsystem. label Jul 12, 2015
@silverwind
Copy link
Contributor

@thefourtheye you had a suggestion about the deprecation rewrite, but I can't seem to find it in the mess that is #632. Could you elaborate again?

exports.rngSync = randomBytes;
exports.prng = util.deprecate(randomBytes,
'`crypto.prng()` is deprecated. ' +
'Please use `crypto.rng()` instead.');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably point to crypto.rngSync.

@jonathanong
Copy link
Contributor Author

updated with just the patch. running the tests locally right now

@jonathanong
Copy link
Contributor Author

shouldn't it say, "used asynchronously"?

@jonathanong
Copy link
Contributor Author

your patch gave me lint errors :(

@thefourtheye
Copy link
Contributor

Sorry about that :(

@silverwind
Copy link
Contributor

shouldn't it say, "used asynchronously"?

Yes, definitely more grammatically correct than "used as async", which makes no sense at all.

exports.randomBytes = exports.pseudoRandomBytes = randomBytes;
exports.randomBytes = exports.pseudoRandomBytes = function(size, callback) {
const warning = 'randomBytes used as async is deprecated. ' +
'Use randomBytesSync instead.';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wait... i'm confused now. i don't see a randomBytesSync() function - I think I added that before but it's no longer relevant. removing this line.

@silverwind
Copy link
Contributor

Linking #5 and #632.

So you went with not renaming the sync methods to randomBytesSync after all? Doesn't that somewhat contradict what you said in #5? What do we gain by just the deprecating the async usage?

@jonathanong
Copy link
Contributor Author

i can still add the Sync version but i don't see the point if we only support the sync version going forward (meaning no randomBytes()). having randomBytesSync() and no randomBytes() is kind of weird. up to you guys.

@silverwind
Copy link
Contributor

Hmm, looking trough #5, I can't seem to find any compelling reason why async randomBytes should be deprecated, except for the naming inconsistency. I'm not sure it's worth pushing the deprecation on users for that alone. I'm sorry, but I think this PR has no future because of that.

#5 (comment) might be a better reason to do a change to randomBytes, we should investigate if we can get closer to window.crypto in terms of API.

@silverwind silverwind closed this Jul 20, 2015
@jonathanong jonathanong deleted the deprecate-mixed-async-crypto branch July 20, 2015 00:34
@Fishrock123
Copy link
Contributor

@silverwind won't it almost always be instantaneous?

@silverwind
Copy link
Contributor

@Fishrock123 10MB of randomess take about 350ms on my Macbook, including process startup which is about 150ms, so yes - small number of bytes would be "instant".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
crypto Issues and PRs related to the crypto subsystem. semver-minor PRs that contain new features and should be released in the next minor version.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants