Skip to content

Commit df6c598

Browse files
committed
fixup! crypto: coerce -0 to +0 before native calls
1 parent ac9d613 commit df6c598

1 file changed

Lines changed: 17 additions & 1 deletion

File tree

test/parallel/test-crypto-negative-zero.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ if (!common.hasCrypto)
66

77
const assert = require('assert');
88
const crypto = require('crypto');
9+
const { hasOpenSSL } = require('../common/crypto');
910

1011
function getOutcome(fn) {
1112
try {
@@ -78,7 +79,6 @@ function assertSameErrorOrSuccess(actual, expected) {
7879
saltLength: zero,
7980
})],
8081
['dsa', (zero) => ({ modulusLength: zero })],
81-
['dsa', (zero) => ({ modulusLength: 512, divisorLength: zero })],
8282
['dh', (zero) => ({ primeLength: zero })],
8383
['dh', (zero) => ({ primeLength: 2, generator: zero })],
8484
]) {
@@ -88,6 +88,22 @@ function assertSameErrorOrSuccess(actual, expected) {
8888
);
8989
}
9090

91+
if (!hasOpenSSL(3) && crypto.getFips()) {
92+
common.printSkipMessage(
93+
'Skipping DSA divisorLength 0 key generation on OpenSSL 1.1.1');
94+
} else {
95+
assertSameErrorOrSuccess(
96+
getOutcome(() => crypto.generateKeyPairSync('dsa', {
97+
modulusLength: 512,
98+
divisorLength: -0,
99+
})),
100+
getOutcome(() => crypto.generateKeyPairSync('dsa', {
101+
modulusLength: 512,
102+
divisorLength: 0,
103+
})),
104+
);
105+
}
106+
91107
crypto.generateKeyPair('rsa', { modulusLength: -0 },
92108
common.mustCall((err) => {
93109
assert(err instanceof Error);

0 commit comments

Comments
 (0)