| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 9bf7604 commit 7c77c30
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -70,7 +70,10 @@ function test(size, type, name, cipher) { | |||
| 70 | 70 | ||
| 71 | 71 | test(undefined, undefined, undefined, 'AES256-SHA256'); | |
| 72 | 72 | test('auto', 'DH', undefined, 'DHE-RSA-AES256-GCM-SHA384'); | |
| 73 | - if (!hasOpenSSL(3, 2)) { | ||
| 73 | + if (hasOpenSSL(4, 0)) { | ||
| 74 | + // OpenSSL 4.0 implements RFC 7919 FFDHE negotiation for TLS 1.2 and | ||
| 75 | + // always selects FFDHE-2048 regardless of the server-supplied dhparam. | ||
| 76 | + } else if (!hasOpenSSL(3, 2)) { | ||
| 74 | 77 | test(1024, 'DH', undefined, 'DHE-RSA-AES256-GCM-SHA384'); | |
| 75 | 78 | } else { | |
| 76 | 79 | test(3072, 'DH', undefined, 'DHE-RSA-AES256-GCM-SHA384'); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -13,6 +13,7 @@ const secLevel = require('internal/crypto/util').getOpenSSLSecLevel(); | |||
| 13 | 13 | const assert = require('assert'); | |
| 14 | 14 | const tls = require('tls'); | |
| 15 | 15 | const fixtures = require('../common/fixtures'); | |
| 16 | + const { hasOpenSSL } = require('../common/crypto'); | ||
| 16 | 17 | ||
| 17 | 18 | const key = fixtures.readKey('agent2-key.pem'); | |
| 18 | 19 | const cert = fixtures.readKey('agent2-cert.pem'); | |
@@ -24,7 +25,7 @@ function loadDHParam(n) { | |||
| 24 | 25 | return fixtures.readKey(`dh${n}.pem`); | |
| 25 | 26 | } | |
| 26 | 27 | ||
| 27 | - function test(size, err, next) { | ||
| 28 | + function test(size, err, next, minDHSizeOverride) { | ||
| 28 | 29 | const options = { | |
| 29 | 30 | key: key, | |
| 30 | 31 | cert: cert, | |
@@ -46,7 +47,7 @@ function test(size, err, next) { | |||
| 46 | 47 | // so that it fails when it makes a connection to the tls | |
| 47 | 48 | // server where is too small. This depends on the openssl | |
| 48 | 49 | // security level | |
| 49 | - const minDHSize = (secLevel > 1) ? 3072 : 2048; | ||
| 50 | + const minDHSize = minDHSizeOverride ?? ((secLevel > 1) ? 3072 : 2048); | ||
| 50 | 51 | const client = tls.connect({ | |
| 51 | 52 | minDHSize: minDHSize, | |
| 52 | 53 | port: this.address().port, | |
@@ -84,7 +85,12 @@ function testDHE3072() { | |||
| 84 | 85 | test(3072, false, null); | |
| 85 | 86 | } | |
| 86 | 87 | ||
| 87 | - if (secLevel > 1) { | ||
| 88 | + if (hasOpenSSL(4, 0)) { | ||
| 89 | + // OpenSSL 4.0 implements RFC 7919 FFDHE negotiation for TLS 1.2 and | ||
| 90 | + // ignores the server-supplied dhparam in favor of FFDHE-2048. The 3072 | ||
| 91 | + // success case is therefore replaced by a 2048 success case. | ||
| 92 | + testDHE2048(true, () => test(2048, false, null, 2048)); | ||
| 93 | + } else if (secLevel > 1) { | ||
| 88 | 94 | // Minimum size for OpenSSL security level 2 and above is 2048 by default | |
| 89 | 95 | testDHE2048(true, testDHE3072); | |
| 90 | 96 | } else { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -28,6 +28,7 @@ if (!common.hasCrypto) { | |||
| 28 | 28 | ||
| 29 | 29 | const { | |
| 30 | 30 | opensslCli, | |
| 31 | + hasOpenSSL, | ||
| 31 | 32 | } = require('../common/crypto'); | |
| 32 | 33 | ||
| 33 | 34 | // OpenSSL has a set of security levels which affect what algorithms | |
@@ -104,9 +105,15 @@ function testCustomParam(keylen, expectedCipher) { | |||
| 104 | 105 | } | |
| 105 | 106 | ||
| 106 | 107 | (async () => { | |
| 107 | - // By default, DHE is disabled while ECDHE is enabled. | ||
| 108 | + // By default, DHE is disabled while ECDHE is enabled. OpenSSL 4.0 | ||
| 109 | + // implements RFC 7919 FFDHE negotiation for TLS 1.2 which enables DHE | ||
| 110 | + // (with FFDHE-2048) even without a server-supplied dhparam. | ||
| 108 | 111 | for (const dhparam of [undefined, null]) { | |
| 109 | - await test(dhparam, null, ecdheCipher); | ||
| 112 | + if (hasOpenSSL(4, 0)) { | ||
| 113 | + await test(dhparam, 2048, dheCipher); | ||
| 114 | + } else { | ||
| 115 | + await test(dhparam, null, ecdheCipher); | ||
| 116 | + } | ||
| 110 | 117 | } | |
| 111 | 118 | ||
| 112 | 119 | // The DHE parameters selected by OpenSSL depend on the strength of the | |
@@ -124,14 +131,24 @@ function testCustomParam(keylen, expectedCipher) { | |||
| 124 | 131 | ||
| 125 | 132 | // Custom DHE parameters are supported (but discouraged). | |
| 126 | 133 | // 1024 is disallowed at security level 2 and above so use 3072 instead | |
| 127 | - // for higher security levels | ||
| 134 | + // for higher security levels. | ||
| 135 | + // OpenSSL 4.0 implements RFC 7919 FFDHE negotiation for TLS 1.2 and | ||
| 136 | + // ignores the server-supplied dhparam in favor of FFDHE-2048, so the | ||
| 137 | + // negotiated key length is always 2048. | ||
| 128 | 138 | if (secLevel < 2) { | |
| 129 | 139 | await testCustomParam(1024, dheCipher); | |
| 140 | + } else if (hasOpenSSL(4, 0)) { | ||
| 141 | + await test(loadDHParam(3072), 2048, dheCipher); | ||
| 130 | 142 | } else { | |
| 131 | 143 | await testCustomParam(3072, dheCipher); | |
| 132 | 144 | } | |
| 133 | 145 | await testCustomParam(2048, dheCipher); | |
| 134 | 146 | ||
| 135 | - // Invalid DHE parameters are discarded. ECDHE remains enabled. | ||
| 136 | - await testCustomParam('error', ecdheCipher); | ||
| 147 | + // Invalid DHE parameters are discarded. Prior to OpenSSL 4.0 this | ||
| 148 | + // disabled DHE and ECDHE was negotiated; since 4.0, FFDHE-2048 is used. | ||
| 149 | + if (hasOpenSSL(4, 0)) { | ||
| 150 | + await test(loadDHParam('error'), 2048, dheCipher); | ||
| 151 | + } else { | ||
| 152 | + await testCustomParam('error', ecdheCipher); | ||
| 153 | + } | ||
| 137 | 154 | })().then(common.mustCall()); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments