Skip to content

Commit 51fdb8e

Browse files
committed
test,crypto: sha3 algorithms aren't supported with BoringSSL
1 parent 82fc81c commit 51fdb8e

File tree

1 file changed

+43
-22
lines changed

1 file changed

+43
-22
lines changed

test/parallel/test-webcrypto-derivekey.js

Lines changed: 43 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -135,14 +135,21 @@ const { KeyObject } = require('crypto');
135135
'201509b012c9cd2fbe7ea938f0c509b36ecb140f38bf9130e96923f55f46756d'],
136136
['hello', 'there', 5, 'SHA-512',
137137
'2e8d981741f98193e0af9c79870af0e985089341221edad9a130d297eae1984b'],
138-
['hello', 'there', 5, 'SHA3-256',
139-
'0aed29b61b3ca3978aea34a9793276574ea997b69e8d03727438199f90571649'],
140-
['hello', 'there', 5, 'SHA3-384',
141-
'7aa4a274aa19b4623c5d3091c4b06355de85ff6f25e53a83e3126cbb86ae68df'],
142-
['hello', 'there', 5, 'SHA3-512',
143-
'4d909c47a81c625f866d1f9406248e6bc3c7ea89225fbccf1f08820254c9ef56'],
144138
];
145139

140+
if (!process.features.openssl_is_boringssl) {
141+
kTests.push(
142+
['hello', 'there', 5, 'SHA3-256',
143+
'0aed29b61b3ca3978aea34a9793276574ea997b69e8d03727438199f90571649'],
144+
['hello', 'there', 5, 'SHA3-384',
145+
'7aa4a274aa19b4623c5d3091c4b06355de85ff6f25e53a83e3126cbb86ae68df'],
146+
['hello', 'there', 5, 'SHA3-512',
147+
'4d909c47a81c625f866d1f9406248e6bc3c7ea89225fbccf1f08820254c9ef56']
148+
);
149+
} else {
150+
common.printSkipMessage('Skipping unsupported SHA-3 test cases');
151+
}
152+
146153
const tests = Promise.all(kTests.map((args) => test(...args)));
147154

148155
tests.then(common.mustCall());
@@ -158,16 +165,23 @@ const { KeyObject } = require('crypto');
158165
// Not long enough secret generated by ECDH
159166
[{ name: 'HMAC', hash: 'SHA-384' }, 'sign', 1024],
160167
[{ name: 'HMAC', hash: 'SHA-512' }, 'sign', 1024],
161-
[{ name: 'HMAC', hash: 'SHA3-256', length: 256 }, 'sign', 256],
162-
[{ name: 'HMAC', hash: 'SHA3-384', length: 384 }, 'sign', 384],
163-
[{ name: 'HMAC', hash: 'SHA3-512', length: 512 }, 'sign', 512],
164-
// This interaction is not defined for now.
165-
// https://github.com/WICG/webcrypto-modern-algos/issues/23
166-
// [{ name: 'HMAC', hash: 'SHA3-256' }, 'sign', 256],
167-
// [{ name: 'HMAC', hash: 'SHA3-384' }, 'sign', 384],
168-
// [{ name: 'HMAC', hash: 'SHA3-512' }, 'sign', 512],
169168
];
170169

170+
if (!process.features.openssl_is_boringssl) {
171+
vectors.push(
172+
[{ name: 'HMAC', hash: 'SHA3-256', length: 256 }, 'sign', 256],
173+
[{ name: 'HMAC', hash: 'SHA3-384', length: 384 }, 'sign', 384],
174+
[{ name: 'HMAC', hash: 'SHA3-512', length: 512 }, 'sign', 512]
175+
// This interaction is not defined for now.
176+
// https://github.com/WICG/webcrypto-modern-algos/issues/23
177+
// [{ name: 'HMAC', hash: 'SHA3-256' }, 'sign', 256],
178+
// [{ name: 'HMAC', hash: 'SHA3-384' }, 'sign', 384],
179+
// [{ name: 'HMAC', hash: 'SHA3-512' }, 'sign', 512],
180+
);
181+
} else {
182+
common.printSkipMessage('Skipping unsupported SHA-3 test cases');
183+
}
184+
171185
if (hasOpenSSL(3)) {
172186
vectors.push(
173187
['KMAC128', 'sign', 128],
@@ -211,16 +225,23 @@ const { KeyObject } = require('crypto');
211225
[{ name: 'HMAC', hash: 'SHA-256' }, 'sign', 512],
212226
[{ name: 'HMAC', hash: 'SHA-384' }, 'sign', 1024],
213227
[{ name: 'HMAC', hash: 'SHA-512' }, 'sign', 1024],
214-
[{ name: 'HMAC', hash: 'SHA3-256', length: 256 }, 'sign', 256],
215-
[{ name: 'HMAC', hash: 'SHA3-384', length: 384 }, 'sign', 384],
216-
[{ name: 'HMAC', hash: 'SHA3-512', length: 512 }, 'sign', 512],
217-
// This interaction is not defined for now.
218-
// https://github.com/WICG/webcrypto-modern-algos/issues/23
219-
// [{ name: 'HMAC', hash: 'SHA3-256' }, 'sign', 256],
220-
// [{ name: 'HMAC', hash: 'SHA3-384' }, 'sign', 384],
221-
// [{ name: 'HMAC', hash: 'SHA3-512' }, 'sign', 512],
222228
];
223229

230+
if (!process.features.openssl_is_boringssl) {
231+
vectors.push(
232+
[{ name: 'HMAC', hash: 'SHA3-256', length: 256 }, 'sign', 256],
233+
[{ name: 'HMAC', hash: 'SHA3-384', length: 384 }, 'sign', 384],
234+
[{ name: 'HMAC', hash: 'SHA3-512', length: 512 }, 'sign', 512],
235+
// This interaction is not defined for now.
236+
// https://github.com/WICG/webcrypto-modern-algos/issues/23
237+
// [{ name: 'HMAC', hash: 'SHA3-256' }, 'sign', 256],
238+
// [{ name: 'HMAC', hash: 'SHA3-384' }, 'sign', 384],
239+
// [{ name: 'HMAC', hash: 'SHA3-512' }, 'sign', 512],
240+
);
241+
} else {
242+
common.printSkipMessage('Skipping unsupported SHA-3 test cases');
243+
}
244+
224245
if (hasOpenSSL(3)) {
225246
vectors.push(
226247
['KMAC128', 'sign', 128],

0 commit comments

Comments
 (0)