| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent c23db1c commit 16e8c2b
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -684,7 +684,7 @@ function bigIntArrayToUnsignedInt(input) { | |||
| 684 | 684 | result |= input[n] << 8 * n_reversed; | |
| 685 | 685 | } | |
| 686 | 686 | ||
| 687 | - return result; | ||
| 687 | + return result >>> 0; | ||
| 688 | 688 | } | |
| 689 | 689 | ||
| 690 | 690 | function bigIntArrayToUnsignedBigInt(input) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -8,10 +8,29 @@ if (!common.hasCrypto) | |||
| 8 | 8 | const assert = require('assert'); | |
| 9 | 9 | ||
| 10 | 10 | const { | |
| 11 | + bigIntArrayToUnsignedInt, | ||
| 11 | 12 | normalizeAlgorithm, | |
| 12 | 13 | validateKeyOps, | |
| 13 | 14 | } = require('internal/crypto/util'); | |
| 14 | 15 | ||
| 16 | + // bigIntArrayToUnsignedInt must return an unsigned 32-bit value even when | ||
| 17 | + // the most significant byte has its top bit set. Otherwise the signed `<<` | ||
| 18 | + // operator yields a negative Int32 for inputs like [0x80, 0x00, 0x00, 0x01]. | ||
| 19 | + { | ||
| 20 | + assert.strictEqual( | ||
| 21 | + bigIntArrayToUnsignedInt(new Uint8Array([0x80, 0x00, 0x00, 0x01])), | ||
| 22 | + 0x80000001); | ||
| 23 | + assert.strictEqual( | ||
| 24 | + bigIntArrayToUnsignedInt(new Uint8Array([0xff, 0xff, 0xff, 0xff])), | ||
| 25 | + 0xffffffff); | ||
| 26 | + assert.strictEqual( | ||
| 27 | + bigIntArrayToUnsignedInt(new Uint8Array([1, 0, 1])), | ||
| 28 | + 65537); | ||
| 29 | + assert.strictEqual( | ||
| 30 | + bigIntArrayToUnsignedInt(new Uint8Array([1, 0, 0, 0, 0])), | ||
| 31 | + undefined); | ||
| 32 | + } | ||
| 33 | + | ||
| 15 | 34 | { | |
| 16 | 35 | // Check that normalizeAlgorithm does not mutate object inputs. | |
| 17 | 36 | const algorithm = { name: 'ECDSA', hash: 'SHA-256' }; | |
| Back | FazBrowse Home | New Git URL |
0 commit comments