Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 23 additions & 21 deletions dot_cardpeek_dir/scripts/e-passport.lua
Original file line number Diff line number Diff line change
Expand Up @@ -352,29 +352,31 @@ function ui_parse_block(node,format,data,pos)
local i,v
local index

for i,v in ipairs(format) do
ITEM = node:append({ classname="item", label=v[1], id=i-1, size=v[2] })
block = bytes.sub(data,pos,pos+v[2]-1)
if v[3]~=nil then
if type(v[3])=="function" then
if v[3](ITEM,block)==false then
return nil
end
elseif type(v[3])=="table" then
index = bytes.tonumber(block)
nodes.set_attribute(ITEM,"val",block)
if v[3][index] then
nodes.set_attribute(ITEM,"alt",v[3][index])
else
nodes.set_attribute(ITEM,"alt",index)
end
if type(format)=="table" then
for i,v in ipairs(format) do
ITEM = node:append({ classname="item", label=v[1], id=i-1, size=v[2] })
block = bytes.sub(data,pos,pos+v[2]-1)
if v[3]~=nil then
if type(v[3])=="function" then
if v[3](ITEM,block)==false then
return nil
end
elseif type(v[3])=="table" then
index = bytes.tonumber(block)
nodes.set_attribute(ITEM,"val",block)
if v[3][index] then
nodes.set_attribute(ITEM,"alt",v[3][index])
else
nodes.set_attribute(ITEM,"alt",index)
end
else
return nil
end
else
return nil
end
else
nodes.set_attribute(ITEM,"val",block)
nodes.set_attribute(ITEM,"val",block)
end
pos = pos + v[2]
end
pos = pos + v[2]
end
return pos
end
Expand Down
24 changes: 13 additions & 11 deletions dot_cardpeek_dir/scripts/emv.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
--
-- This file is part of Cardpeek, the smartcard reader utility.
--
-- Copyright 2009-2015 by 'L1L1'
-- Copyright 2009-2013 by 'L1L1'
--
-- Cardpeek is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
Expand All @@ -27,8 +27,7 @@
-- Jan 23 2012: Added UK Post Office Card Account in AID list from Tyson Key.
-- Mar 25 2012: Added a few AIDs
-- Feb 21 2014: Better NFC compatibility by using current date in GPO.
-- Nov 16 2014: Many improvements from Andrew Kozlic (Many new AIDs, parses AIP, GPO Format 1, AFLs, and more.)
-- @update March 05 2014: Avoid error when card don't have tag 82 or 94 in GPO (issue 62)
-- @update: Nov 16 2014: Many improvements from Andrew Kozlic (Many new AIDs, parses AIP, GPO Format 1, AFLs, and more.)

require('lib.tlv')
require('lib.strict')
Expand Down Expand Up @@ -862,12 +861,8 @@ function emv_process_application(cardenv,aid)
AFL = nodes.get_attribute(ref2, "val")
AIP = bytes.sub(AFL,0,1)
AFL = bytes.sub(AFL,2)
if nodes.find_first(GPO,{id="82"}) then
tag_value_parse(ref2, 0x82, AIP, EMV_REFERENCE)
end
if nodes.find_first(GPO,{id="94"}) then
tag_value_parse(ref2, 0x94, AFL, EMV_REFERENCE)
end
tag_value_parse(ref2, 0x82, AIP, EMV_REFERENCE)
tag_value_parse(ref2, 0x94, AFL, EMV_REFERENCE)
else
log.print(log.WARNING,
"GPO Response message contains neither a Format 1 nor a Format 2 Data Field")
Expand Down Expand Up @@ -1032,8 +1027,15 @@ function ui_parse_cplc_date(node,data)
return
end

year = 0 + string.sub(date, 1, 1)
yday = 0 + string.sub(date, 2, 4)
year = tonumber(string.sub(date, 1, 1))
yday = tonumber(string.sub(date, 2, 4))

if yday == nil then
yday=0
end
if year == nil then
year=0
end

if yday == 366 then
date = "???" .. year .. "-12-31"
Expand Down