MCPcopy Create free account
hub / github.com/allocnode/oh-my-sage / decrypt

Method decrypt

ref/gateway_client.js:51–64  ·  view source on GitHub ↗
(data)

Source from the content-addressed store, hash-verified

49 }
50
51 decrypt(data) {
52 if (data.length < 20) throw new Error('Data too short');
53 const counter = data.readUInt32LE(0);
54 if (counter <= this.decryptCounter) throw new Error('Replay attack');
55 this.decryptCounter = counter;
56
57 const ciphertext = data.slice(4, data.length - 16);
58 const tag = data.slice(data.length - 16);
59 const iv = this._makeIV(counter);
60
61 const decipher = crypto.createDecipheriv('aes-128-gcm', this.key, iv);
62 decipher.setAuthTag(tag);
63 return Buffer.concat([decipher.update(ciphertext), decipher.final()]);
64 }
65}
66
67// ==================== 压缩/解压 ====================

Callers 2

authenticateMethod · 0.95
handleMessageMethod · 0.45

Calls 1

_makeIVMethod · 0.95

Tested by

no test coverage detected