From c070394f824cffeefa5a8dbd7776c6e563588210 Mon Sep 17 00:00:00 2001 From: psytester Date: Mon, 19 May 2014 21:26:40 +0200 Subject: [PATCH 1/3] vicc reads dataset file That new option -d or --datasetfile will read an optional dataset file to be able to start vicc->CardGenerator.py with various content --- virtualsmartcard/src/vpicc/vicc.in | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/virtualsmartcard/src/vpicc/vicc.in b/virtualsmartcard/src/vpicc/vicc.in index 170467e..5fd7b53 100644 --- a/virtualsmartcard/src/vpicc/vicc.in +++ b/virtualsmartcard/src/vpicc/vicc.in @@ -45,6 +45,16 @@ parser.add_argument("-f", "--file", action="store", type=argparse.FileType('r'), help="load a saved smart card image") +parser.add_argument("-d", "--datasetfile", + action="store", + help="Load the smartcard's data groups (DGs) from the specified dataset file. For DGs not in dataset file default values are used. \ +The data groups in the data set file must have the following syntax: \ +--------------------------------------------------- Datagroupname=Datagroupvalue \ +--------------------------------------------------- \ +For Example: GivenNames=GERTRUD. \ +The following Dataset Elements may be used in the dataset file: \ +DocumentType, IssuingState, DateOfExpiry, GivenNames, FamilyNames, ReligiousArtisticName, AcademicTitle, DateOfBirth, PlaceOfBirth, Nationality, Sex, Country, City, ZIP, Street, CommunityID, dg12, dg13, dg14, dg15, dg16, dg19, dg20, dg21.\ +") parser.add_argument("-H", "--hostname", action="store", type=str, @@ -126,7 +136,7 @@ if args.reversed: else: hostname = args.hostname -vicc = VirtualICC(args.file, args.type, +vicc = VirtualICC(args.file, args.datasetfile, args.type, hostname, args.port, readernum=args.reader, ef_cardaccess=ef_cardaccess_data, ef_cardsecurity=ef_cardsecurity_data, ca_key=ca_key_data, cvca=cvca, disable_checks=args.disable_ta_checks, logginglevel=logginglevel) From c411deeb2ebdfde2338228c612d8b99e1b56df19 Mon Sep 17 00:00:00 2001 From: psytester Date: Mon, 19 May 2014 21:43:08 +0200 Subject: [PATCH 2/3] VirtualSmartcard new option for dataset pass dataset file to CardGenerator --- .../src/vpicc/virtualsmartcard/VirtualSmartcard.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/virtualsmartcard/src/vpicc/virtualsmartcard/VirtualSmartcard.py b/virtualsmartcard/src/vpicc/virtualsmartcard/VirtualSmartcard.py index 902e075..33eddf4 100644 --- a/virtualsmartcard/src/vpicc/virtualsmartcard/VirtualSmartcard.py +++ b/virtualsmartcard/src/vpicc/virtualsmartcard/VirtualSmartcard.py @@ -629,7 +629,7 @@ class VirtualICC(object): the vpcd, which forwards it to the application. """ - def __init__(self, filename, card_type, host, port, readernum=None, ef_cardsecurity=None, ef_cardaccess=None, ca_key=None, cvca=None, disable_checks=False, logginglevel=logging.INFO): + def __init__(self, filename, datasetfile, card_type, host, port, readernum=None, ef_cardsecurity=None, ef_cardaccess=None, ca_key=None, cvca=None, disable_checks=False, logginglevel=logging.INFO): from os.path import exists logging.basicConfig(level = logginglevel, @@ -647,7 +647,17 @@ class VirtualICC(object): else: logging.info("Creating new card which will be saved in %s.", self.filename) - + + #If a dataset file is specified, read the card's data groups from disk + if datasetfile != None: + if exists(datasetfile): + logging.info("Reading Data Groups from file %s.", + datasetfile) + self.cardGenerator.readDatagroups(datasetfile) + else: + logging.info("Data Set File %s not found, using default values for datagroups.", + self.datasetfile) + MF, SAM = self.cardGenerator.getCard() #Generate an OS object of the correct card_type From 4d7b9dfbb65cf0575413f73a47d125acd9399e08 Mon Sep 17 00:00:00 2001 From: psytester Date: Mon, 19 May 2014 21:45:56 +0200 Subject: [PATCH 3/3] example dataset file An example how th new dataset file has to look like --- .../vpicc/Example_Dataset_Mueller_Gertrud.txt | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 virtualsmartcard/src/vpicc/Example_Dataset_Mueller_Gertrud.txt diff --git a/virtualsmartcard/src/vpicc/Example_Dataset_Mueller_Gertrud.txt b/virtualsmartcard/src/vpicc/Example_Dataset_Mueller_Gertrud.txt new file mode 100644 index 0000000..7f085fd --- /dev/null +++ b/virtualsmartcard/src/vpicc/Example_Dataset_Mueller_Gertrud.txt @@ -0,0 +1,22 @@ +# This is an example dataset file vor the virtual smartcard. +# Datagroups are just given in plain ascii, separated by =. +# CommunityID has to be given as hex values enclosed with ' '. +# The File is passed to the virtual smartcard emulator via +# command line option -d, with or without path. +# +DocumentType=ID +IssuingState=D +DateOfExpiry=20201031 +GivenNames = Gertrud +FamilyNames=Mueller +ReligiousArtisticName=ǏǐǑǒǓǔǞǟǤǥǦǧǨǩǪǫǬǭǮǯǰǴǵǺǻǼǽǾǿȘșȚțȞȟȪȫȮȯȰ +AcademicTitle= +DateOfBirth=19530304 +PlaceOfBirth= BERLIN FRIEDENAU +Nationality=DE +Sex=F +Country=D +City=BREMEN +ZIP=28195 +Street =STADTMUSIKANTENWEG 12a +CommunityID='\x02\x76\x03\x02\x54\x00\x21'