Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: support for Belgian eID cards #104

Open
wants to merge 19 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Prev Previous commit
Next Next commit
Upon initialisation, read the XML file
Current BeID development tools work with XML files to represent the data
on the card. Reuse that format, so that existing developers don't have
to regenerate their cards (and so that a certain level of
interoperability between those tools exists)

We may add another option in the future, but that's not for now.

Also, add the Belpic applet's AID as the DF name for the MF
  • Loading branch information
yoe committed Jun 15, 2017
commit 5c6c52298dae0b51207053d44d94225805ac0479
32 changes: 30 additions & 2 deletions virtualsmartcard/src/vpicc/virtualsmartcard/cards/belpic.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,42 @@
# virtualsmartcard. If not, see <http:https://www.gnu.org/licenses/>.

from virtualsmartcard.VirtualSmartcard import Iso7816OS
from virtualsmartcard.ConstantDefinitions import MAX_SHORT_LE
from virtualsmartcard.SmartcardFilesystem import MF
from virtualsmartcard.ConstantDefinitions import MAX_SHORT_LE, FDB, LCB
from virtualsmartcard.SmartcardFilesystem import MF, DF, TransparentStructureEF

import xml.etree.ElementTree as ET

class BelpicOS(Iso7816OS):
def __init__(self, mf, sam, ins2handler=None, maxle=MAX_SHORT_LE):
Iso7816OS.__init__(self, mf, sam, ins2handler, maxle)
self.atr = '\x3B\x98\x13\x40\x0A\xA5\x03\x01\x01\x01\xAD\x13\x11'

class BelpicMF(MF):
def __init__(self, datafile, filedescriptor=FDB["NOTSHAREABLEFILE" ] | FDB["DF"],
lifecycle=LCB["ACTIVATED"],simpletlv_data = None, bertlv_data = None):
MF.__init__(self, filedescriptor, lifecycle, simpletlv_data, bertlv_data, dfname = "A00000003029057000AD13100101FF".decode('hex'))
tree = ET.parse(datafile)
root = tree.getroot()
ns = {'f': 'urn:be:fedict:eid:dev:virtualcard:1.0'}
DF00 = DF(self, 0xDF00)
self.append(DF00)
DF01 = DF(self, 0xDF01)
self.append(DF01)
parent = self
fid = 0
for f in root.findall('f:file', ns):
id = f.find('f:id', ns).text
content = f.find('f:content', ns).text
if content is not None:
if(len(id) == 12):
fid = int(id[8:], 16)
if (id[4:8] == 'DF00'):
parent = DF00
if (id[4:8] == 'DF01'):
parent = DF01
else:
fid = int(id[4:], 16)
parent.append(TransparentStructureEF(parent, fid, data = content.decode('hex')))

@staticmethod
def create(p1, p2, data):
Expand Down