chore: update dependency node-rsa to v2#1244
Draft
renovate[bot] wants to merge 1 commit into
Draft
Conversation
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This PR contains the following updates:
^1.1.1→^2.0.0Release Notes
rzcoder/node-rsa (node-rsa)
v2.0.0Compare Source
Full rewrite of the v1 library in TypeScript with the same public API. The
node bundle now routes RSA primitives through
node:cryptowheneverpossible, and the browser bundle defaults to native
BigInt.Performance — node bundle uses
node:cryptonativelycrypto.generateKeyPairSync. 2048-bit drops from ~2.3 sto ~50 ms (~45× faster) on modern hardware; 1024-bit from ~240 ms to
~10 ms.
crypto.sign/crypto.verify.PSS-SHA256 sign on 2048-bit drops from ~17 ms to sub-millisecond.
NodeNativeEngine—also
node:crypto-backed.Performance — browser bundle defaults to native
BigIntA drop-in BigInteger implementation lives at
src/bigint/big-integer-native.ts and
uses ES2020's native
BigInt. The browser bundle picks it at load time;the node bundle stays on the audited jsbn implementation. Round-trips
identically through every API; switch back to jsbn with
new NodeRSA(key, { bigIntImpl: 'jsbn' })if you ever need to.The
bigIntImploption (also accepted bysetOptions) must be setBEFORE the key is imported or generated; switching it on an instance
that already has key components throws, since the two implementations
produce incompatible BigInteger instances.
The browser bundle silently falls back to jsbn on runtimes without
globalThis.BigInt(i.e. pre-2020 environments). No user action needed.Breaking changes
Min Node.js is now 20. v1 worked back to Node 8.11; v2 requires Node 20+
for
node:crypto,globalThis.crypto, and modern ESM features.Module shape: ESM-first.
package.json#exportsprovides a dual ESM/CJSlayout —
import NodeRSA from 'node-rsa'for ESM,require('node-rsa').defaultfor CommonJS.Browser default return type is
Uint8Array(wasBuffervia polyfill).Node return type stays
Buffer(which extendsUint8Array, so mostexisting consumers continue to work). Internal byte handling is
Uint8Arrayend-to-end; the Node entry wraps results as
Bufferat the API boundary.No more
Bufferorcryptoshims for browsers. The browser bundlecontains zero Node-builtin imports — verified in CI by a
grepoverdist/index.browser.js. Bundlers (Vite, Webpack 5, Rollup, esbuild, Parcel)resolve the browser entry via package.json conditional exports.
setOptions({environment})is a deprecated no-op. Build-time platformconditions decide the runtime now. The option still forces the pure-JS
engine path when set to
'browser', preserving the v1 semantic that the61-case test suite relies on. A one-time
console.warnis emitted on use.MD4 is Node-only and provider-gated. OpenSSL 3 (Node 17+) doesn't load
the legacy provider by default, so
crypto.createHash('md4')throws. v2probes at module load and reports md4 as unsupported when the provider is
absent. The browser bundle never supports MD4.
asn1npm dependency removed. PKCS#1, PKCS#8, and OpenSSH formats nowuse a small in-tree DER reader/writer (~150 lines, under
src/asn1/). Byte-identical to v1 output for every fixture key.Native PKCS#1 v1.5
privateDecryptis routed through the JS engine onmodern Node. Node has security-deprecated raw PKCS#1 v1.5 decryption (CVE
response); v2 transparently falls back to the pure-JS implementation so the
call still succeeds. The byte-for-byte plaintext is identical.
Default signing scheme switched from
pkcs1(PKCS#1 v1.5) topss(RSASSA-PSS). PSS is the modern best-practice signing scheme — it has
a tighter security reduction and is preferred by RFC 8017 / NIST for new
code. Existing signatures produced under the v1 default remain verifiable
by passing
signingScheme: 'pkcs1'explicitly.The bare-hash shorthand
setOptions({ signingScheme: 'sha256' })also resolves to
pss-sha256(waspkcs1-sha256in v1). SetsigningScheme: 'pkcs1-sha256'explicitly to keep v1 behaviour.Custom MGF for PSS now throws on the node bundle.
node:cryptoonly supports MGF1 with hash equal to the signing hash. If you need a
non-default MGF, force the pure-JS path with
setOptions({ environment: 'browser' }).Hash algorithms unsupported by the local OpenSSL build now throw at
sign/verify time on the node bundle. Functionally equivalent to v1
(the JS scheme delegated to
nodeBackend.digestwhich also threw) —only the error wording and call-site changed.
Security fixes (no API change)
style padding-oracle (~10⁵ queries to recover plaintext given a timing
oracle). Includes a missing
Y == 0x00check on the leading byte and apost-decode message-length bound.
Bleichenbacher / ROBOT). Closes the internal differential timing oracle;
the valid/invalid binary oracle inherent to PKCS#1 v1.5 remains — use
OAEP for untrusted ciphertexts (the README has a security note).
2003 defence). Fresh
r ← random coprime to nmasks the variable-timemodPowfrom any timing leak ond,dmp1, ordmq1.Math.random()over a 168-element fixed table — adversarial-pseudoprime risk) and now
honours the caller's full round count (was silently halved). Keygen
picks adaptive rounds by bit length per FIPS 186-4 Table C.3.
1 < ewith e odd(RFC 8017 §3.1).
0 ≤ x < nenforced in both$doPrivateand$doPublic(RFC 8017 §3.2).verify()translatesthe resulting out-of-range error to "invalid signature" per §8.x.
n = p·q,dp ≡ d mod (p−1),dq ≡ d mod (q−1),q·coeff ≡ 1 mod p,e·dp ≡ 1 mod (p−1),e·dq ≡ 1 mod (q−1). Closes a Boneh-DeMillo-Lipton fault-injection vector on crafted PEM/PKCS#8/OpenSSH files.
generate(B)refusesB < 512(cryptographically broken) andemits a one-shot
console.warnforB < 2048(below NIST SP 800-56B§6.1.6.2 minimum).
|p − q| < 2^(B/2 − 100)(FIPS 186-4 §B.3.6).while (xp < xq) xp += ploop.SshReader.readStringbounds-checksbefore
subarray; the two private-section checkints (checkint1,checkint2) are now validated for equality.{0, 1} (RFC 5958 §2); inner PKCS#1 version restricted to two-prime
(RFC 8017 §A.1.2); algorithm OID whitelist with clear diagnostics for
PSS-only (1.2.840.113549.1.1.10) and OAEP-only (.1.1.7) misuse.
Added
NodeRSAOptions,EncryptionSchemeOptions,SigningSchemeOptions,HashAlg, formatstring union types).
@noble/hashesruntime dependency for synchronous SHA/MD/RIPEMD digestsin the browser bundle. ~6 KB gzipped, audited, zero-dep.
dist/index.browser.js: <100 KB raw / <30 KB gzipped (currently 90/21)dist/index.node.{js,cjs}: <120 KB raw / <35 KB gzipped (currently 94/22)Internal
tsupfor build (esbuild),vitestfor tests (with aworkspace running every spec in two projects —
nodeandbrowser-emulated),biomefor lint+format, strict TypeScript withnoUncheckedIndexedAccess/exactOptionalPropertyTypes/noImplicitOverrideetc.it()blocks isported verbatim and runs in both vitest projects.
Configuration
📅 Schedule: (UTC)
🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.
♻ Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about this update again.
This PR was generated by Mend Renovate. View the repository job log.