MCPcopy
hub / github.com/gchq/CyberChef / parseExtensions

Function parseExtensions

src/core/lib/TLS.mjs:317–353  ·  view source on GitHub ↗

* Parse Extensions * @param {Uint8Array} bytes * @returns {JSON}

(bytes)

Source from the content-addressed store, hash-verified

315 * @returns {JSON}
316 */
317function parseExtensions(bytes) {
318 const s = new Stream(bytes);
319 const b = s.clone();
320
321 const exts = [];
322 while (s.hasMore()) {
323 const ext = {};
324
325 // Type
326 ext.type = {
327 description: "Extension Type",
328 length: 2,
329 data: b.getBytes(2),
330 value: EXTENSION_LOOKUP[s.readInt(2)] || "unknown"
331 };
332
333 // Length
334 ext.length = {
335 description: "Extension Length",
336 length: 2,
337 data: b.getBytes(2),
338 value: s.readInt(2)
339 };
340
341 // Value
342 ext.value = {
343 description: "Extension Value",
344 length: ext.length.value,
345 data: b.getBytes(ext.length.value),
346 value: s.getBytes(ext.length.value)
347 };
348
349 exts.push(ext);
350 }
351
352 return exts;
353}
354
355/**
356 * Extension type lookup table

Callers 2

parseClientHelloFunction · 0.85
parseServerHelloFunction · 0.85

Calls 4

cloneMethod · 0.95
hasMoreMethod · 0.95
getBytesMethod · 0.95
readIntMethod · 0.95

Tested by

no test coverage detected