Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 9d4a226

Browse filesBrowse files
indutnyMyles Borins
authored andcommitted
crypto: clear error stack in ECDH::Initialize
Clean up OpenSSL error stack in `ECDH::Initialize`, some curves have faulty implementations that are leaving dangling errors after initializing the curve. Fix: #4686 PR-URL: #4689 Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: Shigeki Ohtsu <ohtsu@iij.ad.jp>
1 parent d615757 commit 9d4a226
Copy full SHA for 9d4a226

File tree

Expand file treeCollapse file tree

2 files changed

+7
-0
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+7
-0
lines changed
Open diff view settings
Collapse file

‎src/node_crypto.cc‎

Copy file name to clipboardExpand all lines: src/node_crypto.cc
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4533,6 +4533,8 @@ void ECDH::Initialize(Environment* env, Local<Object> target) {
45334533
void ECDH::New(const FunctionCallbackInfo<Value>& args) {
45344534
Environment* env = Environment::GetCurrent(args);
45354535

4536+
MarkPopErrorOnReturn mark_pop_error_on_return;
4537+
45364538
// TODO(indutny): Support raw curves?
45374539
CHECK(args[0]->IsString());
45384540
node::Utf8Value curve(env->isolate(), args[0]);
Collapse file

‎test/parallel/test-crypto-dh.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-crypto-dh.js
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,11 @@ var secret2 = ecdh2.computeSecret(key1, 'binary', 'buffer');
159159

160160
assert.equal(secret1, secret2.toString('base64'));
161161

162+
// Oakley curves do not clean up ERR stack, it was causing unexpected failure
163+
// when accessing other OpenSSL APIs afterwards.
164+
crypto.createECDH('Oakley-EC2N-3');
165+
crypto.createHash('sha256');
166+
162167
// Point formats
163168
assert.equal(ecdh1.getPublicKey('buffer', 'uncompressed')[0], 4);
164169
var firstByte = ecdh1.getPublicKey('buffer', 'compressed')[0];

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.