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

Method init

modules/crypt/etc/gcm.js:51–66  ·  view source on GitHub ↗
(iv, aad)

Source from the content-addressed store, hash-verified

49 this.zero = new ArrayBuffer(this.block.blockSize);
50 };
51 init(iv, aad) {
52 let h = this.block.encrypt(this.zero);
53 this.ghash = new GHASH(h, aad);
54 if (iv.byteLength == 12) {
55 iv = iv.concat(one);
56 }
57 else {
58 let ghash = new GHASH(h);
59 iv = ghash.process(iv);
60 }
61 this.y0 = iv;
62 // start with y1
63 let y1 = BigInt.fromArrayBuffer(iv);
64 y1++;
65 this.ctr.setIV(ArrayBuffer.fromBigInt(y1));
66 }
67 encrypt(data, buf) {
68 buf = this.ctr.encrypt(data, buf);
69 this.ghash.update(buf);

Callers 4

processMethod · 0.95
addMachineFunction · 0.45
bme68x.jsFile · 0.45
testharness.jsFile · 0.45

Calls 5

fromBigIntMethod · 0.80
concatMethod · 0.65
fromArrayBufferMethod · 0.65
encryptMethod · 0.45
processMethod · 0.45

Tested by

no test coverage detected