Skip to content
Open
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@
}

ModeOfOperationCFB.prototype.encrypt = function(plaintext) {
if ((plaintext.length % this.segmentSize) != 0) {
if (((plaintext.length * this.segmentSize) % this.segmentSize) != 0) {
throw new Error('invalid plaintext size (must be segmentSize bytes)');
}

Expand All @@ -543,7 +543,7 @@
}

ModeOfOperationCFB.prototype.decrypt = function(ciphertext) {
if ((ciphertext.length % this.segmentSize) != 0) {
if (((ciphertext.length * this.segmentSize) % this.segmentSize) != 0) {
throw new Error('invalid ciphertext size (must be segmentSize bytes)');
}

Expand Down
2 changes: 1 addition & 1 deletion test/test-errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ module.exports = {

var moo = new aes.ModeOfOperation.cfb(key, iv, i);

test.throws(function() {
test.doesNotThrow(function() {
moo.encrypt(newBuffer(j));
}, function(error) {
return (error.message === 'invalid plaintext size (must be segmentSize bytes)');
Expand Down