Skip to content

Commit cd1415c

Browse files
tniessenmarco-ippolito
authored andcommittedJun 12, 2024·
Revert "crypto: make timingSafeEqual faster for Uint8Array"
This reverts commit 0f784c9 because it triggers a bug in the V8 version that Node.js 20.x uses. PR-URL: #53390 Reviewed-By: Richard Lau <rlau@redhat.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Yagiz Nizipli <yagiz.nizipli@sentry.io> Reviewed-By: Filip Skokan <panva.ip@gmail.com> Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
1 parent af614c5 commit cd1415c

File tree

3 files changed

+2
-52
lines changed

3 files changed

+2
-52
lines changed
 

‎benchmark/crypto/timingSafeEqual.js

-22
This file was deleted.

‎src/crypto/crypto_timing.cc

+2-24
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99

1010
namespace node {
1111

12-
using v8::FastApiCallbackOptions;
13-
using v8::FastApiTypedArray;
1412
using v8::FunctionCallbackInfo;
1513
using v8::Local;
1614
using v8::Object;
@@ -48,32 +46,12 @@ void TimingSafeEqual(const FunctionCallbackInfo<Value>& args) {
4846
CRYPTO_memcmp(buf1.data(), buf2.data(), buf1.size()) == 0);
4947
}
5048

51-
bool FastTimingSafeEqual(Local<Value> receiver,
52-
const FastApiTypedArray<uint8_t>& a,
53-
const FastApiTypedArray<uint8_t>& b,
54-
// NOLINTNEXTLINE(runtime/references)
55-
FastApiCallbackOptions& options) {
56-
uint8_t* data_a;
57-
uint8_t* data_b;
58-
if (a.length() != b.length() || !a.getStorageIfAligned(&data_a) ||
59-
!b.getStorageIfAligned(&data_b)) {
60-
options.fallback = true;
61-
return false;
62-
}
63-
64-
return CRYPTO_memcmp(data_a, data_b, a.length()) == 0;
65-
}
66-
67-
static v8::CFunction fast_equal(v8::CFunction::Make(FastTimingSafeEqual));
68-
6949
void Initialize(Environment* env, Local<Object> target) {
70-
SetFastMethodNoSideEffect(
71-
env->context(), target, "timingSafeEqual", TimingSafeEqual, &fast_equal);
50+
SetMethodNoSideEffect(
51+
env->context(), target, "timingSafeEqual", TimingSafeEqual);
7252
}
7353
void RegisterExternalReferences(ExternalReferenceRegistry* registry) {
7454
registry->Register(TimingSafeEqual);
75-
registry->Register(FastTimingSafeEqual);
76-
registry->Register(fast_equal.GetTypeInfo());
7755
}
7856
} // namespace Timing
7957

‎src/node_external_reference.h

-6
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,6 @@ using CFunctionCallbackWithStrings =
2727
bool (*)(v8::Local<v8::Value>,
2828
const v8::FastOneByteString& input,
2929
const v8::FastOneByteString& base);
30-
using CFunctionCallbackWithTwoUint8ArraysFallback =
31-
bool (*)(v8::Local<v8::Value>,
32-
const v8::FastApiTypedArray<uint8_t>&,
33-
const v8::FastApiTypedArray<uint8_t>&,
34-
v8::FastApiCallbackOptions&);
3530
using CFunctionWithUint32 = uint32_t (*)(v8::Local<v8::Value>,
3631
const uint32_t input);
3732
using CFunctionWithDoubleReturnDouble = double (*)(v8::Local<v8::Value>,
@@ -56,7 +51,6 @@ class ExternalReferenceRegistry {
5651
V(CFunctionCallbackWithBool) \
5752
V(CFunctionCallbackWithString) \
5853
V(CFunctionCallbackWithStrings) \
59-
V(CFunctionCallbackWithTwoUint8ArraysFallback) \
6054
V(CFunctionWithUint32) \
6155
V(CFunctionWithDoubleReturnDouble) \
6256
V(CFunctionWithInt64Fallback) \

0 commit comments

Comments
 (0)
Please sign in to comment.