* Converts an RSA JSON Web Key object to a browser-native cryptographic key. * As a precondition, `isPkcsAvailable()` must be `true`. * * @param {!Object} jwk a deserialized RSA JSON Web Key, as specified in * Section 6.3 of RFC 7518 * @return {!Promise<!webCrypto.CryptoKey>} *
(jwk)
| 169 | * @throws {TypeError} if `jwk` is not an RSA JSON Web Key |
| 170 | */ |
| 171 | importPkcsKey(jwk) { |
| 172 | devAssert(this.isPkcsAvailable()); |
| 173 | // Safari 10 and earlier want this as an ArrayBufferView. |
| 174 | const keyData = this.isLegacyWebkit_ |
| 175 | ? utf8Encode(JSON.stringify(/** @type {!JsonObject} */ (jwk))) |
| 176 | : /** @type {!webCrypto.JsonWebKey} */ (jwk); |
| 177 | return /** @type {!Promise<!webCrypto.CryptoKey>} */ ( |
| 178 | this.subtle.importKey('jwk', keyData, this.pkcsAlgo, true, ['verify']) |
| 179 | ); |
| 180 | } |
| 181 | |
| 182 | /** |
| 183 | * Verifies an RSASSA-PKCS1-v1_5 signature with a SHA-256 hash. As a |
no test coverage detected