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
Only respond to the commands that this card actually implements
Also, implement a stub version of the "GET CARD DATA" and "LOG OFF"
commands that are proprietary to the Belpic applet.
  • Loading branch information
yoe committed Jun 15, 2017
commit efb57b0ac3be7e5baf04e63cf103b5a89cff2d0b
19 changes: 19 additions & 0 deletions virtualsmartcard/src/vpicc/virtualsmartcard/cards/belpic.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,33 @@
from virtualsmartcard.VirtualSmartcard import Iso7816OS
from virtualsmartcard.ConstantDefinitions import MAX_SHORT_LE, FDB, LCB
from virtualsmartcard.SmartcardFilesystem import MF, DF, TransparentStructureEF
from virtualsmartcard.SWutils import SW, SwError

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.ins2handler = {
0xc0: self.getResponse,
0xa4: self.mf.selectFile,
0xb0: self.mf.readBinaryPlain,
0x20: self.SAM.verify,
0x24: self.SAM.change_reference_data,
0x22: self.SAM.manage_security_environment,
0x2a: self.SAM.perform_security_operation,
0xe4: self.getCardData,
0xe6: self.logOff
}
self.atr = '\x3B\x98\x13\x40\x0A\xA5\x03\x01\x01\x01\xAD\x13\x11'

def getCardData(self, p1, p2, data):
return SW["NORMAL"], "534C494E0123456789ABCDEF01234567F3360125011700030021010f".decode("hex")

# TODO: actually log off
def logOff(self, p1, p2, data):
return SW["NORMAL"]

class BelpicMF(MF):
def __init__(self, datafile, filedescriptor=FDB["NOTSHAREABLEFILE" ] | FDB["DF"],
lifecycle=LCB["ACTIVATED"],simpletlv_data = None, bertlv_data = None):
Expand Down