Skip to content
File

Blob: src/wpt/WebCryptoAPI-test.ts

typescript393 lines
1// Copyright (c) 2017-2022 Cloudflare, Inc.
2// Licensed under the Apache 2.0 license found in the LICENSE file or at:
3// https://opensource.org/licenses/Apache-2.0
4 
5import { type TestRunnerConfig } from 'harness/harness';
6 
7export default {
8 'algorithm-discards-context.https.window.js': {
9 comment: 'Secure context is only relevant in browsers',
10 omittedTests: true,
11 },
12 'crypto_key_cached_slots.https.any.js': {
13 comment: 'Investigate this',
14 expectedFailures: [
15 'CryptoKey.algorithm getter returns cached object',
16 'CryptoKey.usages getter returns cached object',
17 ],
18 },
19 
20 'derive_bits_keys/argon2.js': {
21 comment: 'Argon2 is not supported',
22 omittedTests: true,
23 },
24 'derive_bits_keys/argon2_vectors.js': {
25 comment: 'Argon2 is not supported',
26 omittedTests: true,
27 },
28 'derive_bits_keys/cfrg_curves_bits.js': {},
29 'derive_bits_keys/cfrg_curves_bits_curve25519.https.any.js': {},
30 'derive_bits_keys/cfrg_curves_bits_fixtures.js': {},
31 'derive_bits_keys/cfrg_curves_keys.js': {},
32 'derive_bits_keys/cfrg_curves_keys_curve25519.https.any.js': {},
33 'derive_bits_keys/derive_key_and_encrypt.https.any.js': {},
34 'derive_bits_keys/derive_key_and_encrypt.js': {},
35 'derive_bits_keys/derived_bits_length.https.any.js': {},
36 'derive_bits_keys/derived_bits_length.js': {},
37 'derive_bits_keys/derived_bits_length_testcases.js': {
38 comment:
39 "This is a resource file but it's not in the resources/ directory; no tests in here",
40 omittedTests: true,
41 },
42 'derive_bits_keys/derived_bits_length_vectors.js': {},
43 'derive_bits_keys/ecdh_bits.https.any.js': {},
44 'derive_bits_keys/ecdh_bits.js': {},
45 'derive_bits_keys/ecdh_keys.https.any.js': {},
46 'derive_bits_keys/ecdh_keys.js': {},
47 'derive_bits_keys/hkdf.https.any.js': {
48 comment: 'Cannot cope with this many iterations, keeps timing out',
49 omittedTests: [/with 100000 iterations/],
50 },
51 'derive_bits_keys/hkdf.js': {},
52 'derive_bits_keys/hkdf_vectors.js': {},
53 'derive_bits_keys/pbkdf2.https.any.js': {
54 comment: 'Cannot cope with this many iterations, keeps timing out',
55 omittedTests: [/with 100000 iterations/],
56 },
57 'derive_bits_keys/pbkdf2.js': {},
58 'derive_bits_keys/pbkdf2_vectors.js': {},
59 
60 'digest/digest.https.any.js': {
61 comment: 'They expect TypeError, we have NotSupportedError',
62 expectedFailures: [
63 'empty algorithm object with empty',
64 'empty algorithm object with short',
65 'empty algorithm object with medium',
66 'empty algorithm object with long',
67 ],
68 },
69 
70 'encap_decap/ml_kem_vectors.js': {
71 comment: 'ML-KEM (post-quantum key encapsulation) is not supported',
72 omittedTests: true,
73 },
74 
75 'encrypt_decrypt/aes.js': {},
76 'encrypt_decrypt/aes_cbc.https.any.js': {},
77 'encrypt_decrypt/aes_cbc_vectors.js': {},
78 'encrypt_decrypt/aes_ctr.https.any.js': {},
79 'encrypt_decrypt/aes_ctr_vectors.js': {},
80 'encrypt_decrypt/aes_gcm.https.any.js': {},
81 'encrypt_decrypt/aes_gcm_256_iv.https.any.js': {},
82 'encrypt_decrypt/aes_gcm_256_iv_fixtures.js': {},
83 'encrypt_decrypt/aes_gcm_96_iv_fixtures.js': {},
84 'encrypt_decrypt/aes_gcm_vectors.js': {},
85 'encrypt_decrypt/aes_ocb_fixtures.js': {
86 comment: 'AES-OCB is not supported',
87 omittedTests: true,
88 },
89 'encrypt_decrypt/aes_ocb_vectors.js': {
90 comment: 'AES-OCB is not supported',
91 omittedTests: true,
92 },
93 'encrypt_decrypt/rsa.js': {},
94 'encrypt_decrypt/rsa_oaep.https.any.js': {},
95 'encrypt_decrypt/rsa_vectors.js': {},
96 
97 'generateKey/failures.js': {},
98 'generateKey/failures_AES-CBC.https.any.js': {
99 comment: 'Wrong type of error returned',
100 expectedFailures: [/^(Empty|Bad) algorithm:/],
101 },
102 'generateKey/failures_AES-CTR.https.any.js': {
103 comment: 'Wrong type of error returned',
104 expectedFailures: [/^(Empty|Bad) algorithm:/],
105 },
106 'generateKey/failures_AES-GCM.https.any.js': {
107 comment: 'Wrong type of error returned',
108 expectedFailures: [/^(Empty|Bad) algorithm:/],
109 },
110 'generateKey/failures_AES-KW.https.any.js': {
111 comment: 'Wrong type of error returned',
112 expectedFailures: [/^(Empty|Bad) algorithm:/],
113 },
114 'generateKey/failures_ECDH.https.any.js': {
115 comment: 'Wrong type of error returned',
116 expectedFailures: [/^(Empty|Bad) algorithm:/],
117 },
118 'generateKey/failures_ECDSA.https.any.js': {
119 comment: 'Wrong type of error returned',
120 expectedFailures: [/^(Empty|Bad) algorithm:/],
121 },
122 'generateKey/failures_Ed25519.https.any.js': {
123 comment: 'Wrong type of error returned',
124 expectedFailures: [/^(Empty|Bad) algorithm:/],
125 },
126 'generateKey/failures_HMAC.https.any.js': {
127 comment: 'Wrong type of error returned',
128 expectedFailures: [/^(Empty|Bad) algorithm:/],
129 },
130 'generateKey/failures_RSA-OAEP.https.any.js': {
131 comment: 'Wrong type of error returned',
132 expectedFailures: [/^(Empty|Bad) algorithm:/],
133 },
134 'generateKey/failures_RSA-PSS.https.any.js': {
135 comment: 'Wrong type of error returned',
136 expectedFailures: [/^(Empty|Bad) algorithm:/],
137 },
138 'generateKey/failures_RSASSA-PKCS1-v1_5.https.any.js': {
139 comment: 'Wrong type of error returned',
140 expectedFailures: [/^(Empty|Bad) algorithm:/],
141 },
142 'generateKey/failures_X25519.https.any.js': {
143 comment: 'Wrong type of error returned',
144 expectedFailures: [/^(Empty|Bad) algorithm:/],
145 },
146 'generateKey/successes.js': {},
147 'generateKey/successes_AES-CBC.https.any.js': {
148 comment: 'TODO investigate this',
149 expectedFailures: [/^undefined: /],
150 },
151 'generateKey/successes_AES-CTR.https.any.js': {
152 comment: 'TODO investigate this',
153 expectedFailures: [/^undefined: /],
154 },
155 'generateKey/successes_AES-GCM.https.any.js': {
156 comment: 'TODO investigate this',
157 expectedFailures: [/^undefined: /],
158 },
159 'generateKey/successes_AES-KW.https.any.js': {
160 comment: 'TODO investigate this',
161 expectedFailures: [/^undefined: /],
162 },
163 'generateKey/successes_ECDH.https.any.js': {
164 comment: 'TODO investigate this',
165 expectedFailures: [/^undefined: /],
166 },
167 'generateKey/successes_ECDSA.https.any.js': {
168 comment: 'TODO investigate this',
169 expectedFailures: [/^undefined: /],
170 },
171 'generateKey/successes_Ed25519.https.any.js': {
172 comment: 'TODO investigate this',
173 expectedFailures: [/^undefined: /],
174 },
175 'generateKey/successes_HMAC.https.any.js': {
176 comment: 'TODO investigate this',
177 expectedFailures: [/^undefined: /],
178 },
179 'generateKey/successes_RSA-OAEP.https.any.js': {
180 comment: 'TODO investigate this',
181 expectedFailures: [/^undefined: /],
182 },
183 'generateKey/successes_RSA-PSS.https.any.js': {
184 comment: 'TODO investigate this',
185 expectedFailures: [/^undefined: /],
186 },
187 'generateKey/successes_RSASSA-PKCS1-v1_5.https.any.js': {
188 comment: 'TODO investigate this',
189 expectedFailures: [/^undefined: /],
190 },
191 'generateKey/successes_X25519.https.any.js': {
192 comment: 'TODO investigate this',
193 expectedFailures: [/^undefined: /],
194 },
195 
196 'getRandomValues.any.js': {},
197 'historical.any.js': {
198 comment: 'Secure context is only relevant to browsers',
199 omittedTests: [
200 'Non-secure context window does not have access to crypto.subtle',
201 'Non-secure context window does not have access to SubtleCrypto',
202 'Non-secure context window does not have access to CryptoKey',
203 ],
204 },
205 'idlharness.https.any.js': {
206 comment:
207 'IDL tests fail because Workers exposes globals differently than browsers (not as own properties of self)',
208 expectedFailures: [
209 'CryptoKey interface: attribute type',
210 'CryptoKey interface: attribute extractable',
211 'CryptoKey interface: attribute algorithm',
212 'CryptoKey interface: attribute usages',
213 'SubtleCrypto interface: operation encrypt(AlgorithmIdentifier, CryptoKey, BufferSource)',
214 'SubtleCrypto interface: operation decrypt(AlgorithmIdentifier, CryptoKey, BufferSource)',
215 'SubtleCrypto interface: operation sign(AlgorithmIdentifier, CryptoKey, BufferSource)',
216 'SubtleCrypto interface: operation verify(AlgorithmIdentifier, CryptoKey, BufferSource, BufferSource)',
217 'SubtleCrypto interface: operation digest(AlgorithmIdentifier, BufferSource)',
218 'SubtleCrypto interface: operation generateKey(AlgorithmIdentifier, boolean, sequence<KeyUsage>)',
219 'SubtleCrypto interface: operation deriveKey(AlgorithmIdentifier, CryptoKey, AlgorithmIdentifier, boolean, sequence<KeyUsage>)',
220 'SubtleCrypto interface: operation deriveBits(AlgorithmIdentifier, CryptoKey, optional unsigned long?)',
221 'SubtleCrypto interface: operation importKey(KeyFormat, (BufferSource or JsonWebKey), AlgorithmIdentifier, boolean, sequence<KeyUsage>)',
222 'SubtleCrypto interface: operation exportKey(KeyFormat, CryptoKey)',
223 'SubtleCrypto interface: operation wrapKey(KeyFormat, CryptoKey, CryptoKey, AlgorithmIdentifier)',
224 'SubtleCrypto interface: operation unwrapKey(KeyFormat, BufferSource, CryptoKey, AlgorithmIdentifier, AlgorithmIdentifier, boolean, sequence<KeyUsage>)',
225 'Window interface: attribute crypto',
226 ],
227 },
228 
229 'import_export/ML-DSA_importKey.js': {
230 comment: 'ML-DSA (post-quantum signature algorithm) is not supported',
231 omittedTests: true,
232 },
233 'import_export/ML-DSA_importKey_fixtures.js': {
234 comment: 'ML-DSA (post-quantum signature algorithm) is not supported',
235 omittedTests: true,
236 },
237 'import_export/ML-KEM_importKey.js': {
238 comment: 'ML-KEM (post-quantum key encapsulation) is not supported',
239 omittedTests: true,
240 },
241 'import_export/ML-KEM_importKey_fixtures.js': {
242 comment: 'ML-KEM (post-quantum key encapsulation) is not supported',
243 omittedTests: true,
244 },
245 'import_export/crashtests/importKey-unsettled-promise.https.any.js': {},
246 'import_export/ec_importKey.https.any.js': {},
247 'import_export/ec_importKey_failures_ECDH.https.any.js': {
248 comment:
249 'OpenSSL call failed: EC_POINT_set_affine_coordinates_GFp(group, point, bigX, bigY, nullptr);',
250 expectedFailures: [
251 /^Bad key length:/,
252 /^Missing JWK 'crv' parameter:/,
253 "Invalid 'crv' field: importKey(jwk(private), {name: ECDH, namedCurve: P-256}, true, [deriveKey, deriveBits])",
254 "Invalid 'crv' field: importKey(jwk(private), {name: ECDH, namedCurve: P-384}, true, [deriveKey, deriveBits])",
255 "Invalid 'crv' field: importKey(jwk(private), {name: ECDH, namedCurve: P-521}, true, [deriveKey, deriveBits])",
256 ],
257 },
258 'import_export/ec_importKey_failures_ECDSA.https.any.js': {
259 comment:
260 'OpenSSL call failed: EC_POINT_set_affine_coordinates_GFp(group, point, bigX, bigY, nullptr);',
261 expectedFailures: [
262 /^Bad key length:/,
263 /^Missing JWK 'crv' parameter:/,
264 "Invalid 'crv' field: importKey(jwk(private), {name: ECDSA, namedCurve: P-256}, true, [sign])",
265 "Invalid 'crv' field: importKey(jwk(private), {name: ECDSA, namedCurve: P-384}, true, [sign])",
266 "Invalid 'crv' field: importKey(jwk(private), {name: ECDSA, namedCurve: P-521}, true, [sign])",
267 ],
268 },
269 'import_export/ec_importKey_failures_fixtures.js': {},
270 'import_export/importKey_failures.js': {},
271 'import_export/okp_importKey.js': {},
272 'import_export/okp_importKey_Ed25519.https.any.js': {
273 comment: 'Investigate this',
274 expectedFailures: [
275 'Good parameters with JWK alg Ed25519: Ed25519 (jwk, object(kty, crv, x), {name: Ed25519}, true, [verify])',
276 'Good parameters with JWK alg Ed25519: Ed25519 (jwk, object(kty, crv, x), Ed25519, true, [verify])',
277 'Good parameters with JWK alg Ed25519: Ed25519 (jwk, object(kty, crv, x), {name: Ed25519}, true, [])',
278 'Good parameters with JWK alg Ed25519: Ed25519 (jwk, object(kty, crv, x), Ed25519, true, [])',
279 'Good parameters with JWK alg Ed25519: Ed25519 (jwk, object(kty, crv, x), {name: Ed25519}, true, [verify, verify])',
280 'Good parameters with JWK alg Ed25519: Ed25519 (jwk, object(kty, crv, x), Ed25519, true, [verify, verify])',
281 'Good parameters with JWK alg Ed25519: Ed25519 (jwk, object(crv, d, x, kty), {name: Ed25519}, true, [sign])',
282 'Good parameters with JWK alg Ed25519: Ed25519 (jwk, object(crv, d, x, kty), Ed25519, true, [sign])',
283 'Good parameters with JWK alg Ed25519: Ed25519 (jwk, object(crv, d, x, kty), {name: Ed25519}, true, [sign, sign])',
284 'Good parameters with JWK alg Ed25519: Ed25519 (jwk, object(crv, d, x, kty), Ed25519, true, [sign, sign])',
285 'Good parameters with JWK alg EdDSA: Ed25519 (jwk, object(kty, crv, x), {name: Ed25519}, true, [verify])',
286 'Good parameters with JWK alg EdDSA: Ed25519 (jwk, object(kty, crv, x), Ed25519, true, [verify])',
287 'Good parameters with JWK alg EdDSA: Ed25519 (jwk, object(kty, crv, x), {name: Ed25519}, true, [])',
288 'Good parameters with JWK alg EdDSA: Ed25519 (jwk, object(kty, crv, x), Ed25519, true, [])',
289 'Good parameters with JWK alg EdDSA: Ed25519 (jwk, object(kty, crv, x), {name: Ed25519}, true, [verify, verify])',
290 'Good parameters with JWK alg EdDSA: Ed25519 (jwk, object(kty, crv, x), Ed25519, true, [verify, verify])',
291 'Good parameters with JWK alg EdDSA: Ed25519 (jwk, object(crv, d, x, kty), {name: Ed25519}, true, [sign])',
292 'Good parameters with JWK alg EdDSA: Ed25519 (jwk, object(crv, d, x, kty), Ed25519, true, [sign])',
293 'Good parameters with JWK alg EdDSA: Ed25519 (jwk, object(crv, d, x, kty), {name: Ed25519}, true, [sign, sign])',
294 'Good parameters with JWK alg EdDSA: Ed25519 (jwk, object(crv, d, x, kty), Ed25519, true, [sign, sign])',
295 ],
296 },
297 'import_export/okp_importKey_X25519.https.any.js': {},
298 'import_export/okp_importKey_failures_Ed25519.https.any.js': {
299 comment:
300 'To be investigated - workerd does not reject these invalid key pairs',
301 expectedFailures: [
302 /Invalid key pair: importKey\(jwk\(private\), .*, true, \[sign\]\)/,
303 /Invalid key pair: importKey\(jwk\(private\), .*, true, \[sign, sign\]\)/,
304 /Invalid 'crv' field: importKey\(jwk\(private\), .*, true, \[sign\]\)/,
305 /Invalid 'crv' field: importKey\(jwk \(public\) , .*, true, \[verify\]\)/,
306 ],
307 },
308 'import_export/okp_importKey_failures_X25519.https.any.js': {
309 comment:
310 'To be investigated - workerd does not reject these invalid key pairs',
311 expectedFailures: [
312 /Invalid key pair: importKey\(jwk\(private\), .*, true, \[deriveKey\]\)/,
313 /Invalid key pair: importKey\(jwk\(private\), .*, true, \[deriveBits, deriveKey\]\)/,
314 /Invalid key pair: importKey\(jwk\(private\), .*, true, \[deriveBits\]\)/,
315 /Invalid key pair: importKey\(jwk\(private\), .*, true, \[deriveKey, deriveBits, deriveKey, deriveBits\]\)/,
316 /Invalid 'crv' field: importKey\(jwk\(private\), .*, true, \[deriveKey, deriveBits\]\)/,
317 /Invalid 'crv' field: importKey\(jwk \(public\) , .*, true, \[\]\)/,
318 ],
319 },
320 'import_export/okp_importKey_failures_fixtures.js': {},
321 'import_export/okp_importKey_fixtures.js': {},
322 'import_export/rsa_importKey.https.any.js': {},
323 'import_export/symmetric_importKey.https.any.js': {},
324 'import_export/symmetric_importKey.js': {},
325 
326 'normalize-algorithm-name.https.any.js': {
327 comment:
328 'Algorithm names with Unicode Kelvin sign (U+212A) lookalikes throw SyntaxError instead of NotSupportedError',
329 expectedFailures: [/does not match "HKDF"/, /does not match "PBKDF2"/],
330 },
331 
332 'randomUUID.https.any.js': {},
333 
334 'sign_verify/ecdsa.https.any.js': {},
335 'sign_verify/ecdsa.js': {},
336 'sign_verify/ecdsa_vectors.js': {},
337 'sign_verify/eddsa.js': {},
338 'sign_verify/eddsa_curve25519.https.any.js': {
339 comment: 'To be investigated',
340 expectedFailures: [
341 'EdDSA Ed25519 verification failure due to shortened signature',
342 'EdDSA Ed25519 verification with transferred signature during call',
343 ],
344 },
345 'sign_verify/eddsa_small_order_points.https.any.js': {
346 comment: 'To be investigated',
347 expectedFailures: [
348 'Ed25519 Verification checks with small-order key of order - Test 0',
349 'Ed25519 Verification checks with small-order key of order - Test 1',
350 'Ed25519 Verification checks with small-order key of order - Test 2',
351 'Ed25519 Verification checks with small-order key of order - Test 7',
352 'Ed25519 Verification checks with small-order key of order - Test 11',
353 'Ed25519 Verification checks with small-order key of order - Test 12',
354 'Ed25519 Verification checks with small-order key of order - Test 13',
355 ],
356 },
357 'sign_verify/eddsa_small_order_points.js': {},
358 'sign_verify/eddsa_vectors.js': {},
359 'sign_verify/hmac.https.any.js': {},
360 'sign_verify/hmac.js': {},
361 'sign_verify/hmac_vectors.js': {},
362 'sign_verify/kmac.js': {
363 comment: 'KMAC is not supported',
364 omittedTests: true,
365 },
366 'sign_verify/kmac_vectors.js': {
367 comment: 'KMAC is not supported',
368 omittedTests: true,
369 },
370 'sign_verify/mldsa.js': {
371 comment: 'ML-DSA (post-quantum signature algorithm) is not supported',
372 omittedTests: true,
373 },
374 'sign_verify/mldsa_vectors.js': {
375 comment: 'ML-DSA (post-quantum signature algorithm) is not supported',
376 omittedTests: true,
377 },
378 'sign_verify/rsa.js': {},
379 'sign_verify/rsa_pkcs.https.any.js': {},
380 'sign_verify/rsa_pkcs_vectors.js': {},
381 'sign_verify/rsa_pss.https.any.js': {},
382 'sign_verify/rsa_pss_vectors.js': {},
383 
384 'util/helpers.js': {},
385 'util/worker-report-crypto-subtle-presence.js': {
386 comment: 'ReferenceError: postMessage is not defined',
387 disabledTests: true,
388 },
389 
390 'wrapKey_unwrapKey/wrapKey_unwrapKey.https.any.js': {},
391 'wrapKey_unwrapKey/wrapKey_unwrapKey_vectors.js': {},
392} satisfies TestRunnerConfig;