# HG changeset patch # User Kim Alvefur # Date 1381620988 -7200 # Node ID 61f748d363e15e7e254108ffd05141cf7b93afe4 # Parent 35780ef2d689cf972b9a0dfecfbf0381a9c9a524 util.sasl.scram: Cache profile name instead of concatenating when used diff -r 35780ef2d689 -r 61f748d363e1 util/sasl/scram.lua --- a/util/sasl/scram.lua Sun Oct 13 01:14:21 2013 +0200 +++ b/util/sasl/scram.lua Sun Oct 13 01:36:28 2013 +0200 @@ -101,6 +101,7 @@ end local function scram_gen(hash_name, H_f, HMAC_f) + local profile_name = "scram_" .. hashprep(hash_name); local function scram_hash(self, message) local support_channel_binding = false; if self.profile.cb then support_channel_binding = true; end @@ -168,9 +169,9 @@ log("error", "Generating authentication database failed. Reason: %s", stored_key); return "failure", "temporary-auth-failure"; end - elseif self.profile["scram_"..hashprep(hash_name)] then + elseif self.profile[profile_name] then local state; - stored_key, server_key, iteration_count, salt, state = self.profile["scram_"..hashprep(hash_name)](self, name, self.realm); + stored_key, server_key, iteration_count, salt, state = self.profile[profile_name](self, name, self.realm); if state == nil then return "failure", "not-authorized" elseif state == false then return "failure", "account-disabled" end end