1
0
Fork 0
mirror of https://github.com/Ylianst/MeshCentral.git synced 2025-02-12 11:01:52 +00:00
MeshCentral/meshaccelerator.js

36 lines
959 B
JavaScript
Raw Normal View History

2018-01-10 04:13:41 +00:00
/**
* @description MeshCentral accelerator
* @author Ylian Saint-Hilaire
* @copyright Intel Corporation 2018
* @license Apache-2.0
* @version v0.0.1
*/
2018-08-30 00:40:30 +00:00
/*xjslint node: true */
/*xjslint plusplus: true */
/*xjslint maxlen: 256 */
/*jshint node: true */
/*jshint strict: false */
/*jshint esversion: 6 */
"use strict";
2018-08-27 19:24:15 +00:00
2018-01-10 04:13:41 +00:00
const crypto = require('crypto');
var certStore = null;
process.on('message', function (message) {
switch (message.action) {
case 'sign': {
if (typeof message.key == 'number') { message.key = certStore[message.key].key; }
try {
const sign = crypto.createSign('SHA384');
sign.end(Buffer.from(message.data, 'binary'));
2018-01-10 04:13:41 +00:00
process.send(sign.sign(message.key).toString('binary'));
} catch (e) { process.send(null); }
break;
}
case 'setState': {
certStore = message.certs;
break;
}
}
});