Skip to content

Commit

Permalink
Merge pull request #2238 from cloudflare/jsnell/crypto-timingsafeequa…
Browse files Browse the repository at this point in the history
…l-regression
  • Loading branch information
jasnell authored Jun 7, 2024
2 parents dbc4d7f + 9767b28 commit c5ebbe2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/node/crypto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,12 @@ import {

export const getRandomValues = crypto.getRandomValues;
export const subtle = crypto.subtle;
export const timingSafeEqual = (subtle as any).timingSafeEqual;
export const webcrypto = crypto;

export function timingSafeEqual(a: any, b: any) {
return (subtle as any).timingSafeEqual(a, b);
}

import {
DiffieHellman,
DiffieHellmanGroup,
Expand Down
7 changes: 7 additions & 0 deletions src/workerd/api/node/crypto_random-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
generatePrimeSync,
checkPrime,
checkPrimeSync,
timingSafeEqual,
} from 'node:crypto';

import {
Expand Down Expand Up @@ -378,3 +379,9 @@ export const test = {
}
}
};

export const timingSafeEqualTest = {
test() {
timingSafeEqual(new Uint8Array(1), new Uint8Array(1));
}
};

0 comments on commit c5ebbe2

Please sign in to comment.