fix!: remove node-forge dependency from @libp2p/crypto #2355
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
TLDR: the bundle size has been reduced by about 1/3rd
AES-CTR
WebCrypto doesn't support streaming ciphers.
We have a node-forge-backed shim that allows using streaming AES-CTR in browsers but we don't use it anywhere, so this has been split out into it's own module as
@libp2p/aes-ctr
.RSA encrypt/decrypt
This was added to
@libp2p/crypto
to support webrtc-stardust but that effort didn't go anywhere and we don't use these methods anywhere else in the stack.For reasons lost to the mists of time, we chose to use a padding algorithm that WebCrypto doesn't support so node-forge (or some other userland implemenation) will always be necessary in browsers, so these ops have been pulled out into
@libp2p/rsa
which people can use if they need it.This is now done by manipulating the asn1 structures directly.
PEM/pkix/pkcs1
The previous PEM import/export is also ported to
@libp2p/crypto-rsa
because it seems to handle more weird edge cases introduced by OpenSSL.These could be handled in
@libp2p/crypto
eventually but for now it at least supports round-tripping it's own PEM files.Fixes #2086
BREAKING CHANGE: Legacy RSA operations are now in @libp2p/rsa, streaming AES-CTR ciphers are in @libp2p/aes-ctr
Change checklist