MCPcopy Index your code
hub / github.com/nodejs/node / cipherOrWrap

Function cipherOrWrap

lib/internal/crypto/webcrypto.js:1237–1268  ·  view source on GitHub ↗
(mode, normalizedAlgorithm, key, data)

Source from the content-addressed store, hash-verified

1235}
1236
1237function 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
1270function encrypt(algorithm, key, data) {
1271 return callSubtleCryptoMethod(encryptImpl, this, arguments);

Callers 4

wrapKeyImplFunction · 0.85
unwrapKeyImplFunction · 0.85
encryptImplFunction · 0.85
decryptImplFunction · 0.85

Calls 3

validateMaxBufferLengthFunction · 0.85
requireFunction · 0.50
failMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…