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

Function decapsulateBitsImpl

lib/internal/crypto/webcrypto.js:1479–1519  ·  view source on GitHub ↗
(decapsulationAlgorithm, decapsulationKey, ciphertext)

Source from the content-addressed store, hash-verified

1477}
1478
1479function decapsulateBitsImpl(decapsulationAlgorithm, decapsulationKey, ciphertext) {
1480 emitExperimentalWarning('The decapsulateBits Web Crypto API method');
1481 const prefix = prepareSubtleMethod(
1482 this, 'decapsulateBits', arguments.length, 3);
1483 let i = 0;
1484 decapsulationAlgorithm = convertSubtleArgument(
1485 prefix, 'AlgorithmIdentifier', decapsulationAlgorithm, i++);
1486 decapsulationKey = convertSubtleArgument(
1487 prefix, 'CryptoKey', decapsulationKey, i++);
1488 ciphertext = convertSubtleArgument(prefix, 'BufferSource', ciphertext, i++);
1489
1490 const normalizedDecapsulationAlgorithm =
1491 normalizeAlgorithm(decapsulationAlgorithm, 'decapsulate');
1492 const keyAlgorithm = getCryptoKeyAlgorithm(decapsulationKey);
1493
1494 if (normalizedDecapsulationAlgorithm.name !== keyAlgorithm.name) {
1495 throw lazyDOMException(
1496 'key algorithm mismatch',
1497 'InvalidAccessError');
1498 }
1499
1500 if (!hasCryptoKeyUsage(decapsulationKey, 'decapsulateBits')) {
1501 throw lazyDOMException(
1502 'decapsulationKey does not have decapsulateBits usage',
1503 'InvalidAccessError');
1504 }
1505
1506 switch (keyAlgorithm.name) {
1507 case 'ML-KEM-512':
1508 case 'ML-KEM-768':
1509 case 'ML-KEM-1024':
1510 return require('internal/crypto/ml_kem')
1511 .mlKemDecapsulate(decapsulationKey, ciphertext);
1512 /* c8 ignore start */
1513 default: {
1514 const assert = require('internal/assert');
1515 assert.fail('Unreachable code');
1516 }
1517 /* c8 ignore stop */
1518 }
1519}
1520
1521function decapsulateKey(
1522 decapsulationAlgorithm,

Callers

nothing calls this directly

Calls 9

emitExperimentalWarningFunction · 0.85
prepareSubtleMethodFunction · 0.85
convertSubtleArgumentFunction · 0.85
getCryptoKeyAlgorithmFunction · 0.85
lazyDOMExceptionFunction · 0.85
hasCryptoKeyUsageFunction · 0.85
normalizeAlgorithmFunction · 0.70
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…