Commit ad376c3
crypto: fix argument validation in crypto.timingSafeEqual fast path
A regression introduced by
0136bb0
made it possible for the fast path to be hit with non-array-buffer
arguments despite that the fast paths could only deal with array
buffer arguments, so that it can crash with invalid arguments
once crypto.timingSafeEqual is optimized instead of throwing
validation errors as usual. This adds validation to the fast path
so that it throws correctly.
PR-URL: #60538
Fixes: #60537
Refs: nodejs-private/node-private#749
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>1 parent 3bf42a5 commit ad376c3Copy full SHA for ad376c3
File tree
Expand file treeCollapse file tree
3 files changed
+55
-26
lines changedOpen diff view settings
Filter options
- src/crypto
- test/sequential
Expand file treeCollapse file tree
3 files changed
+55
-26
lines changedOpen diff view settings
Collapse file
src/crypto/crypto_timing.cc
Copy file name to clipboardExpand all lines: src/crypto/crypto_timing.cc+14Lines changed: 14 additions & 0 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
56 | 56 | |
57 | 57 | |
58 | 58 | |
| 59 | + |
| 60 | + |
| 61 | + |
| 62 | + |
| 63 | + |
| 64 | + |
| 65 | + |
| 66 | + |
| 67 | + |
| 68 | + |
| 69 | + |
| 70 | + |
| 71 | + |
| 72 | + |
59 | 73 | |
60 | 74 | |
61 | 75 | |
|
Collapse file
test/sequential/test-crypto-timing-safe-equal-fast.js
Copy file name to clipboard+40Lines changed: 40 additions & 0 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
| 1 | + |
| 2 | + |
| 3 | + |
| 4 | + |
| 5 | + |
| 6 | + |
| 7 | + |
| 8 | + |
| 9 | + |
| 10 | + |
| 11 | + |
| 12 | + |
| 13 | + |
| 14 | + |
| 15 | + |
| 16 | + |
| 17 | + |
| 18 | + |
| 19 | + |
| 20 | + |
| 21 | + |
| 22 | + |
| 23 | + |
| 24 | + |
| 25 | + |
| 26 | + |
| 27 | + |
| 28 | + |
| 29 | + |
| 30 | + |
| 31 | + |
| 32 | + |
| 33 | + |
| 34 | + |
| 35 | + |
| 36 | + |
| 37 | + |
| 38 | + |
| 39 | + |
| 40 | + |
Collapse file
test/sequential/test-crypto-timing-safe-equal.js
Copy file name to clipboardExpand all lines: test/sequential/test-crypto-timing-safe-equal.js+1-26Lines changed: 1 addition & 26 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
1 | | - |
| 1 | + |
2 | 2 | |
3 | 3 | |
4 | 4 | |
| ||
92 | 92 | |
93 | 93 | |
94 | 94 | |
95 | | - |
96 | | - |
97 | | - |
98 | | - |
99 | | - |
100 | | - |
101 | | - |
102 | | - |
103 | | - |
104 | | - |
105 | | - |
106 | | - |
107 | | - |
108 | | - |
109 | | - |
110 | | - |
111 | | - |
112 | | - |
113 | | - |
114 | | - |
115 | | - |
116 | | - |
117 | | - |
118 | | - |
119 | | - |
0 commit comments