mirror of
https://github.com/Ylianst/MeshCentral.git
synced 2024-11-22 22:17:31 +03:00
Fixed the OTP random generator to be even.
This commit is contained in:
parent
632d190d23
commit
86b5e4a85d
15
meshuser.js
15
meshuser.js
@ -1429,12 +1429,8 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
|
||||
// Perform a sub-action
|
||||
var actionTaken = false;
|
||||
if (command.subaction == 1) { // Generate a new set of tokens
|
||||
var randomNumbers = [];
|
||||
for (var i = 0; i < 10; i++) {
|
||||
var v; // TODO: This random generation does not produce equal changes for all values. FIX IT!
|
||||
do { v = (obj.parent.crypto.randomBytes(4).readUInt32BE(0) % 100000000); } while (randomNumbers.indexOf(v) >= 0);
|
||||
randomNumbers.push(v);
|
||||
}
|
||||
var randomNumbers = [], v;
|
||||
for (var i = 0; i < 10; i++) { do { v = getRandomEightDigitInteger(); } while (randomNumbers.indexOf(v) >= 0); randomNumbers.push(v); }
|
||||
user.otpkeys = { keys: [] };
|
||||
for (var i = 0; i < 10; i++) { user.otpkeys.keys[i] = { p: randomNumbers[i], u: true } }
|
||||
actionTaken = true;
|
||||
@ -1605,6 +1601,13 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
|
||||
return obj;
|
||||
}
|
||||
|
||||
// Generate a 8 digit integer with even random probability for each value.
|
||||
function getRandomEightDigitInteger() {
|
||||
var bigInt;
|
||||
do { bigInt = obj.parent.crypto.randomBytes(4).readUInt32BE(0); } while (bigInt > 4200000000);
|
||||
return bigInt % 100000000;
|
||||
}
|
||||
|
||||
// Parse arguments string array into an object
|
||||
function parseArgs(argv) {
|
||||
var results = { '_': [] }, current = null;
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "meshcentral",
|
||||
"version": "0.2.7-i",
|
||||
"version": "0.2.7-j",
|
||||
"keywords": [
|
||||
"Remote Management",
|
||||
"Intel AMT",
|
||||
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -971,6 +971,10 @@
|
||||
//addNotification(n);
|
||||
break;
|
||||
}
|
||||
case 'stopped': { // Server is stopping.
|
||||
// TODO: Disconnect
|
||||
break;
|
||||
}
|
||||
default:
|
||||
console.log('Unknown message.event.action', message.event.action);
|
||||
break;
|
||||
|
@ -1685,6 +1685,10 @@
|
||||
addNotification(n);
|
||||
break;
|
||||
}
|
||||
case 'stopped': { // Server is stopping.
|
||||
// TODO: Disconnect
|
||||
break;
|
||||
}
|
||||
default:
|
||||
//console.log('Unknown message.event.action', message.event.action);
|
||||
break;
|
||||
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user