Skip to content

Commit

Permalink
byte offset error
Browse files Browse the repository at this point in the history
Signed-off-by: Marin Petrunic <[email protected]>
  • Loading branch information
mpetrunic committed Jul 13, 2023
1 parent 12210d9 commit 09daf88
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions test/basic.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,17 @@ describe('poly1305', () => {
}
});

should.only('handle byte offset', () => {
const sample = require('crypto').randomBytes(60); // strings must be converted to Uint8Array
//uint8array view that skips first byte
const data = new Uint8Array(sample.buffer, 1)
const key = require('crypto').randomBytes(32);
const nonce12 = require('crypto').randomBytes(12);
const stream_c = chacha20_poly1305(key, nonce12);
const encrypted_c = stream_c.encrypt(data);
stream_c.decrypt(encrypted_c); // === data
});

should('multiple updates', () => {
const key = new Uint8Array(32);
for (let i = 0; i < key.length; i++) key[i] = i;
Expand Down

0 comments on commit 09daf88

Please sign in to comment.