|
|
@ -76,6 +76,73 @@ describe('CBC', function() { |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
describe('@encrypt', function() { |
|
|
|
|
|
|
|
it('should return this known value', function() { |
|
|
|
var messagebuf1 = new Buffer(128 / 8); |
|
|
|
messagebuf1.fill(0); |
|
|
|
var messagebuf2 = new Buffer(128 / 8); |
|
|
|
messagebuf2.fill(0x10); |
|
|
|
var messagebuf = Buffer.concat([messagebuf1, messagebuf2]); |
|
|
|
var ivbuf = new Buffer(128 / 8); |
|
|
|
ivbuf.fill(0x10); |
|
|
|
var cipherkeybuf = new Buffer(128 / 8); |
|
|
|
cipherkeybuf.fill(0); |
|
|
|
var blockcipher = {}; |
|
|
|
blockcipher.encrypt = function(messagebuf, cipherkeybuf) { |
|
|
|
return messagebuf; |
|
|
|
}; |
|
|
|
blockcipher.decrypt = function(messagebuf, cipherkeybuf) { |
|
|
|
return messagebuf; |
|
|
|
}; |
|
|
|
var encbuf = CBC.encrypt(messagebuf, ivbuf, blockcipher, cipherkeybuf); |
|
|
|
var buf2 = CBC.decrypt(encbuf, ivbuf, blockcipher, cipherkeybuf); |
|
|
|
}); |
|
|
|
|
|
|
|
it('should return this shorter known value', function() { |
|
|
|
var messagebuf1 = new Buffer(128 / 8); |
|
|
|
messagebuf1.fill(0); |
|
|
|
var messagebuf2 = new Buffer(120 / 8); |
|
|
|
messagebuf2.fill(0x10); |
|
|
|
var messagebuf = Buffer.concat([messagebuf1, messagebuf2]); |
|
|
|
var ivbuf = new Buffer(128 / 8); |
|
|
|
ivbuf.fill(0x10); |
|
|
|
var cipherkeybuf = new Buffer(128 / 8); |
|
|
|
cipherkeybuf.fill(0); |
|
|
|
var blockcipher = {}; |
|
|
|
blockcipher.encrypt = function(messagebuf, cipherkeybuf) { |
|
|
|
return messagebuf; |
|
|
|
}; |
|
|
|
blockcipher.decrypt = function(messagebuf, cipherkeybuf) { |
|
|
|
return messagebuf; |
|
|
|
}; |
|
|
|
var encbuf = CBC.encrypt(messagebuf, ivbuf, blockcipher, cipherkeybuf); |
|
|
|
var buf2 = CBC.decrypt(encbuf, ivbuf, blockcipher, cipherkeybuf); |
|
|
|
}); |
|
|
|
|
|
|
|
it('should return this shorter known value', function() { |
|
|
|
var messagebuf1 = new Buffer(128 / 8); |
|
|
|
messagebuf1.fill(0); |
|
|
|
var messagebuf2 = new Buffer(136 / 8); |
|
|
|
messagebuf2.fill(0x10); |
|
|
|
var messagebuf = Buffer.concat([messagebuf1, messagebuf2]); |
|
|
|
var ivbuf = new Buffer(128 / 8); |
|
|
|
ivbuf.fill(0x10); |
|
|
|
var cipherkeybuf = new Buffer(128 / 8); |
|
|
|
cipherkeybuf.fill(0); |
|
|
|
var blockcipher = {}; |
|
|
|
blockcipher.encrypt = function(messagebuf, cipherkeybuf) { |
|
|
|
return messagebuf; |
|
|
|
}; |
|
|
|
blockcipher.decrypt = function(messagebuf, cipherkeybuf) { |
|
|
|
return messagebuf; |
|
|
|
}; |
|
|
|
var encbuf = CBC.encrypt(messagebuf, ivbuf, blockcipher, cipherkeybuf); |
|
|
|
var buf2 = CBC.decrypt(encbuf, ivbuf, blockcipher, cipherkeybuf); |
|
|
|
}); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
describe('@encryptblock', function() { |
|
|
|
|
|
|
|
it('should return this known value', function() { |
|
|
|