MCPcopy Index your code
hub / github.com/nodejs/node / validateAsymmetricKeyType

Function validateAsymmetricKeyType

lib/internal/crypto/keys.js:514–531  ·  view source on GitHub ↗
(type, ctx, key)

Source from the content-addressed store, hash-verified

512}
513
514function validateAsymmetricKeyType(type, ctx, key) {
515 if (ctx === kCreatePrivate) {
516 throw new ERR_INVALID_ARG_TYPE(
517 'key',
518 ['string', 'ArrayBuffer', 'Buffer', 'TypedArray', 'DataView'],
519 key,
520 );
521 }
522
523 if (type !== 'private') {
524 if (ctx === kConsumePrivate || ctx === kCreatePublic)
525 throw new ERR_CRYPTO_INVALID_KEY_OBJECT_TYPE(type, 'private');
526 if (type !== 'public') {
527 throw new ERR_CRYPTO_INVALID_KEY_OBJECT_TYPE(type,
528 'private or public');
529 }
530 }
531}
532
533function getKeyTypes(allowKeyObject, bufferOnly = false) {
534 const types = [

Callers 1

prepareAsymmetricKeyFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected