flocore/lib/ECIES.js
Linus Unnebäck 3da6fe899f cleanup after removal of soop
Removed some unnecessary parenthesise that hung around after the merge
of #417
2014-07-12 12:14:56 +02:00

24 lines
676 B
JavaScript

'use strict';
var crypto = require('crypto');
var ECIES = require('./common/ECIES');
ECIES.symmetricEncrypt = function(key, iv, message) {
var cipheriv = crypto.createCipheriv('AES-256-CBC', key, iv);
var a = cipheriv.update(message);
var b = cipheriv.final();
var r = Buffer.concat([iv, a, b]);
return r;
};
ECIES.symmetricDecrypt = function(key, encrypted) {
var iv = encrypted.slice(0, 16);
var decipheriv = crypto.createDecipheriv('AES-256-CBC', key, iv);
var todecrypt = encrypted.slice(16, encrypted.length);
var a = decipheriv.update(todecrypt);
var b = decipheriv.final();
var r = Buffer.concat([a, b]);
return r;
};
module.exports = ECIES;