(mode, normalizedAlgorithm, key, data)
| 1235 | } |
| 1236 | |
| 1237 | function cipherOrWrap(mode, normalizedAlgorithm, key, data) { |
| 1238 | // While WebCrypto allows for larger input buffer sizes, we limit |
| 1239 | // those to sizes that can fit within uint32_t because of limitations |
| 1240 | // in the OpenSSL API. |
| 1241 | validateMaxBufferLength(data, 'data'); |
| 1242 | |
| 1243 | switch (normalizedAlgorithm.name) { |
| 1244 | case 'RSA-OAEP': |
| 1245 | return require('internal/crypto/rsa') |
| 1246 | .rsaCipher(mode, key, data, normalizedAlgorithm); |
| 1247 | case 'AES-CTR': |
| 1248 | // Fall through |
| 1249 | case 'AES-CBC': |
| 1250 | // Fall through |
| 1251 | case 'AES-GCM': |
| 1252 | // Fall through |
| 1253 | case 'AES-OCB': |
| 1254 | // Fall through |
| 1255 | case 'AES-KW': |
| 1256 | return require('internal/crypto/aes') |
| 1257 | .aesCipher(mode, key, data, normalizedAlgorithm); |
| 1258 | case 'ChaCha20-Poly1305': |
| 1259 | return require('internal/crypto/chacha20_poly1305') |
| 1260 | .c20pCipher(mode, key, data, normalizedAlgorithm); |
| 1261 | /* c8 ignore start */ |
| 1262 | default: { |
| 1263 | const assert = require('internal/assert'); |
| 1264 | assert.fail('Unreachable code'); |
| 1265 | } |
| 1266 | /* c8 ignore stop */ |
| 1267 | } |
| 1268 | } |
| 1269 | |
| 1270 | function encrypt(algorithm, key, data) { |
| 1271 | return callSubtleCryptoMethod(encryptImpl, this, arguments); |
no test coverage detected
searching dependent graphs…