Browse Source

test decrypt

patch-2
Ryan X. Charles 11 years ago
parent
commit
429a2d099f
  1. 26
      test/test.cbc.js

26
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'));
});
});

Loading…
Cancel
Save