MCPcopy Create free account
hub / github.com/Moddable-OpenSource/moddable / calculateMac

Function calculateMac

modules/crypt/ssl/ssl_record.js:110–123  ·  view source on GitHub ↗
(hmac, seqNum, type, version, content)

Source from the content-addressed store, hash-verified

108 tlsCipherText: {
109 name: "tlsCipherText",
110 calculateMac(hmac, seqNum, type, version, content) {
111 hmac.reset();
112 seqNum = ArrayBuffer.fromBigInt(seqNum);
113 let stream = new SSLStream();
114 for (let len = 8 - seqNum.byteLength; len > 0; len--)
115 stream.writeChar(0);
116 stream.writeChunk(seqNum);
117 stream.writeChar(type);
118 stream.writeChars(version, 2);
119 stream.writeChars(content.byteLength, 2);
120 hmac.update(stream.getChunk());
121 hmac.update(content);
122 return hmac.close();
123 },
124 aeadAdditionalData(seqNum, type, version, len) {
125 const c = ArrayBuffer.fromBigInt(seqNum, 8);
126 let tmps = new SSLStream(undefined, c.byteLength + 1 + 2 + 2);

Callers

nothing calls this directly

Calls 8

writeCharMethod · 0.95
writeChunkMethod · 0.95
writeCharsMethod · 0.95
getChunkMethod · 0.95
fromBigIntMethod · 0.80
closeMethod · 0.65
resetMethod · 0.45
updateMethod · 0.45

Tested by

no test coverage detected