GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — tls: make server not use DHE in less than 1024bits · nodejs/node@9b35be5

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • doc/api
    • tls.markdown
  • src
    • node_crypto.cc
  • test/parallel
    • test-tls-dhe.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎doc/api/tls.markdown‎

Copy file name to clipboardExpand all lines: doc/api/tls.markdown
+4-2Lines changed: 4 additions & 2 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -183,8 +183,10 @@ automatically set as a listener for the [secureConnection][] event. The
183183

184184
- `dhparam`: A string or `Buffer` containing Diffie Hellman parameters,
185185
required for Perfect Forward Secrecy. Use `openssl dhparam` to create it.
186-
If omitted or invalid, it is silently discarded and DHE ciphers won't be
187-
available.
186+
Its key length should be greater than or equal to 1024 bits, otherwise
187+
it throws an error. It is strongly recommended to use 2048 bits or
188+
more for stronger security. If omitted or invalid, it is silently
189+
discarded and DHE ciphers won't be available.
188190

189191
- `handshakeTimeout`: Abort the connection if the SSL/TLS handshake does not
190192
finish in this many milliseconds. The default is 120 seconds.
Collapse file

‎src/node_crypto.cc‎

Copy file name to clipboardExpand all lines: src/node_crypto.cc
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -757,6 +757,12 @@ void SecureContext::SetDHParam(const FunctionCallbackInfo<Value>& args) {
757757
if (dh == nullptr)
758758
return;
759759

760+
const int keylen = BN_num_bits(dh->p);
761+
if (keylen < 1024)
762+
return env->ThrowError("DH parameter is less than 1024 bits");
763+
else if (keylen < 2048)
764+
fprintf(stderr, "WARNING: DH parameter is less than 2048 bits\n");
765+
760766
SSL_CTX_set_options(sc->ctx_, SSL_OP_SINGLE_DH_USE);
761767
int r = SSL_CTX_set_tmp_dh(sc->ctx_, dh);
762768
DH_free(dh);
Collapse file

‎test/parallel/test-tls-dhe.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-tls-dhe.js
+6-4Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,9 @@ function test(keylen, expectedCipher, cb) {
6262
}
6363

6464
function test512() {
65-
test(512, 'DHE-RSA-AES128-SHA256', test1024);
66-
ntests++;
65+
assert.throws(function() {
66+
test(512, 'DHE-RSA-AES128-SHA256', null);
67+
}, /DH parameter is less than 1024 bits/);
6768
}
6869

6970
function test1024() {
@@ -77,12 +78,13 @@ function test2048() {
7778
}
7879

7980
function testError() {
80-
test('error', 'ECDHE-RSA-AES128-SHA256', null);
81+
test('error', 'ECDHE-RSA-AES128-SHA256', test512);
8182
ntests++;
8283
}
8384

84-
test512();
85+
test1024();
8586

8687
process.on('exit', function() {
8788
assert.equal(ntests, nsuccess);
89+
assert.equal(ntests, 3);
8890
});

0 commit comments

Comments
0 (0)
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.