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

Function mlKemGenerateKey

lib/internal/crypto/ml_kem.js:58–80  ·  view source on GitHub ↗
(algorithm, extractable, usages)

Source from the content-addressed store, hash-verified

56 ['decapsulateKey', 'decapsulateBits']);
57
58function mlKemGenerateKey(algorithm, extractable, usages) {
59 const { name } = algorithm;
60 const usagesSet = validateKeyUsages(usages, kUsages.keygen, name);
61
62 const nid = {
63 '__proto__': null,
64 'ML-KEM-512': EVP_PKEY_ML_KEM_512,
65 'ML-KEM-768': EVP_PKEY_ML_KEM_768,
66 'ML-KEM-1024': EVP_PKEY_ML_KEM_1024,
67 }[name];
68
69 const keyAlgorithm = { name };
70 const keyUsages = getKeyPairUsages(usagesSet, kUsages);
71 validateUsagesNotEmpty(keyUsages.private);
72
73 return jobPromise(() => new NidKeyPairGenJob(
74 kCryptoJobWebCrypto,
75 nid,
76 keyAlgorithm,
77 getUsagesMask(keyUsages.public),
78 getUsagesMask(keyUsages.private),
79 extractable));
80}
81
82function mlKemExportKey(key, format) {
83 try {

Callers

nothing calls this directly

Calls 5

validateKeyUsagesFunction · 0.85
getKeyPairUsagesFunction · 0.85
validateUsagesNotEmptyFunction · 0.85
jobPromiseFunction · 0.85
getUsagesMaskFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…