From 429a2d099f8cf0e8355531ebe252fcd48bfb53e0 Mon Sep 17 00:00:00 2001 From: "Ryan X. Charles" Date: Wed, 27 Aug 2014 14:36:23 -0700 Subject: [PATCH] test decrypt --- test/test.cbc.js | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/test/test.cbc.js b/test/test.cbc.js index 03ec539..2a53751 100644 --- a/test/test.cbc.js +++ b/test/test.cbc.js @@ -70,18 +70,17 @@ describe('CBC', function() { blockcipher.encrypt = function(messagebuf, cipherkeybuf) { return messagebuf; }; + blockcipher.decrypt = function(messagebuf, cipherkeybuf) { + return messagebuf; + }; var encbuf = CBC.encrypt(messagebuf, ivbuf, blockcipher, cipherkeybuf); - encbuf.toString('hex').should.equal('101010101010101010101010101010100000000000000000000000000000000010101010101010101010101010101010'); + var buf2 = CBC.decrypt(encbuf, ivbuf, blockcipher, cipherkeybuf); }); - }); - - describe('@encrypt', function() { - - it('should return this known value', function() { + it('should return this shorter known value', function() { var messagebuf1 = new Buffer(128 / 8); messagebuf1.fill(0); - var messagebuf2 = new Buffer(128 / 8); + var messagebuf2 = new Buffer(120 / 8); messagebuf2.fill(0x10); var messagebuf = Buffer.concat([messagebuf1, messagebuf2]); var ivbuf = new Buffer(128 / 8); @@ -102,7 +101,7 @@ describe('CBC', function() { it('should return this shorter known value', function() { var messagebuf1 = new Buffer(128 / 8); messagebuf1.fill(0); - var messagebuf2 = new Buffer(120 / 8); + var messagebuf2 = new Buffer(136 / 8); messagebuf2.fill(0x10); var messagebuf = Buffer.concat([messagebuf1, messagebuf2]); var ivbuf = new Buffer(128 / 8); @@ -120,10 +119,14 @@ describe('CBC', function() { var buf2 = CBC.decrypt(encbuf, ivbuf, blockcipher, cipherkeybuf); }); - it('should return this shorter known value', function() { + }); + + describe('decrypt', function() { + + it('', function() { var messagebuf1 = new Buffer(128 / 8); messagebuf1.fill(0); - var messagebuf2 = new Buffer(136 / 8); + var messagebuf2 = new Buffer(128 / 8); messagebuf2.fill(0x10); var messagebuf = Buffer.concat([messagebuf1, messagebuf2]); var ivbuf = new Buffer(128 / 8); @@ -138,7 +141,8 @@ describe('CBC', function() { return messagebuf; }; var encbuf = CBC.encrypt(messagebuf, ivbuf, blockcipher, cipherkeybuf); - var buf2 = CBC.decrypt(encbuf, ivbuf, blockcipher, cipherkeybuf); + var messagebuf2 = CBC.decrypt(encbuf, ivbuf, blockcipher, cipherkeybuf); + messagebuf2.toString('hex').should.equal(messagebuf.toString('hex')); }); });