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

Function testVerify

test/parallel/test-webcrypto-sign-verify-eddsa.js:18–150  ·  view source on GitHub ↗
({ name,
                            context,
                            publicKeyBuffer,
                            privateKeyBuffer,
                            signature,
                            data })

Source from the content-addressed store, hash-verified

16const supportsContext = hasOpenSSL(3, 2);
17
18async function testVerify({ name,
19 context,
20 publicKeyBuffer,
21 privateKeyBuffer,
22 signature,
23 data }) {
24 const [
25 publicKey,
26 noVerifyPublicKey,
27 privateKey,
28 hmacKey,
29 rsaKeys,
30 ecKeys,
31 ] = await Promise.all([
32 subtle.importKey(
33 'spki',
34 publicKeyBuffer,
35 { name },
36 false,
37 ['verify']),
38 subtle.importKey(
39 'spki',
40 publicKeyBuffer,
41 { name },
42 false,
43 [ /* No usages */ ]),
44 subtle.importKey(
45 'pkcs8',
46 privateKeyBuffer,
47 { name },
48 false,
49 ['sign']),
50 subtle.generateKey(
51 { name: 'HMAC', hash: 'SHA-256' },
52 false,
53 ['sign']),
54 subtle.generateKey(
55 {
56 name: 'RSA-PSS',
57 modulusLength: 1024,
58 publicExponent: new Uint8Array([1, 0, 1]),
59 hash: 'SHA-256',
60 },
61 false,
62 ['sign']),
63 subtle.generateKey(
64 {
65 name: 'ECDSA',
66 namedCurve: 'P-256'
67 },
68 false,
69 ['sign']),
70 ]);
71
72 assert(await subtle.verify({ name, context }, publicKey, signature, data));
73 if (context?.byteLength !== undefined) {
74 if (supportsContext) {
75 assert(!(await subtle.verify({ name, context: crypto.randomBytes(30) }, publicKey, signature, data)));

Calls 5

allMethod · 0.80
sliceMethod · 0.65
assertFunction · 0.50
verifyMethod · 0.45
fromMethod · 0.45

Tested by

no test coverage detected