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

🐛 [bug] crypto.timingSafeEqual === undefined #2172

Closed
helloimalastair opened this issue May 27, 2024 · 1 comment · Fixed by #2216
Closed

🐛 [bug] crypto.timingSafeEqual === undefined #2172

helloimalastair opened this issue May 27, 2024 · 1 comment · Fixed by #2216
Assignees
Labels
api bug Something isn't working nodejs compat

Comments

@helloimalastair
Copy link
Contributor

Versions

[email protected]
[email protected]
[email protected]

Issue

According to Misc | Node Crypto, the timingSafeEqual function should be supported by nodejs_compat.

However, when logging import crypto from "node:crypto";, you see

{
	DiffieHellman: [Function: DiffieHellman],
	DiffieHellmanGroup: [Function: DiffieHellmanGroup],
	createDiffieHellman: [Function: createDiffieHellman],
	createDiffieHellmanGroup: [Function: createDiffieHellmanGroup],
	getDiffieHellman: [Function: getDiffieHellman],
	KeyObject: [class KeyObject],
	PublicKeyObject: [class PublicKeyObject extends AsymmetricKeyObject],
	PrivateKeyObject: [class PrivateKeyObject extends AsymmetricKeyObject],
	SecretKeyObject: [class SecretKeyObject extends KeyObject],
	generateKey: [Function: generateKey],
	generateKeyPair: [Function: generateKeyPair],
	generateKeyPairSync: [Function: generateKeyPairSync],
	generateKeySync: [Function: generateKeySync],
	createPrivateKey: [Function: createPrivateKey],
	createPublicKey: [Function: createPublicKey],
	createSecretKey: [Function: createSecretKey],
	getRandomValues: [Function: getRandomValues],
	randomBytes: [Function: randomBytes],
	randomFillSync: [Function: randomFillSync],
	randomFill: [Function: randomFill],
	randomInt: [Function: randomInt],
	randomUUID: [Function: randomUUID],
	generatePrime: [Function: generatePrime],
	generatePrimeSync: [Function: generatePrimeSync],
	checkPrime: [Function: checkPrime],
	checkPrimeSync: [Function: checkPrimeSync],
	Hash: [Function: Hash],
	Hmac: [Function: Hmac],
	createHash: [Function: createHash],
	createHmac: [Function: createHmac],
	getHashes: [Function: getHashes],
	hkdf: [Function: hkdf],
	hkdfSync: [Function: hkdfSync],
	pbkdf2: [Function: pbkdf2],
	pbkdf2Sync: [Function: pbkdf2Sync],
	getCiphers: [Function: getCiphers],
	getCurves: [Function: getCurves],
	secureHeapUsed: [Function: secureHeapUsed],
	setEngine: [Function: setEngine],
	timingSafeEqual: undefined,
	getFips: [Function: getFips],
	setFips: [Function: setFips],
	fips: [Getter/Setter],
	subtle: SubtleCrypto {},
	webcrypto: Crypto { subtle: SubtleCrypto {} }
}

where it appears that timingSafeEqual is defined as undefined...

@DaniFoldi
Copy link
Contributor

Probably
https://github.com/cloudflare/workerd/blame/2646a2a245c44125c22d55ef8200a71b17844a53/src/node/crypto.ts#L13
needs to be

export const timingSafeEqual = crypto.subtle.timingSafeEqual;

For some reason, node crypto and web crypto define it in different places, I remember this from miniflare 2 😅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api bug Something isn't working nodejs compat
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants