MCPcopy
hub / github.com/panva/jose / testECDSASigEncoding

Function testECDSASigEncoding

test/jws/restrictions.test.ts:91–106  ·  view source on GitHub ↗
(t, alg)

Source from the content-addressed store, hash-verified

89testRSAenc.title = (title, alg) => `${alg} requires key modulusLength to be 2048 bits or larger`
90
91async function testECDSASigEncoding(t, alg) {
92 const { privateKey, publicKey } = await generateKeyPair(alg, { extractable: true })
93
94 const jws = await new FlattenedSign(t.context.payload)
95 .setProtectedHeader({ alg })
96 .sign(privateKey)
97
98 const derEncodedSignature = base64url.encode(
99 crypto.sign(`sha${alg.slice(2, 5)}`, Buffer.from('foo'), await exportPKCS8(privateKey)),
100 )
101
102 await t.throwsAsync(flattenedVerify({ ...jws, signature: derEncodedSignature }, publicKey), {
103 message: 'signature verification failed',
104 code: 'ERR_JWS_SIGNATURE_VERIFICATION_FAILED',
105 })
106}
107testECDSASigEncoding.title = (title, alg) => `${alg} swallows invalid signature encoding errors`
108
109test(testRSAsig, 'RS256')

Callers

nothing calls this directly

Calls 6

exportPKCS8Function · 0.85
flattenedVerifyFunction · 0.85
encodeMethod · 0.80
signMethod · 0.65
setProtectedHeaderMethod · 0.65
generateKeyPairFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…