diff --git a/virtualsmartcard/src/vpicc/virtualsmartcard/CryptoUtils.py b/virtualsmartcard/src/vpicc/virtualsmartcard/CryptoUtils.py index 497dd58..5a1de69 100644 --- a/virtualsmartcard/src/vpicc/virtualsmartcard/CryptoUtils.py +++ b/virtualsmartcard/src/vpicc/virtualsmartcard/CryptoUtils.py @@ -122,15 +122,17 @@ def crypto_checksum(algo, key, data, iv=None, ssc=None): """ Compute various types of cryptographic checksums. - :param algo: A string specifying the algorithm to use. Currently supported \ - algorithms are \"MAX\" \"HMAC\" and \"CC\" (Meaning a cryptographic checksum \ - as used by the ICAO passports) + :param algo: + A string specifying the algorithm to use. Currently supported + algorithms are \"MAX\" \"HMAC\" and \"CC\" (Meaning a cryptographic + checksum as used by the ICAO passports) :param key: They key used to computed the cryptographic checksum :param data: The data for which to calculate the checksum - :param iv: Optional. An initialization vector. Only used by the \"MAC\" \ - algorithm - :param ssc: Optional. A send sequence counter to be prepended to the data. \ - Only used by the \"CC\" algorithm + :param iv: + Optional. An initialization vector. Only used by the \"MAC\" algorithm + :param ssc: + Optional. A send sequence counter to be prepended to the data. + Only used by the \"CC\" algorithm """ diff --git a/virtualsmartcard/src/vpicc/virtualsmartcard/SEutils.py b/virtualsmartcard/src/vpicc/virtualsmartcard/SEutils.py index 1c29e48..a795c36 100644 --- a/virtualsmartcard/src/vpicc/virtualsmartcard/SEutils.py +++ b/virtualsmartcard/src/vpicc/virtualsmartcard/SEutils.py @@ -191,20 +191,23 @@ class Security_Environment(object): referred SE or the tag of a control reference template :param p1: - == == == == == == == == ====================================== + Bitmask according to this table + + == == == == == == == == ======================================= b8 b7 b6 b5 b4 b3 b2 b1 Meaning - == == == == == == == == ====================================== - - - - 1 - - - - Secure messaging in command data field - - - 1 - - - - - Secure messaging in response data field - - 1 - - - - - - Computation, decipherment, internal + == == == == == == == == ======================================= + - - - 1 - - - - Secure messaging in command data field + - - 1 - - - - - Secure messaging in response data field + - 1 - - - - - - Computation, decipherment, internal authentication and key agreement - 1 - - - - - - - Verification, encipherment, external + 1 - - - - - - - Verification, encipherment, external authentication and key agreement - - - - - 0 0 0 1 SET + - - - - 0 0 0 1 SET 1 1 1 1 0 0 1 0 STORE 1 1 1 1 0 0 1 1 RESTORE 1 1 1 1 0 1 0 0 ERASE - == == == == == == == == ====================================== + == == == == == == == == ======================================= + """ cmd = p1 & 0x0F diff --git a/virtualsmartcard/src/vpicc/virtualsmartcard/SmartcardFilesystem.py b/virtualsmartcard/src/vpicc/virtualsmartcard/SmartcardFilesystem.py index c5a02ca..75fccb0 100644 --- a/virtualsmartcard/src/vpicc/virtualsmartcard/SmartcardFilesystem.py +++ b/virtualsmartcard/src/vpicc/virtualsmartcard/SmartcardFilesystem.py @@ -40,8 +40,8 @@ def isEqual(list): def walk(start, path): """Walks a path of fids and returns the last file (EF or DF). - start -- DF, where to look for the first fid - path -- a string of fids + :param start: DF, where to look for the first fid + :param path: a string of fids """ if len(path) % 2 != 0: raise SwError(SW["ERR_INCORRECTPARAMETERS"]) @@ -60,8 +60,8 @@ def getfile_byrefdataobj(mf, refdataobjs): """Returns a list of files according to the given list of reference data objects. - mf -- the MF - refdataobjs -- a list of 3-tuples (tag, length, newvalue)""" + param mf: the MF + param refdataobjs: a list of 3-tuples (tag, length, newvalue)""" result = [None] for tag, length, newvalue in refdataobjs: @@ -520,15 +520,6 @@ class MF(DF): """ Returns a byte according to the first software function table from the historical bytes of the card capabilities. - - DFSelectionByFullDFName -- Bool (True). - DFSelectionByPartialDFName -- Bool (True). - DFSelectionByPath -- Bool (True). - DFSelectionByFID -- Bool (True). - DFSelectionByApplication_implicite -- Bool (True). - ShortFIDSupported -- Bool (True). - RecordNumberSupported -- Bool (True). - RecordIdentifierSupported -- Bool (True). """ fsft = 0 if DFSelectionByFullDFName: @@ -1530,8 +1521,8 @@ class RecordStructureEF(EF): """ Returns a list of records. - num_id -- The requested record's number or identifier - reference -- Specifies which record to select (usually the last 3 bits of 'p1' of a record handling command) + :param num_id: The requested record's number or identifier + :param reference: Specifies which record to select (usually the last 3 bits of 'p1' of a record handling command) """ if (reference >> 2) == 1: return self.__getRecordsByNumber(num_id, reference) diff --git a/virtualsmartcard/src/vpicc/virtualsmartcard/SmartcardSAM.py b/virtualsmartcard/src/vpicc/virtualsmartcard/SmartcardSAM.py index 0a8a921..4077cd8 100644 --- a/virtualsmartcard/src/vpicc/virtualsmartcard/SmartcardSAM.py +++ b/virtualsmartcard/src/vpicc/virtualsmartcard/SmartcardSAM.py @@ -291,15 +291,18 @@ class SAM(object): stored on the cards filesystem. :param p1: Specifies the algorithm to use. Needed to know the keylength. - :param p2: Specifies a reference to the key to be used for encryption + :param p2: + + Specifies a reference to the key to be used for encryption - Meaning of p2: - b8 b7 b6 b5 b4 b3 b2 b1 | Meaning - 0 0 0 0 0 0 0 0 | No information is given - 0 -- -- -- -- -- -- -- | Global reference data(e.g. MF specific key) - 1 -- -- -- -- -- -- -- | Specific reference data(e.g. DF specific key) - -- -- -- x x x x x | Number of the secret - Any other value | RFU + b8 b7 b6 b5 b4 b3 b2 b1 Meaning + == == == == == == == == ============================================= + 0 0 0 0 0 0 0 0 No information is given + 0 - - - - - - - Global reference data(e.g. MF specific key) + 1 - - - - - - - Specific reference data(e.g. DF specific key) + - - - x x x x x Number of the secret + == == == == == == == == ============================================= + Any other value RFU """ key = None diff --git a/virtualsmartcard/src/vpicc/virtualsmartcard/VirtualSmartcard.py b/virtualsmartcard/src/vpicc/virtualsmartcard/VirtualSmartcard.py index 90effc2..296a874 100644 --- a/virtualsmartcard/src/vpicc/virtualsmartcard/VirtualSmartcard.py +++ b/virtualsmartcard/src/vpicc/virtualsmartcard/VirtualSmartcard.py @@ -51,7 +51,7 @@ class SmartcardOS(object): def execute(self, msg): """Returns response to the given APDU as string of characters - msg -- the APDU as string of characters + :param msg: the APDU as string of characters """ return ""