(algorithm, data)
| 210 | // Implementation for WebCrypto subtle.digest() |
| 211 | |
| 212 | function asyncDigest(algorithm, data) { |
| 213 | validateMaxBufferLength(data, 'data'); |
| 214 | |
| 215 | switch (algorithm.name) { |
| 216 | case 'SHA-1': |
| 217 | // Fall through |
| 218 | case 'SHA-256': |
| 219 | // Fall through |
| 220 | case 'SHA-384': |
| 221 | // Fall through |
| 222 | case 'SHA-512': |
| 223 | // Fall through |
| 224 | case 'SHA3-256': |
| 225 | // Fall through |
| 226 | case 'SHA3-384': |
| 227 | // Fall through |
| 228 | case 'SHA3-512': |
| 229 | return jobPromise(() => new HashJob( |
| 230 | kCryptoJobWebCrypto, |
| 231 | normalizeHashName(algorithm.name), |
| 232 | data)); |
| 233 | case 'cSHAKE128': |
| 234 | // Fall through |
| 235 | case 'cSHAKE256': { |
| 236 | const outputLength = algorithm.outputLength; |
| 237 | if (algorithm.functionName?.byteLength || |
| 238 | algorithm.customization?.byteLength) { |
| 239 | if (CShakeJob === undefined) { |
| 240 | throw lazyDOMException( |
| 241 | 'Non-empty CShakeParams functionName or customization is not supported', |
| 242 | 'NotSupportedError'); |
| 243 | } |
| 244 | |
| 245 | return jobPromise(() => new CShakeJob( |
| 246 | kCryptoJobWebCrypto, |
| 247 | algorithm.name, |
| 248 | data, |
| 249 | algorithm.functionName, |
| 250 | algorithm.customization, |
| 251 | outputLength)); |
| 252 | } |
| 253 | |
| 254 | const bits = jobPromise(() => new HashJob( |
| 255 | kCryptoJobWebCrypto, |
| 256 | normalizeHashName(algorithm.name), |
| 257 | data, |
| 258 | numBitsToBytes(outputLength) * 8)); |
| 259 | if (outputLength % 8 === 0) |
| 260 | return bits; |
| 261 | return jobPromiseThen(bits, (bits) => |
| 262 | TypedArrayPrototypeGetBuffer(truncateToBitLength(outputLength, bits))); |
| 263 | } |
| 264 | case 'TurboSHAKE128': |
| 265 | // Fall through |
| 266 | case 'TurboSHAKE256': |
| 267 | return jobPromise(() => new TurboShakeJob( |
| 268 | kCryptoJobWebCrypto, |
| 269 | algorithm.name, |
nothing calls this directly
no test coverage detected
searching dependent graphs…