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

Function rsaKeyGenerate

lib/internal/crypto/rsa.js:101–147  ·  view source on GitHub ↗
(
  algorithm,
  extractable,
  usages,
)

Source from the content-addressed store, hash-verified

99}
100
101function rsaKeyGenerate(
102 algorithm,
103 extractable,
104 usages,
105) {
106 const publicExponentConverted = bigIntArrayToUnsignedInt(algorithm.publicExponent);
107 if (publicExponentConverted === undefined) {
108 throw lazyDOMException(
109 'The publicExponent must be equivalent to an unsigned 32-bit value',
110 'OperationError');
111 }
112 const {
113 name,
114 modulusLength,
115 publicExponent,
116 hash,
117 } = algorithm;
118
119 const allowedUsages = kUsages[name];
120 const usagesSet = validateKeyUsages(usages, allowedUsages.keygen, name);
121
122 const keyAlgorithm = {
123 name,
124 modulusLength,
125 publicExponent,
126 hash,
127 };
128
129 if (publicExponentConverted < 3 || publicExponentConverted % 2 === 0) {
130 throw lazyDOMException(
131 'The operation failed for an operation-specific reason',
132 'OperationError');
133 }
134
135 const keyUsages = getKeyPairUsages(usagesSet, allowedUsages);
136 validateUsagesNotEmpty(keyUsages.private);
137
138 return jobPromise(() => new RsaKeyPairGenJob(
139 kCryptoJobWebCrypto,
140 kKeyVariantRSA_SSA_PKCS1_v1_5,
141 modulusLength,
142 publicExponentConverted,
143 keyAlgorithm,
144 getUsagesMask(keyUsages.public),
145 getUsagesMask(keyUsages.private),
146 extractable));
147}
148
149function rsaExportKey(key, format) {
150 try {

Callers

nothing calls this directly

Calls 7

bigIntArrayToUnsignedIntFunction · 0.85
lazyDOMExceptionFunction · 0.85
validateKeyUsagesFunction · 0.85
getKeyPairUsagesFunction · 0.85
validateUsagesNotEmptyFunction · 0.85
jobPromiseFunction · 0.85
getUsagesMaskFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…