flocore/lib/expmt/cbc.js
Ryan X. Charles 1b1ecd989a pkcs7
This is a standard algorithm for the purposes of padding a block for a block
cipher. It will be used in CBC, which in turned will be used with AES for
ECIES.
2014-08-24 19:38:20 -07:00

15 lines
308 B
JavaScript

var Random = require('../random');
var CBC = function CBC() {
};
CBC.pkcs7pad = function(buf, blocksize) {
var bytesize = blocksize / 8;
var padbytesize = bytesize - buf.length;
var pad = new Buffer(padbytesize);
pad.fill(padbytesize);
return Buffer.concat([buf, pad]);
};
module.exports = CBC;