(algorithmName)
| 1 | var subtle = crypto.subtle; |
| 2 | |
| 3 | function runTests(algorithmName) { |
| 4 | var algorithm = { name: algorithmName }; |
| 5 | var data = keyData[algorithmName]; |
| 6 | var jwkData = { |
| 7 | jwk: { kty: data.jwk.kty, alg: data.jwk.alg, pub: data.jwk.pub }, |
| 8 | }; |
| 9 | |
| 10 | [true, false].forEach(function (extractable) { |
| 11 | // Test public keys first |
| 12 | allValidUsages(data.publicUsages, true).forEach(function (usages) { |
| 13 | ['spki', 'jwk', 'raw-public'].forEach(function (format) { |
| 14 | if (format === 'jwk') { |
| 15 | // Not all fields used for public keys |
| 16 | testFormat( |
| 17 | format, |
| 18 | algorithm, |
| 19 | jwkData, |
| 20 | algorithmName, |
| 21 | usages, |
| 22 | extractable |
| 23 | ); |
| 24 | } else { |
| 25 | testFormat( |
| 26 | format, |
| 27 | algorithm, |
| 28 | data, |
| 29 | algorithmName, |
| 30 | usages, |
| 31 | extractable |
| 32 | ); |
| 33 | } |
| 34 | }); |
| 35 | }); |
| 36 | |
| 37 | // Next, test private keys |
| 38 | allValidUsages(data.privateUsages).forEach(function (usages) { |
| 39 | ['pkcs8', 'jwk', 'raw-seed'].forEach(function (format) { |
| 40 | testFormat(format, algorithm, data, algorithmName, usages, extractable); |
| 41 | }); |
| 42 | }); |
| 43 | }); |
| 44 | } |
| 45 | |
| 46 | // Test importKey with a given key format and other parameters. If |
| 47 | // extrable is true, export the key and verify that it matches the input. |
nothing calls this directly
no test coverage detected