(_algorithm, message)
| 84 | } |
| 85 | |
| 86 | async encrypt(_algorithm, message) { |
| 87 | if (message.length > this._keyBytes - 11) { |
| 88 | return null; |
| 89 | } |
| 90 | const ps = new Uint8Array(this._keyBytes - message.length - 3); |
| 91 | window.crypto.getRandomValues(ps); |
| 92 | for (let i = 0; i < ps.length; i++) { |
| 93 | ps[i] = Math.floor(ps[i] * 254 / 255 + 1); |
| 94 | } |
| 95 | const em = new Uint8Array(this._keyBytes); |
| 96 | em[1] = 0x02; |
| 97 | em.set(ps, 2); |
| 98 | em.set(message, ps.length + 3); |
| 99 | const emBigInt = u8ArrayToBigInt(em); |
| 100 | const c = modPow(emBigInt, this._eBigInt, this._nBigInt); |
| 101 | return bigIntToU8Array(c, this._keyBytes); |
| 102 | } |
| 103 | |
| 104 | async decrypt(_algorithm, message) { |
| 105 | if (message.length !== this._keyBytes) { |
nothing calls this directly
no test coverage detected