Temporarily commented out distance bounding code. About to add in CMAC calculations to C Code.

This commit is contained in:
Dom 2018-04-02 10:46:05 +01:00
commit 2cbf09c3d1

View file

@ -186,6 +186,7 @@ function calculateMAC(MAC_input)
end end
function proximityCheck() function proximityCheck()
--PreparePC--
commandString = PREPAREPC commandString = PREPAREPC
response = sendRaw(commandString, true, true) response = sendRaw(commandString, true, true)
OPT = string.sub(response, 5, 6) OPT = string.sub(response, 5, 6)
@ -202,23 +203,25 @@ function proximityCheck()
end end
print("OPT = " .. OPT .. " pubRespTime = " .. pubRespTime .. " pps = " .. pps) print("OPT = " .. OPT .. " pubRespTime = " .. pubRespTime .. " pps = " .. pps)
--PC--
RndC = "0001020304050607" --Random Challenge RndC = "0001020304050607" --Random Challenge
commandString = PROXIMITYCHECK .. "08" .. RndC commandString = PROXIMITYCHECK .. "08" .. RndC
response = sendRaw(commandString, true, true) response = sendRaw(commandString, true, true)
RndR = string.sub(response, 3, 18) RndR = string.sub(response, 3, 18)
print("RndC = " .. RndC .. " RndR = " .. RndR) print("RndC = " .. RndC .. " RndR = " .. RndR)
--VerifyPC--
MAC_input = "FD" .. OPT .. pubRespTime MAC_input = "FD" .. OPT .. pubRespTime
if(pps_present == true) then if(pps_present == true) then
MAC_input = MAC_input .. pps MAC_input = MAC_input .. pps
end end
rnum_concat = "" rnum_concat = ""
j = 1 rnum_concat = RndR .. RndC --temporary (only works for when a single random challenge (8 bytes) is sent)
for i = 1,8 do -- j = 1
rnum_concat = rnum_concat .. string.sub(RndR, j, j + 1) .. string.sub(RndC, j, j + 1) -- for i = 1,8 do
j = j + 2 -- rnum_concat = rnum_concat .. string.sub(RndR, j, j + 1) .. string.sub(RndC, j, j + 1)
end -- j = j + 2
-- end
MAC_input = MAC_input .. rnum_concat MAC_input = MAC_input .. rnum_concat
print("Concatenation of random numbers = " .. rnum_concat) print("Concatenation of random numbers = " .. rnum_concat)
print("Final PCD concatenation before input into MAC function = " .. MAC_input) print("Final PCD concatenation before input into MAC function = " .. MAC_input)
@ -226,6 +229,7 @@ function proximityCheck()
print("8-byte PCD MAC_tag (placeholder - currently incorrect) = " .. MAC_tag) print("8-byte PCD MAC_tag (placeholder - currently incorrect) = " .. MAC_tag)
commandString = VERIFYPC .. MAC_tag commandString = VERIFYPC .. MAC_tag
response = sendRaw(commandString, true, true) response = sendRaw(commandString, true, true)
print(response)
PICC_MAC = string.sub(response, 5, 20) PICC_MAC = string.sub(response, 5, 20)
print("8-byte MAC returned by PICC = " .. PICC_MAC) print("8-byte MAC returned by PICC = " .. PICC_MAC)
MAC_input = "90" .. string.sub(MAC_input, 3) MAC_input = "90" .. string.sub(MAC_input, 3)
@ -254,7 +258,7 @@ function main(args)
--writePerso() --writePerso()
--commitPerso() --commitPerso()
getVersion() --getVersion()
proximityCheck() proximityCheck()
--commandString = VERIFYPC .. "186EFDE8DDC7D30B" --commandString = VERIFYPC .. "186EFDE8DDC7D30B"