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

Function decapsulate

lib/internal/crypto/kem.js:72–111  ·  view source on GitHub ↗
(key, ciphertext, callback)

Source from the content-addressed store, hash-verified

70}
71
72function decapsulate(key, ciphertext, callback) {
73 if (!KEMDecapsulateJob)
74 throw new ERR_CRYPTO_KEM_NOT_SUPPORTED();
75
76 if (callback !== undefined)
77 validateFunction(callback, 'callback');
78
79 const {
80 data: keyData,
81 format: keyFormat,
82 type: keyType,
83 passphrase: keyPassphrase,
84 namedCurve: keyNamedCurve,
85 } = preparePrivateKey(key);
86
87 ciphertext = getArrayBufferOrView(ciphertext, 'ciphertext');
88
89 const job = new KEMDecapsulateJob(
90 callback ? kCryptoJobAsync : kCryptoJobSync,
91 keyData,
92 keyFormat,
93 keyType,
94 keyPassphrase,
95 keyNamedCurve,
96 ciphertext);
97
98 if (!callback) {
99 const { 0: err, 1: result } = job.run();
100 if (err !== undefined)
101 throw err;
102
103 return result;
104 }
105
106 job.ondone = (error, result) => {
107 if (error) return FunctionPrototypeCall(callback, job, error);
108 FunctionPrototypeCall(callback, job, null, result);
109 };
110 job.run();
111}
112
113module.exports = {
114 encapsulate,

Callers

nothing calls this directly

Calls 2

preparePrivateKeyFunction · 0.85
runMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…