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

Function rsaFunctionFor

lib/internal/crypto/cipher.js:65–83  ·  view source on GitHub ↗
(method, defaultPadding, keyType)

Source from the content-addressed store, hash-verified

63const { StringDecoder } = require('string_decoder');
64
65function rsaFunctionFor(method, defaultPadding, keyType) {
66 const keyName = keyType === 'private' ? 'privateKey' : undefined;
67 return (key, buffer) => {
68 const { format, type, data, passphrase, namedCurve } =
69 keyType === 'private' ?
70 preparePrivateKey(key, keyName) :
71 preparePublicOrPrivateKey(key, keyName);
72 const padding = key.padding || defaultPadding;
73 const { oaepHash, encoding } = key;
74 let { oaepLabel } = key;
75 if (oaepHash !== undefined)
76 validateString(oaepHash, 'key.oaepHash');
77 if (oaepLabel !== undefined)
78 oaepLabel = getArrayBufferOrView(oaepLabel, 'key.oaepLabel', encoding);
79 buffer = getArrayBufferOrView(buffer, 'buffer', encoding);
80 return method(data, format, type, passphrase, namedCurve, buffer,
81 padding, oaepHash, oaepLabel);
82 };
83}
84
85const publicEncrypt = rsaFunctionFor(_publicEncrypt, RSA_PKCS1_OAEP_PADDING,
86 'public');

Callers 1

cipher.jsFile · 0.85

Calls 3

preparePrivateKeyFunction · 0.85
methodFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…