Skip to content

Commit b26a782

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

File tree

2 files changed

+62
-34
lines changed

2 files changed

+62
-34
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],

test/parallel/test-webcrypto-digest.js

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,11 @@ const kDigestedData = {
147147
long: '4b02caf650276030ea5617e597c5d53fd9daa68b78bfe' +
148148
'60b22aab8d36a4c2a3affdb71234f49276737c575ddf7' +
149149
'4d14054cbd6fdb98fd0ddcbcb46f91ad76b6ee'
150-
},
151-
'cshake128': {
150+
}
151+
};
152+
153+
if (!process.features.openssl_is_boringssl) {
154+
kDigestedData.cshake128 = {
152155
empty: '7f9c2ba4e88f827d616045507605853ed73b8093f6e' +
153156
'fbc88eb1a6eacfa66ef26',
154157
short: 'dea62d73e6b59cf725d0320d660089a4475cbbd3b85' +
@@ -157,8 +160,9 @@ const kDigestedData = {
157160
'832ab18285cf4f304ca32d',
158161
long: '3a5bf5676955e5dec87d430e526925558971ca14c370' +
159162
'ee5d7cf572b94c7c63d7'
160-
},
161-
'cshake256': {
163+
};
164+
165+
kDigestedData.cshake256 = {
162166
empty: '46b9dd2b0ba88d13233b3feb743eeb243fcd52ea62b' +
163167
'81b82b50c27646ed5762fd75dc4ddd8c0f200cb0501' +
164168
'9d67b592f6fc821c49479ab48640292eacb3b7c4be',
@@ -172,14 +176,16 @@ const kDigestedData = {
172176
long: '0c42bfd1e282622fd8144aa29b072fd09fc2bae70885' +
173177
'd5290933492f9d17411926a613dd0611668c2ac999e8' +
174178
'c011aabaa9004323425fbad75b0f58ee6e777a94'
175-
},
176-
'sha3-256': {
179+
};
180+
181+
kDigestedData['sha3-256'] = {
177182
empty: 'a7ffc6f8bf1ed76651c14756a061d662f580ff4de43b49fa82d80a4b80f8434a',
178183
short: '3059af7aa33b517084e8ad7bbc4fb208a44c28ef32b4698d103dd540e4f91aa1',
179184
medium: '1fa7cd1da74cd8046417508c8314e74a9a4a9d38f9f18e6cb215b8c891a0a80e',
180185
long: 'b2cfc61e0386cdaef5e10a2be189891f5ef52a7624bfcd8edc893acc64fec600'
181-
},
182-
'sha3-384': {
186+
};
187+
188+
kDigestedData['sha3-384'] = {
183189
empty: '0c63a75b845e4f7d01107d852e4c2485c51a50aaaa9' +
184190
'4fc61995e71bbee983a2ac3713831264adb47fb6bd1' +
185191
'e058d5f004',
@@ -192,8 +198,9 @@ const kDigestedData = {
192198
long: '3b39c4c97ad87613305d0ccc987181713e2d5e84b1f9' +
193199
'760011bcce0c297499005bdce8a3d2409b5ad0164f32' +
194200
'bb8778d0'
195-
},
196-
'sha3-512': {
201+
};
202+
203+
kDigestedData['sha3-512'] = {
197204
empty: 'a69f73cca23a9ac5c8b567dc185a756e97c982164fe' +
198205
'25859e0d1dcc1475c80a615b2123af1f5f94c11e3e9' +
199206
'402c3ac558f500199d95b6d3e301758586281dcd26',
@@ -206,8 +213,8 @@ const kDigestedData = {
206213
long: 'bd262cecf565c338032de5ba0138f0aacfe7dde83d27' +
207214
'2d0d37d952829ed25de1a1342d98659ef7d2fa4aca7c' +
208215
'e2b1aa0784d8fc1dcbf81bcec7a7431a3da36bf7'
209-
}
210-
};
216+
};
217+
}
211218

212219
async function testDigest(size, alg) {
213220
const digest = await subtle.digest(

0 commit comments

Comments
 (0)