|
80 | 80 | }
|
81 | 81 |
|
82 | 82 | testFormat(format, algorithm, data, curve, usages, extractable);
|
| 83 | + if (vector.name === 'ECDH' && format === 'jwk') { |
| 84 | + testEcdhJwkAlg(algorithm, { ...data.jwk, alg: 'any alg works here' }, curve, usages, extractable); |
| 85 | + } |
83 | 86 | });
|
84 | 87 |
|
85 | 88 | });
|
|
90 | 93 | var data = keyData[curve];
|
91 | 94 | allValidUsages(vector.privateUsages).forEach(function(usages) {
|
92 | 95 | testFormat(format, algorithm, data, curve, usages, extractable);
|
| 96 | + if (vector.name === 'ECDH' && format === 'jwk') { |
| 97 | + testEcdhJwkAlg(algorithm, { ...data.jwk, alg: 'any alg works here' }, curve, usages, extractable); |
| 98 | + } |
93 | 99 | });
|
94 | 100 | testEmptyUsages(format, algorithm, data, curve, extractable);
|
95 | 101 | });
|
96 | 102 | });
|
97 |
| - |
98 | 103 | });
|
99 | 104 | });
|
100 | 105 |
|
|
151 | 156 | }, "Empty Usages: " + keySize.toString() + " bits " + parameterString(format, false, keyData, algorithm, extractable, usages));
|
152 | 157 | }
|
153 | 158 |
|
| 159 | + // Test ECDH importKey with a JWK format |
| 160 | + // Should succeed with any "alg" value |
| 161 | + function testEcdhJwkAlg(algorithm, keyData, keySize, usages, extractable) { |
| 162 | + const format = "jwk"; |
| 163 | + promise_test(function(test) { |
| 164 | + return subtle.importKey(format, keyData, algorithm, extractable, usages). |
| 165 | + then(function(key) { |
| 166 | + assert_equals(key.constructor, CryptoKey, "Imported a CryptoKey object"); |
| 167 | + assert_goodCryptoKey(key, algorithm, extractable, usages, keyData.d ? 'private' : 'public'); |
| 168 | + }, function(err) { |
| 169 | + assert_unreached("Threw an unexpected error: " + err.toString()); |
| 170 | + }); |
| 171 | + }, "ECDH any JWK alg: " + keySize.toString() + " bits " + parameterString(format, false, keyData, algorithm, extractable, usages)); |
| 172 | + } |
| 173 | + |
154 | 174 |
|
155 | 175 |
|
156 | 176 | // Helper methods follow:
|
|
0 commit comments