Commit bad1e2f
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 f92cbc2 commit bad1e2fCopy full SHA for bad1e2f
2 files changed
+20-1Lines changed: 20 additions & 1 deletion
File tree
Expand file treeCollapse file tree
Open diff view settings
Filter options
- lib/internal/crypto
- test/parallel
Expand file treeCollapse file tree
Open diff view settings
Collapse file
lib/internal/crypto/util.js
Copy file name to clipboardExpand all lines: lib/internal/crypto/util.js+1-1Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
698 | 698 | |
699 | 699 | |
700 | 700 | |
701 | | - |
| 701 | + |
702 | 702 | |
703 | 703 | |
704 | 704 | |
|
Collapse file
test/parallel/test-webcrypto-util.js
Copy file name to clipboardExpand all lines: test/parallel/test-webcrypto-util.js+19Lines changed: 19 additions & 0 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
8 | 8 | |
9 | 9 | |
10 | 10 | |
| 11 | + |
11 | 12 | |
12 | 13 | |
13 | 14 | |
14 | 15 | |
| 16 | + |
| 17 | + |
| 18 | + |
| 19 | + |
| 20 | + |
| 21 | + |
| 22 | + |
| 23 | + |
| 24 | + |
| 25 | + |
| 26 | + |
| 27 | + |
| 28 | + |
| 29 | + |
| 30 | + |
| 31 | + |
| 32 | + |
| 33 | + |
15 | 34 | |
16 | 35 | |
17 | 36 | |
|
0 commit comments