From bf5828ed5a7cb232ad706112384d611c6accebb1 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Thu, 18 Sep 2014 10:16:59 +0200 Subject: util.random: Switch to SHA512 --- util/random.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/util/random.lua b/util/random.lua index ed5cdf4b..328bdb00 100644 --- a/util/random.lua +++ b/util/random.lua @@ -10,7 +10,7 @@ local tostring = tostring; local os_time = os.time; local os_clock = os.clock; local ceil = math.ceil; -local sha1 = require "util.hashes".sha1; +local H = require "util.hashes".sha512; local last_uniq_time = 0; local function uniq_time() @@ -21,7 +21,7 @@ local function uniq_time() end local function new_random(x) - return sha1(x..os_clock()..tostring({})); + return H(x..os_clock()..tostring({})); end local buffer = new_random(uniq_time()); -- cgit v1.2.3 From 8e74cf8125fdd3cac754f7cdfb4daec62a5a75ea Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Thu, 18 Sep 2014 10:21:38 +0200 Subject: util.random: Ensure at least 4 bytes of previous random state is used when generating new randomness --- util/random.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/util/random.lua b/util/random.lua index 328bdb00..5938a94f 100644 --- a/util/random.lua +++ b/util/random.lua @@ -31,8 +31,8 @@ local function seed(x) end local function bytes(n) - if #buffer < n then seed(uniq_time()); end - local r = buffer:sub(0, n); + if #buffer < n+4 then seed(uniq_time()); end + local r = buffer:sub(1, n); buffer = buffer:sub(n+1); return r; end -- cgit v1.2.3 From ad7e3d7233cff3e34c11323ff5ec64aacb8f678c Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Tue, 23 Sep 2014 00:23:33 +0200 Subject: core.module{manager,api}: Fix for 010b141e91ed (Thanks v1ct0r) --- core/moduleapi.lua | 4 +++- core/modulemanager.lua | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/core/moduleapi.lua b/core/moduleapi.lua index e5f86b37..c30a8936 100644 --- a/core/moduleapi.lua +++ b/core/moduleapi.lua @@ -370,7 +370,9 @@ function api:open_store(name, type) return require"core.storagemanager".open(self.host, name or self.name, type); end -return function (mm) +function api.init(mm) modulemanager = mm; return api; end + +return api; diff --git a/core/modulemanager.lua b/core/modulemanager.lua index 198e208a..92372ac3 100644 --- a/core/modulemanager.lua +++ b/core/modulemanager.lua @@ -37,7 +37,7 @@ local _G = _G; module "modulemanager" -local api = _G.require "core.moduleapi"(_M); -- Module API container +local api = _G.require "core.moduleapi".init(_M); -- Module API container -- [host] = { [module] = module_env } local modulemap = { ["*"] = {} }; -- cgit v1.2.3