Skip to content

Commit

Permalink
[crypto] Clarify the status of crypto keys APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
vicb committed Nov 4, 2024
1 parent 7e1333e commit 8b89318
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 24 deletions.
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');
}

0 comments on commit 8b89318

Please sign in to comment.