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

Function rsaSignVerify

lib/internal/crypto/rsa.js:247–285  ·  view source on GitHub ↗
(key, data, { saltLength }, signature)

Source from the content-addressed store, hash-verified

245}
246
247function rsaSignVerify(key, data, { saltLength }, signature) {
248 const mode = signature === undefined ? kSignJobModeSign : kSignJobModeVerify;
249 const type = mode === kSignJobModeSign ? 'private' : 'public';
250
251 if (getCryptoKeyType(key) !== type)
252 throw lazyDOMException(`Key must be a ${type} key`, 'InvalidAccessError');
253
254 const algorithm = getCryptoKeyAlgorithm(key);
255 if (algorithm.name === 'RSA-PSS') {
256 try {
257 validateInt32(
258 saltLength,
259 'algorithm.saltLength',
260 0,
261 MathCeil((algorithm.modulusLength - 1) / 8) -
262 getDigestSizeInBytes(algorithm.hash.name) - 2);
263 } catch (err) {
264 throw lazyDOMException(
265 'The operation failed for an operation-specific reason',
266 { name: 'OperationError', cause: err });
267 }
268 }
269
270 return jobPromise(() => new SignJob(
271 kCryptoJobWebCrypto,
272 signature === undefined ? kSignJobModeSign : kSignJobModeVerify,
273 getCryptoKeyHandle(key),
274 undefined,
275 undefined,
276 undefined,
277 undefined,
278 data,
279 normalizeHashName(algorithm.hash.name),
280 saltLength,
281 algorithm.name === 'RSA-PSS' ? RSA_PKCS1_PSS_PADDING : undefined,
282 undefined,
283 undefined,
284 signature));
285}
286
287
288module.exports = {

Callers

nothing calls this directly

Calls 7

getCryptoKeyTypeFunction · 0.85
lazyDOMExceptionFunction · 0.85
getCryptoKeyAlgorithmFunction · 0.85
getDigestSizeInBytesFunction · 0.85
jobPromiseFunction · 0.85
getCryptoKeyHandleFunction · 0.85
normalizeHashNameFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…