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

[crypto] Clarify the status of crypto keys APIs #3051

Merged
merged 1 commit into from
Nov 12, 2024
Merged
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
16 changes: 8 additions & 8 deletions src/node/crypto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -285,14 +285,14 @@ export default {
// * [x] crypto.createHash(algorithm[, options])
// * [x] crypto.createHmac(algorithm, key[, options])
// * [x] crypto.getHashes()
// * Keys
// * [ ] crypto.createPrivateKey(key)
// * [ ] crypto.createPublicKey(key)
// * [x] crypto.createSecretKey(key[, encoding])
// * [x] crypto.generateKey(type, options, callback)
// * [x] crypto.generateKeyPair(type, options, callback)
// * [x] crypto.generateKeyPairSync(type, options)
// * [x] crypto.generateKeySync(type, options)
// * Keys, not implemented yet. Calling the following APIs will throw a ERR_METHOD_NOT_IMPLEMENTED
// * [.] crypto.createPrivateKey(key)
// * [.] crypto.createPublicKey(key)
// * [.] crypto.createSecretKey(key[, encoding])
// * [.] crypto.generateKey(type, options, callback)
// * [.] crypto.generateKeyPair(type, options, callback)
// * [.] crypto.generateKeyPairSync(type, options)
// * [.] crypto.generateKeySync(type, options)
// * Sign/Verify
// * [ ] crypto.createSign(algorithm[, options])
// * [ ] crypto.createVerify(algorithm[, options])
Expand Down
20 changes: 4 additions & 16 deletions src/node/internal/crypto_keys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -438,21 +438,15 @@ export function generateKey(
_options: GenerateKeyOptions,
callback: GenerateKeyCallback
) {
// We intentionally have not implemented key generation up to this point.
// The reason is that generation of cryptographically safe keys is a CPU
// intensive operation that can often exceed limits on the amount of CPU
// time a worker is allowed.
// This API is not implemented yet.
callback(new ERR_METHOD_NOT_IMPLEMENTED('crypto.generateKeySync'));
}

export function generateKeySync(
_type: SecretKeyType,
_options: GenerateKeyOptions
) {
// We intentionally have not implemented key generation up to this point.
// The reason is that generation of cryptographically safe keys is a CPU
// intensive operation that can often exceed limits on the amount of CPU
// time a worker is allowed.
// This API is not implemented yet.
throw new ERR_METHOD_NOT_IMPLEMENTED('crypto.generateKeySync');
}

Expand All @@ -461,20 +455,14 @@ export function generateKeyPair(
_options: GenerateKeyPairOptions,
callback: GenerateKeyPairCallback
) {
// We intentionally have not implemented key generation up to this point.
// The reason is that generation of cryptographically safe keys is a CPU
// intensive operation that can often exceed limits on the amount of CPU
// time a worker is allowed.
// This API is not implemented yet.
callback(new ERR_METHOD_NOT_IMPLEMENTED('crypto.generateKeyPair'));
}

export function generateKeyPairSync(
_type: AsymmetricKeyType,
_options: GenerateKeyPairOptions
): KeyObjectPair {
// We intentionally have not implemented key generation up to this point.
// The reason is that generation of cryptographically safe keys is a CPU
// intensive operation that can often exceed limits on the amount of CPU
// time a worker is allowed.
// This API is not implemented yet.
throw new ERR_METHOD_NOT_IMPLEMENTED('crypto.generateKeyPairSync');
}