Skip to content

Commit 0764bc4

Browse files
committed
Revert "crypto: add crypto.timingSafeEqual"
This reverts commit 0fc5e0d. Additional testing indicates that there may still be timing issues with this implementation. Revert in order to give more time for testing before this goes out into a release... Refs: #8040 Refs: #8203 PR-URL: #8225 Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]>
1 parent e3cb0bf commit 0764bc4

File tree

5 files changed

+0
-178
lines changed

5 files changed

+0
-178
lines changed

doc/api/crypto.md

-9
Original file line numberDiff line numberDiff line change
@@ -1217,15 +1217,6 @@ keys:
12171217

12181218
All paddings are defined in `crypto.constants`.
12191219

1220-
### crypto.timingSafeEqual(a, b)
1221-
1222-
Returns true if `a` is equal to `b`, without leaking timing information that
1223-
would allow an attacker to guess one of the values. This is suitable for
1224-
comparing HMAC digests or secret values like authentication cookies or
1225-
[capability urls](https://www.w3.org/TR/capability-urls/).
1226-
1227-
`a` and `b` must both be `Buffer`s, and they must have the same length.
1228-
12291220
### crypto.privateEncrypt(private_key, buffer)
12301221

12311222
Encrypts `buffer` with `private_key`.

lib/crypto.js

-3
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ const getHashes = binding.getHashes;
1616
const getCurves = binding.getCurves;
1717
const getFipsCrypto = binding.getFipsCrypto;
1818
const setFipsCrypto = binding.setFipsCrypto;
19-
const timingSafeEqual = binding.timingSafeEqual;
2019

2120
const Buffer = require('buffer').Buffer;
2221
const stream = require('stream');
@@ -650,8 +649,6 @@ Object.defineProperty(exports, 'fips', {
650649
set: setFipsCrypto
651650
});
652651

653-
exports.timingSafeEqual = timingSafeEqual;
654-
655652
// Legacy API
656653
Object.defineProperty(exports, 'createCredentials', {
657654
configurable: true,

src/node_crypto.cc

-17
Original file line numberDiff line numberDiff line change
@@ -5771,22 +5771,6 @@ void ExportChallenge(const FunctionCallbackInfo<Value>& args) {
57715771
args.GetReturnValue().Set(outString);
57725772
}
57735773

5774-
void TimingSafeEqual(const FunctionCallbackInfo<Value>& args) {
5775-
Environment* env = Environment::GetCurrent(args);
5776-
5777-
THROW_AND_RETURN_IF_NOT_BUFFER(args[0], "First argument");
5778-
THROW_AND_RETURN_IF_NOT_BUFFER(args[1], "Second argument");
5779-
5780-
size_t buf_length = Buffer::Length(args[0]);
5781-
if (buf_length != Buffer::Length(args[1])) {
5782-
return env->ThrowTypeError("Input buffers must have the same length");
5783-
}
5784-
5785-
const char* buf1 = Buffer::Data(args[0]);
5786-
const char* buf2 = Buffer::Data(args[1]);
5787-
5788-
return args.GetReturnValue().Set(CRYPTO_memcmp(buf1, buf2, buf_length) == 0);
5789-
}
57905774

57915775
void InitCryptoOnce() {
57925776
OPENSSL_config(NULL);
@@ -5919,7 +5903,6 @@ void InitCrypto(Local<Object> target,
59195903
env->SetMethod(target, "setFipsCrypto", SetFipsCrypto);
59205904
env->SetMethod(target, "PBKDF2", PBKDF2);
59215905
env->SetMethod(target, "randomBytes", RandomBytes);
5922-
env->SetMethod(target, "timingSafeEqual", TimingSafeEqual);
59235906
env->SetMethod(target, "getSSLCiphers", GetSSLCiphers);
59245907
env->SetMethod(target, "getCiphers", GetCiphers);
59255908
env->SetMethod(target, "getHashes", GetHashes);

test/sequential/sequential.status

-5
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,6 @@ prefix sequential
66

77
[true] # This section applies to all platforms
88

9-
# crypto.timingSafeEqual contains a statistical timing test to verify that the
10-
# function is timing-safe. As a result, the test sometimes fails due to random
11-
# timing fluctuations.
12-
test-crypto-timing-safe-equal : PASS,FLAKY
13-
149
[$system==win32]
1510

1611
[$system==linux]

test/sequential/test-crypto-timing-safe-equal.js

-144
This file was deleted.

0 commit comments

Comments
 (0)