security update round 2
This commit is contained in:
@@ -13,13 +13,28 @@ function Security.hasPassword()
|
||||
return not not Security.getPassword()
|
||||
end
|
||||
|
||||
local function genKey()
|
||||
local key = { }
|
||||
for _ = 1, 32 do
|
||||
table.insert(key, ("%02x"):format(math.random(0, 0xFF)))
|
||||
end
|
||||
return table.concat(key)
|
||||
end
|
||||
|
||||
function Security.generateKeyPair()
|
||||
local privateKey = Util.hexToByteArray(genKey())
|
||||
return privateKey, ECC.publicKey(privateKey)
|
||||
end
|
||||
|
||||
function Security.getIdentifier()
|
||||
return Security.geetPublicKey()
|
||||
end
|
||||
|
||||
-- deprecate - will use getIdentifier
|
||||
function Security.getSecretKey()
|
||||
local config = Config.load('os')
|
||||
if not config.secretKey then
|
||||
config.secretKey = ""
|
||||
for _ = 1, 32 do
|
||||
config.secretKey = config.secretKey .. ("%02x"):format(math.random(0, 0xFF))
|
||||
end
|
||||
config.secretKey = genKey()
|
||||
Config.update('os', config)
|
||||
end
|
||||
return Util.hexToByteArray(config.secretKey)
|
||||
|
||||
Reference in New Issue
Block a user