Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change timingSafeEqual to use byteLength. #21397

Closed
wants to merge 4 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
More descriptive errors if it does error this time.
... please don't error this time. You have no reason to.
  • Loading branch information
ZaneHannanAU authored Jun 26, 2018
commit 06a4f4f3a3d5cdc8331732b5bd44dc8c2780ab45
17 changes: 11 additions & 6 deletions test/sequential/test-crypto-timing-safe-equal.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@ assert.strictEqual(
assert.strictEqual(
crypto.timingSafeEqual(Uint8Array.of(1, 0), Uint16Array.of(1)),
true,
'should consider equal binary integers to be equal'
'should consider equal binary views to be equal' +
' (Uint8Array 1 0, Uint16Array 1)'
);

assert.strictEqual(
crypto.timingSafeEqual(Uint8Array.of(0, 1), Uint16Array.of(1)),
false,
'should consider unequal binary integers to be unequal'
'should consider unequal binary views to be unequal' +
' (Uint8Array 0 1, Uint16Array 1)'
);

assert.strictEqual(
Expand All @@ -30,16 +32,18 @@ assert.strictEqual(
BigUint64Array.of(1n)
),
true,
'should consider equal binary integers to be equal'
'should consider equal binary views to be equal' +
' (Uint8Array 1 ...0, BigUint64Array 1n)'
);

assert.strictEqual(
crypto.timingSafeEqual(
Buffer.allocUnsafe(8).fill(255),
Buffer.alloc(8, 255),
BigInt64Array.of(-1n)
),
true,
'should consider equal binary integers to be equal'
'should consider equal binary views to be equal' +
' (Buffer 0xFF, BigInt64Array -1)'
);

assert.strictEqual(
Expand All @@ -48,7 +52,8 @@ assert.strictEqual(
BigInt64Array.of(0n)
),
true,
'should consider equal views to be equal'
'should consider equal binary views to be equal' +
' (DataView, BigInt64Array)'
);

assert.strictEqual(
Expand Down