crypto: fix unsigned conversion of 4-byte RSA publicExponent · nodejs/node@16e8c2b · GitHub
Skip to content

Commit 16e8c2b

Browse files
deepview-autofixclaudeChALkeR
authored andcommitted
crypto: fix unsigned conversion of 4-byte RSA publicExponent
`bigIntArrayToUnsignedInt` used the signed `<<` operator, so when the most significant byte of a 4-byte input had its top bit set (e.g. `[0x80, 0x00, 0x00, 0x01]`) the result was a negative Int32 instead of the intended unsigned 32-bit value. This caused any RSA `publicExponent` exactly 4 bytes long with the top bit set to be parsed incorrectly. Coerce the final value with `>>> 0` and add a unit test. Assisted-by: Claude <noreply@anthropic.com> Co-Authored-By: Claude <noreply@anthropic.com> Co-Authored-By: DeepView Autofix <276251120+deepview-autofix@users.noreply.github.com> Co-Authored-By: Nikita Skovoroda <chalkerx@gmail.com> Signed-off-by: Nikita Skovoroda <chalkerx@gmail.com> PR-URL: #62839 Reviewed-By: Filip Skokan <panva.ip@gmail.com>
1 parent c23db1c commit 16e8c2b

2 files changed

Lines changed: 20 additions & 1 deletion

File tree

lib/internal/crypto/util.js

Lines changed: 1 addition & 1 deletion

test/parallel/test-webcrypto-util.js

Lines changed: 19 additions & 0 deletions

0 commit comments

Comments
 (0)