(algorithm, extractable)
| 37 | } |
| 38 | |
| 39 | async _generateKey(algorithm, extractable) { |
| 40 | this._keyLength = algorithm.modulusLength; |
| 41 | this._keyBytes = Math.ceil(this._keyLength / 8); |
| 42 | const key = await window.crypto.subtle.generateKey( |
| 43 | { |
| 44 | name: "RSA-OAEP", |
| 45 | modulusLength: algorithm.modulusLength, |
| 46 | publicExponent: algorithm.publicExponent, |
| 47 | hash: {name: "SHA-256"}, |
| 48 | }, |
| 49 | true, ["encrypt", "decrypt"]); |
| 50 | const privateKey = await window.crypto.subtle.exportKey("jwk", key.privateKey); |
| 51 | this._n = this._padArray(this._base64urlDecode(privateKey.n), this._keyBytes); |
| 52 | this._nBigInt = u8ArrayToBigInt(this._n); |
| 53 | this._e = this._padArray(this._base64urlDecode(privateKey.e), this._keyBytes); |
| 54 | this._eBigInt = u8ArrayToBigInt(this._e); |
| 55 | this._d = this._padArray(this._base64urlDecode(privateKey.d), this._keyBytes); |
| 56 | this._dBigInt = u8ArrayToBigInt(this._d); |
| 57 | this._extractable = extractable; |
| 58 | } |
| 59 | |
| 60 | static async importKey(key, _algorithm, extractable, keyUsages) { |
| 61 | if (keyUsages.length !== 1 || keyUsages[0] !== "encrypt") { |
no test coverage detected