Unit test fixes

This commit is contained in:
2021-07-30 18:43:52 -05:00
parent d428445f00
commit b58bfcf1e1
2 changed files with 16 additions and 4 deletions

View File

@@ -24,7 +24,7 @@ export default class packet {
this.token = token;
}
buffer = null;
buffer = new Uint8Array(0);
decode_offset = 0;
token;
@@ -180,9 +180,11 @@ export default class packet {
...this.buffer.slice(nonce.length + mac.length),
...this.buffer.slice(nonce.length, nonce.length + mac.length),
]);
this.buffer = Buffer.from(
new XChaCha20Poly1305(key).open(nonce, this.buffer, aad)
);
const result = new XChaCha20Poly1305(key).open(nonce, this.buffer, aad);
if (!result) {
throw new Error('decryption failed');
}
this.buffer = Buffer.from(result);
}
this.buffer = new Uint8Array(this.buffer);