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

doc: remove outdated try/catch statements and use const #3087

Closed
wants to merge 8 commits into from
Closed

doc: remove outdated try/catch statements and use const #3087

wants to merge 8 commits into from

Conversation

JungMinu
Copy link
Member

The code shows that it throws on a lack of entropy, but the note below says that it does not.
Remove outdated try/catchstatements in sync examples about crypto.randomBytes to make it clear

fix description about crypto.randomBytes
low on entropy.
normally never take longer than a few milliseconds.
Under normal circumstances, the only error thrown from this is from RAND_bytes(), which throws when it doesn't have enough entropy.
However, with CheckEntropy, this will block until the system has enough entropy for the OpenSSL pool.
Copy link
Member

Choose a reason for hiding this comment

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

I don't think that's very enlightening for people not familiar with openssl or the code base. I don't really have suggestions on how to reword it, just that it's not very helpful now (and the part about CheckEntropy() is arguably wrong in a nuanced way.)

Also, please wrap lines at 80 columns.

Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps, @JungMinu, you could update the code block instead? The note is mostly correct about the current behavior. Maybe remove the try / catch block in the example?

@bnoordhuis
Copy link
Member

The commit log could be be a little more descriptive. Ideally, you shouldn't have to look at the diff to know what a commit changed.

@JungMinu
Copy link
Member Author

@bnoordhuis Thanks, I will update

@brendanashworth brendanashworth added crypto Issues and PRs related to the crypto subsystem. doc Issues and PRs related to the documentations. labels Sep 27, 2015
@JungMinu
Copy link
Member Author

@brendanashworth Thanks for your comment, I would love to 😄

@brendanashworth
Copy link
Contributor

@JungMinu assuming you've setup locally with git, you can always add new changes as new commits and push them to github. It will automatically update this PR, which is easier for everyone.

@JungMinu
Copy link
Member Author

@brendanashworth Yes, I will.

remove outdated examples about crypto.randomBytes to make it clear
@JungMinu
Copy link
Member Author

@brendanashworth Based on your comments, I removed try / catch block.

@JungMinu
Copy link
Member Author

@brendanashworth @bnoordhuis Please review

@bnoordhuis
Copy link
Member

I speculate that @brendanashworth's suggestion was to remove the try/catch statement, not the call to crypto.randomBytes().

fix outdated examples about crypto.randomBytes to make it clear
@JungMinu
Copy link
Member Author

@bnoordhuis Thanks, I've updated

@JungMinu JungMinu changed the title doc: fix crypto.randomBytes doc: Remove outdated try/catchstatements in sync examples Sep 27, 2015
@JungMinu JungMinu changed the title doc: Remove outdated try/catchstatements in sync examples doc: Remove outdated try/catch statements in sync examples Sep 27, 2015
@JungMinu JungMinu changed the title doc: Remove outdated try/catch statements in sync examples doc: Remove outdated try/catch statements in sync Sep 27, 2015
The code shows that it throws on a lack of entropy, but the note below says that it does not.
Remove outdated `try/catch`statements in sync examples about crypto.randomBytes to make it clear
@JungMinu
Copy link
Member Author

@bnoordhuis I've updated commit log and description, Thanks 😄

The code shows that it throws on a lack of entropy, but the note below says that it does not.
Remove outdated try/catchstatements in sync examples about crypto.randomBytes to make it clear
The code shows that it throws on a lack of entropy, but the note below says that it does not.
Remove outdated `try/catch`statements in sync examples about crypto.randomBytes to make it clear
// handle error
// most likely, entropy sources are drained
}
// Implementation of handling errors is recommended.
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this mean there should be a try/catch? randomBytes() will never throw anymore, right?

The code shows that it throws on a lack of entropy, but the note below says that it does not.
Remove outdated `try/catch`statements in sync examples about crypto.randomBytes to make it clear
@JungMinu
Copy link
Member Author

@Fishrock123 Sorry, I made a mistake.
I've updated.

@JungMinu
Copy link
Member Author

@Fishrock123 Thanks for your comment 😄

@bnoordhuis
Copy link
Member

LGTM

@brendanashworth
Copy link
Contributor

Perfect, also LGTM!

// handle error
// most likely, entropy sources are drained
}
var buf = crypto.randomBytes(256);
Copy link
Contributor

Choose a reason for hiding this comment

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

May I suggest to use const?

@thefourtheye
Copy link
Contributor

LGTM with take-it or leave-it suggestion

The code shows that it throws on a lack of entropy, but the note below says that it does not.
Remove outdated try/catchstatements in sync examples about crypto.randomBytes to make it clear.
In addition, use `const` instead of `var` for constant variable.
@JungMinu
Copy link
Member Author

@thefourtheye Thanks, I've updated

@JungMinu JungMinu changed the title doc: Remove outdated try/catch statements in sync doc: remove outdated try/catch statements and use const Sep 29, 2015
brendanashworth pushed a commit that referenced this pull request Oct 1, 2015
Fixes description about crypto.randomBytes.

Fixes: #3081
PR-URL: #3087
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Brendan Ashworth <brendan.ashworth@me.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
@brendanashworth
Copy link
Contributor

Landed in d32363f, thanks @JungMinu!

rvagg pushed a commit that referenced this pull request Oct 2, 2015
Fixes description about crypto.randomBytes.

Fixes: #3081
PR-URL: #3087
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Brendan Ashworth <brendan.ashworth@me.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
@rvagg rvagg mentioned this pull request Oct 3, 2015
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. doc Issues and PRs related to the documentations.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants