(algorithmName)
| 1 | var subtle = crypto.subtle; |
| 2 | |
| 3 | function runTests(algorithmName) { |
| 4 | var algorithm = {name: algorithmName}; |
| 5 | var data = keyData[algorithmName]; |
| 6 | var jwkData = {jwk: {kty: data.jwk.kty, crv: data.jwk.crv, x: data.jwk.x}}; |
| 7 | |
| 8 | [true, false].forEach(function(extractable) { |
| 9 | // Test public keys first |
| 10 | allValidUsages(data.publicUsages, true).forEach(function(usages) { |
| 11 | ['spki', 'jwk', 'raw'].forEach(function(format) { |
| 12 | if (format === "jwk") { // Not all fields used for public keys |
| 13 | testFormat(format, algorithm, jwkData, algorithmName, usages, extractable); |
| 14 | // Test for https://github.com/w3c/webcrypto/pull/401 |
| 15 | if (extractable) { |
| 16 | testJwkAlgBehaviours(algorithm, jwkData.jwk, algorithmName, usages); |
| 17 | } |
| 18 | } else { |
| 19 | testFormat(format, algorithm, data, algorithmName, usages, extractable); |
| 20 | } |
| 21 | }); |
| 22 | |
| 23 | }); |
| 24 | |
| 25 | // Next, test private keys |
| 26 | allValidUsages(data.privateUsages).forEach(function(usages) { |
| 27 | ['pkcs8', 'jwk'].forEach(function(format) { |
| 28 | testFormat(format, algorithm, data, algorithmName, usages, extractable); |
| 29 | |
| 30 | // Test for https://github.com/w3c/webcrypto/pull/401 |
| 31 | if (format === "jwk" && extractable) { |
| 32 | testJwkAlgBehaviours(algorithm, data.jwk, algorithmName, usages); |
| 33 | } |
| 34 | }); |
| 35 | }); |
| 36 | }); |
| 37 | } |
| 38 | |
| 39 | |
| 40 | // Test importKey with a given key format and other parameters. If |
no test coverage detected