Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(crypto): limit RSA key size to <= 8192 bits #1931

Merged
merged 3 commits into from
Aug 4, 2023

Conversation

MarcoPolo
Copy link
Collaborator

Restrict the RSA key sizes we expect from peers. Protects us from spending a lot of compute on verifying signatures from big keys. Similar to libp2p/go-libp2p#2454

@MarcoPolo MarcoPolo requested a review from achingbrain August 3, 2023 23:24
- Make max key size a const
- Export max key size
- Add a fixuture with a key bigger than max key size
- Remove ability to override max key size (since if it's exported it becomes part of the documented API)
- Ensure we check the max key size before doing any async work
- Use uint8arrays/from-string to decode base64url instead of rolling our own
- Minor edits to test names to make them consistent with the others
@achingbrain
Copy link
Member

I made a few changes here:

  • Make max key size a const to prevent it being accidentally overwritten
  • Export max key size for reuse
  • Add a fixture with a key bigger than max key size so we don't need to override the max key size at runtime
  • Remove ability to override max key size (since if it's exported it becomes part of the documented API)
  • Ensure we check the max key size before doing any async work
  • Use uint8arrays/from-string to decode base64url instead of rolling our own version
  • Minor edits to test names to make them consistent with the others

@achingbrain achingbrain changed the title fix: crypto: limit RSA key size to <= 8192 bits fix(crypto): limit RSA key size to <= 8192 bits Aug 4, 2023
@achingbrain achingbrain merged commit 58421e1 into master Aug 4, 2023
@achingbrain achingbrain deleted the marco/limit-rsa-key-size branch August 4, 2023 12:30
This was referenced Jan 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants