FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
node/src/crypto/crypto_timing.cc at main · fetchapi/node · GitHub
fetchapi
/
node
Public
forked from
nodejs/node
Notifications
You must be signed in to change notification settings
Fork
1
Star
0
Code
Pull requests
1
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
node
/
src
/
crypto
/
crypto_timing.cc
Copy path
More file actions
More file actions
Latest commit
History
History
History
59 lines (50 loc) · 1.65 KB
Breadcrumbs
node
/
src
/
crypto
/
crypto_timing.cc
Copy path
File metadata and controls
59 lines (50 loc) · 1.65 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#
include
"
crypto/crypto_timing.h
"
#
include
"
crypto/crypto_util.h
"
#
include
"
env-inl.h
"
#
include
"
node_errors.h
"
#
include
"
v8.h
"
#
include
"
node.h
"
#
include
<
openssl/crypto.h
>
namespace
node
{
using
v8::FunctionCallbackInfo;
using
v8::Local;
using
v8::Object;
using
v8::Value;
namespace
crypto
{
namespace
Timing
{
void
TimingSafeEqual
(
const
FunctionCallbackInfo<Value>& args) {
//
Moving the type checking into JS leads to test failures, most likely due
//
to V8 inlining certain parts of the wrapper. Therefore, keep them in C++.
//
Refs: https://github.com/nodejs/node/issues/34073.
Environment* env =
Environment::GetCurrent
(args);
if
(!
IsAnyBufferSource
(args[
0
])) {
THROW_ERR_INVALID_ARG_TYPE
(
env,
"
The
\"
buf1
\"
argument must be an instance of
"
"
ArrayBuffer, Buffer, TypedArray, or DataView.
"
);
return
;
}
if
(!
IsAnyBufferSource
(args[
1
])) {
THROW_ERR_INVALID_ARG_TYPE
(
env,
"
The
\"
buf2
\"
argument must be an instance of
"
"
ArrayBuffer, Buffer, TypedArray, or DataView.
"
);
return
;
}
ArrayBufferOrViewContents<
char
>
buf1
(args[
0
]);
ArrayBufferOrViewContents<
char
>
buf2
(args[
1
]);
if
(buf1.
size
() != buf2.
size
()) {
THROW_ERR_CRYPTO_TIMING_SAFE_EQUAL_LENGTH
(env);
return
;
}
return
args.
GetReturnValue
().
Set
(
CRYPTO_memcmp
(buf1.
data
(), buf2.
data
(), buf1.
size
()) ==
0
);
}
void
Initialize
(Environment* env, Local<Object> target) {
SetMethodNoSideEffect
(
env->
context
(), target,
"
timingSafeEqual
"
, TimingSafeEqual);
}
void
RegisterExternalReferences
(ExternalReferenceRegistry* registry) {
registry->
Register
(TimingSafeEqual);
}
}
//
namespace Timing
}
//
namespace crypto
}
//
namespace node
Back
|
FazBrowse Home
|
New Git URL