diff options
author | Divy Srivastava <dj.srivastava23@gmail.com> | 2024-10-16 14:27:28 +0530 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-10-16 14:27:28 +0530 |
commit | 21fa953f320c66a897822c4c731b2fae5f07c78b (patch) | |
tree | ff12dcf66b5712b493042e171309514d09856d23 /tests/unit_node | |
parent | 661882f10df198faf0df8f85493ee53ab64fbc97 (diff) |
fix(ext/node): timingSafeEqual account for AB byteOffset (#26292)
Fixes https://github.com/denoland/deno/issues/26276
Diffstat (limited to 'tests/unit_node')
-rw-r--r-- | tests/unit_node/crypto/crypto_misc_test.ts | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/tests/unit_node/crypto/crypto_misc_test.ts b/tests/unit_node/crypto/crypto_misc_test.ts index 47a48b1bf..007009339 100644 --- a/tests/unit_node/crypto/crypto_misc_test.ts +++ b/tests/unit_node/crypto/crypto_misc_test.ts @@ -1,5 +1,6 @@ // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. -import { randomFillSync, randomUUID } from "node:crypto"; +import { randomFillSync, randomUUID, timingSafeEqual } from "node:crypto"; +import { Buffer } from "node:buffer"; import { assert, assertEquals } from "../../unit/test_util.ts"; import { assertNotEquals } from "@std/assert"; @@ -28,3 +29,10 @@ Deno.test("[node/crypto.randomFillSync] array buffer view", () => { assertEquals(buf.subarray(0, 8), new Uint8Array(8)); assertEquals(buf.subarray(24, 32), new Uint8Array(8)); }); + +Deno.test("[node/crypto.timingSafeEqual] compares equal Buffer with different byteOffset", () => { + const a = Buffer.from([212, 213]); + const b = Buffer.from([0, 0, 0, 0, 0, 0, 0, 0, 212, 213]).subarray(8); + + assert(timingSafeEqual(a, b)); +}); |