Skip to content

Commit e844773

Browse files
victorgomespthier
authored andcommitted
Remove use of deprecated type v8::FastApiTypedArray (nodejs#197)
1 parent e9d2810 commit e844773

File tree

3 files changed

+3
-65
lines changed

3 files changed

+3
-65
lines changed

src/crypto/crypto_timing.cc

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -50,35 +50,11 @@ void TimingSafeEqual(const FunctionCallbackInfo<Value>& args) {
5050
CRYPTO_memcmp(buf1.data(), buf2.data(), buf1.size()) == 0);
5151
}
5252

53-
bool FastTimingSafeEqual(Local<Value> receiver,
54-
const FastApiTypedArray<uint8_t>& a,
55-
const FastApiTypedArray<uint8_t>& b,
56-
// NOLINTNEXTLINE(runtime/references)
57-
FastApiCallbackOptions& options) {
58-
uint8_t* data_a;
59-
uint8_t* data_b;
60-
if (a.length() != b.length() || !a.getStorageIfAligned(&data_a) ||
61-
!b.getStorageIfAligned(&data_b)) {
62-
TRACK_V8_FAST_API_CALL("crypto.timingSafeEqual.error");
63-
HandleScope scope(options.isolate);
64-
THROW_ERR_CRYPTO_TIMING_SAFE_EQUAL_LENGTH(options.isolate);
65-
return false;
66-
}
67-
68-
TRACK_V8_FAST_API_CALL("crypto.timingSafeEqual.ok");
69-
return CRYPTO_memcmp(data_a, data_b, a.length()) == 0;
70-
}
71-
72-
static v8::CFunction fast_equal(v8::CFunction::Make(FastTimingSafeEqual));
73-
7453
void Initialize(Environment* env, Local<Object> target) {
75-
SetFastMethodNoSideEffect(
76-
env->context(), target, "timingSafeEqual", TimingSafeEqual, &fast_equal);
54+
SetMethod(env->context(), target, "timingSafeEqual", TimingSafeEqual);
7755
}
7856
void RegisterExternalReferences(ExternalReferenceRegistry* registry) {
7957
registry->Register(TimingSafeEqual);
80-
registry->Register(FastTimingSafeEqual);
81-
registry->Register(fast_equal.GetTypeInfo());
8258
}
8359
} // namespace Timing
8460

src/node_buffer.cc

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -862,24 +862,6 @@ void Compare(const FunctionCallbackInfo<Value> &args) {
862862
args.GetReturnValue().Set(val);
863863
}
864864

865-
int32_t FastCompare(v8::Local<v8::Value>,
866-
const FastApiTypedArray<uint8_t>& a,
867-
const FastApiTypedArray<uint8_t>& b) {
868-
uint8_t* data_a;
869-
uint8_t* data_b;
870-
CHECK(a.getStorageIfAligned(&data_a));
871-
CHECK(b.getStorageIfAligned(&data_b));
872-
873-
size_t cmp_length = std::min(a.length(), b.length());
874-
875-
return normalizeCompareVal(
876-
cmp_length > 0 ? memcmp(data_a, data_b, cmp_length) : 0,
877-
a.length(),
878-
b.length());
879-
}
880-
881-
static v8::CFunction fast_compare(v8::CFunction::Make(FastCompare));
882-
883865
// Computes the offset for starting an indexOf or lastIndexOf search.
884866
// Returns either a valid offset in [0...<length - 1>], ie inside the Buffer,
885867
// or -1 to signal that there is no possible match.
@@ -1549,8 +1531,8 @@ void Initialize(Local<Object> target,
15491531
"byteLengthUtf8",
15501532
SlowByteLengthUtf8,
15511533
&fast_byte_length_utf8);
1552-
SetFastMethod(context, target, "copy", SlowCopy, &fast_copy);
1553-
SetFastMethodNoSideEffect(context, target, "compare", Compare, &fast_compare);
1534+
SetMethod(context, target, "copy", Copy);
1535+
SetMethod(context, target, "compare", Compare);
15541536
SetMethodNoSideEffect(context, target, "compareOffset", CompareOffset);
15551537
SetMethod(context, target, "fill", Fill);
15561538
SetMethodNoSideEffect(context, target, "indexOfBuffer", IndexOfBuffer);
@@ -1628,8 +1610,6 @@ void RegisterExternalReferences(ExternalReferenceRegistry* registry) {
16281610
registry->Register(fast_copy.GetTypeInfo());
16291611
registry->Register(FastCopy);
16301612
registry->Register(Compare);
1631-
registry->Register(FastCompare);
1632-
registry->Register(fast_compare.GetTypeInfo());
16331613
registry->Register(CompareOffset);
16341614
registry->Register(Fill);
16351615
registry->Register(IndexOfBuffer);

src/node_external_reference.h

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -41,21 +41,6 @@ using CFunctionCallbackWithStrings =
4141
bool (*)(v8::Local<v8::Value>,
4242
const v8::FastOneByteString& input,
4343
const v8::FastOneByteString& base);
44-
using CFunctionCallbackWithTwoUint8Arrays =
45-
int32_t (*)(v8::Local<v8::Value>,
46-
const v8::FastApiTypedArray<uint8_t>&,
47-
const v8::FastApiTypedArray<uint8_t>&);
48-
using CFunctionCallbackWithTwoUint8ArraysFallback =
49-
bool (*)(v8::Local<v8::Value>,
50-
const v8::FastApiTypedArray<uint8_t>&,
51-
const v8::FastApiTypedArray<uint8_t>&,
52-
v8::FastApiCallbackOptions&);
53-
using CFunctionCallbackWithUint8ArrayUint32Int64Bool =
54-
int32_t (*)(v8::Local<v8::Value>,
55-
const v8::FastApiTypedArray<uint8_t>&,
56-
uint32_t,
57-
int64_t,
58-
bool);
5944
using CFunctionWithUint32 = uint32_t (*)(v8::Local<v8::Value>,
6045
const uint32_t input);
6146
using CFunctionWithDoubleReturnDouble = double (*)(v8::Local<v8::Value>,
@@ -102,9 +87,6 @@ class ExternalReferenceRegistry {
10287
V(CFunctionCallbackWithBool) \
10388
V(CFunctionCallbackWithString) \
10489
V(CFunctionCallbackWithStrings) \
105-
V(CFunctionCallbackWithTwoUint8Arrays) \
106-
V(CFunctionCallbackWithTwoUint8ArraysFallback) \
107-
V(CFunctionCallbackWithUint8ArrayUint32Int64Bool) \
10890
V(CFunctionWithUint32) \
10991
V(CFunctionWithDoubleReturnDouble) \
11092
V(CFunctionWithInt64Fallback) \

0 commit comments

Comments
 (0)