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

Function cfrgExportKey

lib/internal/crypto/cfrg.js:91–115  ·  view source on GitHub ↗
(key, format)

Source from the content-addressed store, hash-verified

89}
90
91function cfrgExportKey(key, format) {
92 try {
93 switch (format) {
94 case kWebCryptoKeyFormatRaw: {
95 const handle = getCryptoKeyHandle(key);
96 return TypedArrayPrototypeGetBuffer(
97 getCryptoKeyType(key) === 'private' ? handle.rawPrivateKey() : handle.rawPublicKey());
98 }
99 case kWebCryptoKeyFormatSPKI: {
100 return TypedArrayPrototypeGetBuffer(
101 getCryptoKeyHandle(key).export(kKeyFormatDER, kWebCryptoKeyFormatSPKI));
102 }
103 case kWebCryptoKeyFormatPKCS8: {
104 return TypedArrayPrototypeGetBuffer(
105 getCryptoKeyHandle(key).export(kKeyFormatDER, kWebCryptoKeyFormatPKCS8, null, null));
106 }
107 default:
108 return undefined;
109 }
110 } catch (err) {
111 throw lazyDOMException(
112 'The operation failed for an operation-specific reason',
113 { name: 'OperationError', cause: err });
114 }
115}
116
117function cfrgImportKey(
118 format,

Callers

nothing calls this directly

Calls 4

getCryptoKeyHandleFunction · 0.85
getCryptoKeyTypeFunction · 0.85
lazyDOMExceptionFunction · 0.85
exportMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…