(algorithm, key, data)
| 1272 | } |
| 1273 | |
| 1274 | function encryptImpl(algorithm, key, data) { |
| 1275 | const prefix = prepareSubtleMethod(this, 'encrypt', arguments.length, 3); |
| 1276 | let i = 0; |
| 1277 | algorithm = convertSubtleArgument( |
| 1278 | prefix, 'AlgorithmIdentifier', algorithm, i++); |
| 1279 | key = convertSubtleArgument(prefix, 'CryptoKey', key, i++); |
| 1280 | data = convertSubtleArgument(prefix, 'BufferSource', data, i++); |
| 1281 | |
| 1282 | const normalizedAlgorithm = normalizeAlgorithm(algorithm, 'encrypt'); |
| 1283 | |
| 1284 | if (normalizedAlgorithm.name !== getCryptoKeyAlgorithm(key).name) |
| 1285 | throw lazyDOMException('Key algorithm mismatch', 'InvalidAccessError'); |
| 1286 | |
| 1287 | if (!hasCryptoKeyUsage(key, 'encrypt')) |
| 1288 | throw lazyDOMException( |
| 1289 | 'Unable to use this key to encrypt', 'InvalidAccessError'); |
| 1290 | |
| 1291 | return cipherOrWrap( |
| 1292 | kWebCryptoCipherEncrypt, |
| 1293 | normalizedAlgorithm, |
| 1294 | key, |
| 1295 | data, |
| 1296 | ); |
| 1297 | } |
| 1298 | |
| 1299 | function decrypt(algorithm, key, data) { |
| 1300 | return callSubtleCryptoMethod(decryptImpl, this, arguments); |
nothing calls this directly
no test coverage detected
searching dependent graphs…