Skip to content

Enforce fixed R||S signature length in _RawEC.verify - #410

Open
amirulian wants to merge 1 commit into
latchset:mainfrom
amirulian:fix-ecdsa-signature-length
Open

amirulian wants to merge 1 commit into
latchset:mainfrom
amirulian:fix-ecdsa-signature-length

Conversation

@amirulian

Copy link
Copy Markdown
  • Check that the raw ECDSA JWS signature length equals 2 * ((pkey.key_size + 7) // 8) bytes in _RawEC.verify() per RFC 7518 Section 3.4.
  • Previously _RawEC.verify() split signature at len(signature) // 2 without checking the total length, allowing non-canonical signatures with leading zero bytes on R and/or S (such as 65-byte R || 0x00 || S or 66-byte 0x00 || R || 0x00 || S for ES256) to pass verification.
  • Add unit tests for ES256, ES384, and ES512 in jwcrypto/tests.py.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant