Skip to content

Commit

Permalink
Cache loaded encryption keys.
Browse files Browse the repository at this point in the history
I'm pretty sure that's a commit message that strikes fear in the hearts of
 cryptographers everywhere.
  • Loading branch information
icculus committed Dec 18, 2013
1 parent 7e650c1 commit 5c3eeae
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions 1pass.lua
Expand Up @@ -57,7 +57,12 @@ local function load_json(fname)
end


local keys = {}
function loadKey(basedir, level, password)
if keys[level] ~= nil then
return keys[level]
end

local keysjson = load_json(basedir .. "/encryptionKeys.js");
if (keysjson == nil) or (keysjson[level] == nil) then
return nil
Expand All @@ -81,6 +86,7 @@ function loadKey(basedir, level, password)
return nil
end

keys[level] = decrypted
return decrypted
end
end
Expand Down Expand Up @@ -109,8 +115,7 @@ showHint(basedir)
io.write("password: ")
local password = io.read("*l")

local sl5 = loadKey(basedir, "SL5", password)
if sl5 == nil then
if loadKey(basedir, "SL5", password) == nil then
print("wrong password?\n")
os.exit(1)
end
Expand Down

0 comments on commit 5c3eeae

Please sign in to comment.