diff --git a/client/lualibs/precalc.lua b/client/lualibs/precalc.lua index ce58998a8..cedad4cf2 100644 --- a/client/lualibs/precalc.lua +++ b/client/lualibs/precalc.lua @@ -38,7 +38,7 @@ local function ApplyPermutationAndShifts( pos, value, nibble) local shiftbytes = shifts[pos] local shiftElem = shiftbytes[nibble+1] --one indexed local shiftOne = shiftbytes[1] - local rs = bit32.bxor(value, bit32.bxor(shiftOne, shiftElem)) + local rs = bit32.bxor(value, shiftOne, shiftElem) return rs end diff --git a/client/scripts/calc_ev1_it.lua b/client/scripts/calc_ev1_it.lua index e170e9106..f7a59dc1e 100644 --- a/client/scripts/calc_ev1_it.lua +++ b/client/scripts/calc_ev1_it.lua @@ -108,7 +108,7 @@ local function findEntryByUid( uid ) -- xor UID4,UID5,UID6,UID7 -- mod 0x20 (dec 32) - local pos = (bxor(bxor(bxor(uid[4],uid[5]), uid[6]),uid[7])) % 32 + local pos = (bxor(uid[4], uid[5], uid[6], uid[7])) % 32 -- convert to hexstring pos = string.format('%02X', pos) @@ -132,9 +132,9 @@ local function pwdgen(uid) local entry = findEntryByUid(uidbytes) if entry == nil then return nil, "Can't find a xor entry" end - local pwd0 = bxor( bxor( bxor( entry[1], uidbytes[2]), uidbytes[3]), uidbytes[4]) - local pwd1 = bxor( bxor( bxor( entry[2], uidbytes[1]), uidbytes[3]), uidbytes[5]) - local pwd2 = bxor( bxor( bxor( entry[3], uidbytes[1]), uidbytes[2]), uidbytes[6]) + local pwd0 = bxor( entry[1], uidbytes[2], uidbytes[3], uidbytes[4]) + local pwd1 = bxor( entry[2], uidbytes[1], uidbytes[3], uidbytes[5]) + local pwd2 = bxor( entry[3], uidbytes[1], uidbytes[2], uidbytes[6]) local pwd3 = bxor( entry[4], uidbytes[7]) return string.format('%02X%02X%02X%02X', pwd0, pwd1, pwd2, pwd3) end diff --git a/client/scripts/ul_uid.lua b/client/scripts/ul_uid.lua index 6acb08694..d87939c4a 100644 --- a/client/scripts/ul_uid.lua +++ b/client/scripts/ul_uid.lua @@ -120,8 +120,8 @@ function main(args) local uidbytes = utils.ConvertHexToBytes(uid) - local bcc1 = bxor(bxor(bxor(uidbytes[1], uidbytes[2]), uidbytes[3]), 0x88) - local bcc2 = bxor(bxor(bxor(uidbytes[4], uidbytes[5]), uidbytes[6]), uidbytes[7]) + local bcc1 = bxor(0x88, uidbytes[1], uidbytes[2], uidbytes[3]) + local bcc2 = bxor(uidbytes[4], uidbytes[5], uidbytes[6], uidbytes[7]) local block0 = string.format('%02X%02X%02X%02X', uidbytes[1], uidbytes[2], uidbytes[3], bcc1) local block1 = string.format('%02X%02X%02X%02X', uidbytes[4], uidbytes[5], uidbytes[6], uidbytes[7])