Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions lib/cipherModes.js
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,9 @@ modes.ctr.prototype.start = function(options) {
// use IV as first input
this._iv = transformIV(options.iv, this.blockSize);
this._inBlock = this._iv.slice(0);
if(options.counter) {
inc32(this._inBlock, options.counter);
}
this._partialBytes = 0;
};

Expand Down Expand Up @@ -988,9 +991,9 @@ function transformIV(iv, blockSize) {
return iv;
}

function inc32(block) {
function inc32(block, count) {
// increment last 32 bits of block only
block[block.length - 1] = (block[block.length - 1] + 1) & 0xFFFFFFFF;
block[block.length - 1] = (block[block.length - 1] + (count || 1)) & 0xFFFFFFFF;
}

function from64To32(num) {
Expand Down