(algorithm, data, key, callback)
| 156 | }; |
| 157 | |
| 158 | function signOneShot(algorithm, data, key, callback) { |
| 159 | if (algorithm != null) |
| 160 | validateString(algorithm, 'algorithm'); |
| 161 | |
| 162 | if (callback !== undefined) |
| 163 | validateFunction(callback, 'callback'); |
| 164 | |
| 165 | data = getArrayBufferOrView(data, 'data'); |
| 166 | |
| 167 | if (!key) |
| 168 | throw new ERR_CRYPTO_SIGN_KEY_REQUIRED(); |
| 169 | |
| 170 | // Options specific to RSA |
| 171 | const rsaPadding = getPadding(key); |
| 172 | const pssSaltLength = getSaltLength(key); |
| 173 | |
| 174 | // Options specific to (EC)DSA |
| 175 | const dsaSigEnc = getDSASignatureEncoding(key); |
| 176 | |
| 177 | // Options specific to Ed448 and ML-DSA |
| 178 | const context = getContext(key); |
| 179 | |
| 180 | const { |
| 181 | data: keyData, |
| 182 | format: keyFormat, |
| 183 | type: keyType, |
| 184 | passphrase: keyPassphrase, |
| 185 | namedCurve: keyNamedCurve, |
| 186 | } = preparePrivateKey(key); |
| 187 | |
| 188 | const job = new SignJob( |
| 189 | callback ? kCryptoJobAsync : kCryptoJobSync, |
| 190 | kSignJobModeSign, |
| 191 | keyData, |
| 192 | keyFormat, |
| 193 | keyType, |
| 194 | keyPassphrase, |
| 195 | keyNamedCurve, |
| 196 | data, |
| 197 | algorithm, |
| 198 | pssSaltLength, |
| 199 | rsaPadding, |
| 200 | dsaSigEnc, |
| 201 | context, |
| 202 | undefined); |
| 203 | |
| 204 | if (!callback) { |
| 205 | const { 0: err, 1: signature } = job.run(); |
| 206 | if (err !== undefined) |
| 207 | throw err; |
| 208 | |
| 209 | return Buffer.from(signature); |
| 210 | } |
| 211 | |
| 212 | job.ondone = (error, signature) => { |
| 213 | if (error) return FunctionPrototypeCall(callback, job, error); |
| 214 | FunctionPrototypeCall(callback, job, null, Buffer.from(signature)); |
| 215 | }; |
nothing calls this directly
no test coverage detected
searching dependent graphs…