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
Show file tree
Hide file tree
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
Next Next commit
Start work on adding a belpic implementation
BELPIC (BELgian Personal Identity Card) is the official electronic ID
card of Belgium.

Start adding a virtual implementation of this card to vsmartcard.

Not remotely there yet, but at least this runs without error already,
and sends the correct ATR when asked. Beyond that... much TODO.
  • Loading branch information
yoe committed Jun 15, 2017
commit 99ff2a4f25165a8ec24238f6c055734d127809a1
3 changes: 2 additions & 1 deletion virtualsmartcard/src/vpicc/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ vpicccards_PYTHON = virtualsmartcard/cards/__init__.py \
virtualsmartcard/cards/ePass.py \
virtualsmartcard/cards/nPA.py \
virtualsmartcard/cards/Relay.py \
virtualsmartcard/cards/cryptoflex.py
virtualsmartcard/cards/cryptoflex.py \
virtualsmartcard/cards/belpic.py

do_subst = $(SED) \
-e 's,[@]PYTHON[@],$(PYTHON),g' \
Expand Down
2 changes: 1 addition & 1 deletion virtualsmartcard/src/vpicc/vicc.in
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Report bugs to @PACKAGE_BUGREPORT@

parser.add_argument("-t", "--type",
action="store",
choices=['iso7816', 'cryptoflex', 'ePass', 'nPA', 'relay', 'handler_test'],
choices=['iso7816', 'cryptoflex', 'ePass', 'nPA', 'relay', 'handler_test', 'belpic'],
default='iso7816',
help="type of smart card to emulate (default: %(default)s)")
parser.add_argument("-v", "--verbose",
Expand Down
7 changes: 7 additions & 0 deletions virtualsmartcard/src/vpicc/virtualsmartcard/CardGenerator.py
Original file line number Diff line number Diff line change
Expand Up @@ -665,6 +665,11 @@ def __generate_cryptoflex(self):
data="\x00\x00\x00\x01\x00\x01\x00\x00")) # EF.ICCSN
self.sam = CryptoflexSAM(self.mf)

def __generate_belpic(self):
# TODO: implement this in a somewhat more rational manner. For now
# though, use the ISO7816 implementation
self.__generate_iso_card()

def generateCard(self):
"""Generate a new card"""
if self.type == 'iso7816':
Expand All @@ -675,6 +680,8 @@ def generateCard(self):
self.__generate_cryptoflex()
elif self.type == 'nPA':
self.__generate_nPA()
elif self.type == 'belpic':
self.__generate_belpic()
else:
return (None, None)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,9 @@ def __init__(self, datasetfile, card_type, host, port,
elif card_type == "handler_test":
from virtualsmartcard.cards.HandlerTest import HandlerTestOS
self.os = HandlerTestOS()
elif card_type == "belpic":
from virtualsmartcard.cards.belpic import BelpicOS
self.os = BelpicOS(MF, SAM)
else:
logging.warning("Unknown cardtype %s. Will use standard card_type \
(ISO 7816)", card_type)
Expand Down
27 changes: 27 additions & 0 deletions virtualsmartcard/src/vpicc/virtualsmartcard/cards/belpic.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#
# Copyright (C) 2017 Wouter Verhelst, Federal Public Service BOSA, DG DT
#
# This file is part of virtualsmartcard.
#
# virtualsmartcard is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the Free
# Software Foundation, either version 3 of the License, or (at your option) any
# later version.
#
# virtualsmartcard is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
# more details.
#
# You should have received a copy of the GNU General Public License along with
# 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

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'