Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
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
20 changes: 20 additions & 0 deletions bench/crypto/constant-time-compare.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import crypto from "node:crypto";
import { bench, run } from "../runner.mjs";

// Both compares go through BoringSSL CRYPTO_memcmp.
for (const size of [16, 64, 256, 1024, 4096, 65536]) {
const bytes = crypto.randomBytes(size);
const copy = Buffer.from(bytes);
const key = crypto.createSecretKey(bytes);
const sameKey = crypto.createSecretKey(copy);

bench(`timingSafeEqual - ${size} bytes`, () => {
return crypto.timingSafeEqual(bytes, copy);
});

bench(`KeyObject.equals - ${size} bytes`, () => {
return key.equals(sameKey);
});
}

await run();
2 changes: 1 addition & 1 deletion scripts/build/deps/boringssl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { quote } from "../shell.ts";
import type { Dependency, DirectBuild } from "../source.ts";
import { LIBC_ALLOCATION_SYMBOLS, depSourceDir } from "../source.ts";

const BORINGSSL_COMMIT = "41bf9b59c2ebf277a7aa427e1ecad5cc80dd4d4f";
const BORINGSSL_COMMIT = "51a84a8111ef25fab67079b7734c2fed3b9f91e2";

export const boringssl: Dependency = {
name: "boringssl",
Expand Down
Loading