Skip to content

Commit bd5b61f

Browse files
krktargos
authored andcommitted
test: fix crypto-dh error message for OpenSSL 3.x
OpenSSL 3.0.12 and 3.1.4 changes the type of error short keys and IVs cause. The error message in test-crypto-dh for the "empty secret" is now 'Supplied key is too small' instead of 'error:02800080:Diffie-Hellman routines::invalid secret'. Error message change is test-only and uses the right error message for versions >=3.0.12 in 3.0.x and >= 3.1.4 in 3.1.x series. ref. https://git.openssl.org/gitweb/?p=openssl.git;a=commitdiff;h=0df40630850fb2740e6be6890bb905d3fc623b2d ref. https://git.openssl.org/gitweb/?p=openssl.git;a=commitdiff;h=5f69f5c65e483928c4b28ed16af6e5742929f1ee ref. https://www.openssl.org/news/vulnerabilities.html#CVE-2023-5363 PR-URL: #50395 Reviewed-By: Richard Lau <rlau@redhat.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
1 parent 7c35055 commit bd5b61f

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

test/parallel/test-crypto-dh.js

+9-5
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,15 @@ const crypto = require('crypto');
8585
}, wrongBlockLength);
8686
}
8787

88-
assert.throws(() => {
89-
dh3.computeSecret('');
90-
}, { message: common.hasOpenSSL3 ?
91-
'error:02800080:Diffie-Hellman routines::invalid secret' :
92-
'Supplied key is too small' });
88+
{
89+
const v = crypto.constants.OPENSSL_VERSION_NUMBER;
90+
const hasOpenSSL3WithNewErrorMessage = (v >= 0x300000c0 && v <= 0x30100000) || (v >= 0x30100040 && v <= 0x30200000);
91+
assert.throws(() => {
92+
dh3.computeSecret('');
93+
}, { message: common.hasOpenSSL3 && !hasOpenSSL3WithNewErrorMessage ?
94+
'error:02800080:Diffie-Hellman routines::invalid secret' :
95+
'Supplied key is too small' });
96+
}
9397
}
9498

9599
// Through a fluke of history, g=0 defaults to DH_GENERATOR (2).

0 commit comments

Comments
 (0)