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

crypto: add getCurves() to get supported ECs #1914

Closed
wants to merge 1 commit into from

Conversation

mscdex
Copy link
Contributor

@mscdex mscdex commented Jun 7, 2015

No description provided.

@mscdex mscdex added the crypto Issues and PRs related to the crypto subsystem. label Jun 7, 2015
@silverwind silverwind added the semver-minor PRs that contain new features and should be released in the next minor version. label Jun 7, 2015
@silverwind
Copy link
Contributor

👍 nice feature, will be pretty useful. Looking good from my side, though I can't review the C++ part.

@mscdex
Copy link
Contributor Author

mscdex commented Jun 7, 2015

/cc @nodejs/crypto

@silverwind
Copy link
Contributor

@mscdex
Copy link
Contributor Author

mscdex commented Jun 8, 2015

Looks like one of the Windows CI boxes has too little memory?

EC_builtin_curve* curves =
reinterpret_cast<EC_builtin_curve*>(malloc(sizeof(EC_builtin_curve) * len));

if (curves) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Won't this just fail silently if you run out of memory in the malloc call? Perhaps something like this would be simpler.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

@mscdex mscdex force-pushed the crypto-get-curves branch from 13c11b6 to 0bc4a2f Compare June 8, 2015 03:11
@silverwind
Copy link
Contributor

Local<Array> arr = Array::New(env->isolate());
size_t len = EC_get_builtin_curves(NULL, 0);
EC_builtin_curve* curves =
reinterpret_cast<EC_builtin_curve*>(malloc(sizeof(EC_builtin_curve) * len));
Copy link
Member

Choose a reason for hiding this comment

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

Style: four spaces indent for line continuations and can you use sizeof(*curves)?

@mscdex mscdex force-pushed the crypto-get-curves branch from 0bc4a2f to eb1fd08 Compare June 8, 2015 15:00
@mscdex
Copy link
Contributor Author

mscdex commented Jun 8, 2015

Commit updated as per suggestions.


if (num_curves) {
alloc_size = sizeof(*curves) * num_curves;
curves = reinterpret_cast<EC_builtin_curve*>(malloc(alloc_size));
Copy link
Member

Choose a reason for hiding this comment

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

Micro-nit: just static_cast is sufficient here.

@bnoordhuis
Copy link
Member

LGTM with nits.

@mscdex mscdex force-pushed the crypto-get-curves branch from eb1fd08 to 1c59845 Compare June 8, 2015 16:26
mscdex added a commit that referenced this pull request Jun 8, 2015
PR-URL: #1914
Reviewed-By: Roman Reiss <[email protected]>
Reviewed-By: Ben Noordhuis <[email protected]>
@mscdex
Copy link
Contributor Author

mscdex commented Jun 8, 2015

Landed in 38d1afc.

@mscdex mscdex closed this Jun 8, 2015
@mscdex mscdex deleted the crypto-get-curves branch June 8, 2015 16:38
@silverwind
Copy link
Contributor

May as well update the doc change in deb8b87 again to point to this method.

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.

4 participants