Skip to content

Commit

Permalink
Fix chacha bug.
Browse files Browse the repository at this point in the history
  • Loading branch information
dlongley committed Aug 14, 2022
1 parent 6fa7c7f commit dc90fe6
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/algorithms/xc20p.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,11 +159,11 @@ async function _hchacha20({key, nonce}) {
const dvOut = new DataView(out.buffer, out.byteOffset, out.length);
const dvDst = new DataView(dst.buffer, dst.byteOffset, dst.length);
for(let i = 0; i < 4; ++i) {
dvOut.setUint32(i * 4, (state[i] - dvDst.getUint32(i * 4, LE)) | 0);
dvOut.setUint32(i * 4, (dvDst.getUint32(i * 4, LE) - state[i]) | 0, LE);
}
for(let i = 0; i < 4; ++i) {
dvOut.setUint32(
i * 4 + 16, (state[i + 12] - dvDst.getUint32(i * 4 + 48, LE)) | 0);
i * 4 + 16, (dvDst.getUint32(i * 4 + 48, LE) - state[i + 12]) | 0, LE);
}

return out;
Expand Down

0 comments on commit dc90fe6

Please sign in to comment.