made system use full salt+pepper #16

Merged
Astronand merged 1 commits from 1.2-dev into main 2026-03-19 14:11:26 -04:00
4 changed files with 9 additions and 11 deletions

View File

@@ -198,6 +198,7 @@ local ok, err = xpcall(function()
local smallestDiff = math.huge local smallestDiff = math.huge
for k, _ in pairs(tbl) do for k, _ in pairs(tbl) do
if k==target then return k end
local diff = math.abs(k - target) local diff = math.abs(k - target)
if diff < smallestDiff then if diff < smallestDiff then
smallestDiff = diff smallestDiff = diff

View File

@@ -49,6 +49,7 @@ local function findClosest(tbl, target)
local smallestDiff = math.huge local smallestDiff = math.huge
for k, _ in pairs(tbl) do for k, _ in pairs(tbl) do
if k==target then return k end
local diff = math.abs(k - target) local diff = math.abs(k - target)
if diff < smallestDiff then if diff < smallestDiff then
smallestDiff = diff smallestDiff = diff

View File

@@ -150,16 +150,11 @@ end
local pepper = getFile("/etc/pam.d/secret") local pepper = getFile("/etc/pam.d/secret")
local function genSalt() local function genSalt()
local chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789./" return toHex(math.random(0,2^32))
local s = ""
for i = 1, 16 do
s = s .. chars:sub(math.random(1, #chars), math.random(1, #chars))
end
return s
end end
local function hashPassword(password, salt) local function hashPassword(password, salt)
local key = (pepper .. salt):sub(1, 32) local key = (pepper .. salt)
return blake2s(password, key) return blake2s(password, key)
end end

View File

@@ -6,10 +6,11 @@ local install,releasename=function()end,""
local exitall=false local exitall=false
local function download(url) local function download(url)
shell.run("wget "..url.." /tmp/download") local data,err=http.get(url)
local lib = require("tmp.download") if not data then error(err) end
fs.delete("/tmp/download") local func,err=load(data.readAll(),"@download","t",_ENV)
return lib if not func then error(err) end
return func()
end end
print("Installing JSON...") print("Installing JSON...")