add test for no rotation enc/dec

This commit is contained in:
DavidVentura
2024-01-26 17:35:57 +01:00
parent 784fc27a20
commit 36ab8d3285
+16
View File
@@ -69,6 +69,22 @@ describe("module", () => {
0x00, 0x00, 0x00, 0x00, 0x30, 0x2e, 0x30, 0x2e, 0x30, 0x2e, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x2e, 0x30, 0x2e, 0x30, 0x2e, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x30, 0x2e, 0x30, 0x2e, 0x30, 0x2e, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x2e, 0x30, 0x2e, 0x30, 0x2e, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
]); ]);
it("encrypts without rotation", () => {
const in_buf = new DataView(new Uint8Array([1, 2, 3, 4]).buffer);
XqBytesEnc(in_buf, in_buf.byteLength, 0); // this mutates in_buf
assert.equal(in_buf.add(0).readU8(), 0);
assert.equal(in_buf.add(1).readU8(), 3);
assert.equal(in_buf.add(2).readU8(), 2);
assert.equal(in_buf.add(3).readU8(), 5);
});
it("decrypts without rotation", () => {
const in_buf = new DataView(new Uint8Array([1, 2, 3, 4]).buffer);
XqBytesDec(in_buf, in_buf.byteLength, 0); // this mutates in_buf
assert.equal(in_buf.add(0).readU8(), 0);
assert.equal(in_buf.add(1).readU8(), 3);
assert.equal(in_buf.add(2).readU8(), 2);
assert.equal(in_buf.add(3).readU8(), 5);
});
it("decrypts simple input", () => { it("decrypts simple input", () => {
const in_buf = new DataView(simple_enc_bytes.buffer.slice(0)); const in_buf = new DataView(simple_enc_bytes.buffer.slice(0));
XqBytesDec(in_buf, simple_enc_bytes.byteLength, 4); // this mutates in_buf XqBytesDec(in_buf, simple_enc_bytes.byteLength, 4); // this mutates in_buf