From fc963b5d70ede86baa033a9ca629b2fa4f1c8732 Mon Sep 17 00:00:00 2001 From: oepen Date: Wed, 2 Nov 2011 13:09:02 +0000 Subject: [PATCH] Converting docstrings to sphinx syntax git-svn-id: https://vsmartcard.svn.sourceforge.net/svnroot/vsmartcard@607 96b47cad-a561-4643-ad3b-153ac7d7599c --- .../src/vpicc/virtualsmartcard/CryptoUtils.py | 22 +- .../src/vpicc/virtualsmartcard/SEutils.py | 64 +++--- .../virtualsmartcard/SmartcardFilesystem.py | 194 +++++++++++------- .../vpicc/virtualsmartcard/SmartcardSAM.py | 9 +- .../virtualsmartcard/cards/cryptoflex.py | 14 +- 5 files changed, 185 insertions(+), 118 deletions(-) diff --git a/virtualsmartcard/src/vpicc/virtualsmartcard/CryptoUtils.py b/virtualsmartcard/src/vpicc/virtualsmartcard/CryptoUtils.py index 18b1267..497dd58 100644 --- a/virtualsmartcard/src/vpicc/virtualsmartcard/CryptoUtils.py +++ b/virtualsmartcard/src/vpicc/virtualsmartcard/CryptoUtils.py @@ -121,15 +121,19 @@ def strip_padding(cipherspec, data, padding_class=0x01): 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 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 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 + """ + if algo not in ("HMAC", "MAC", "CC"): raise ValueError, "Unknown Algorithm %s" % algo @@ -254,7 +258,7 @@ def read_protected_string(string, password, cipherspec=None): ## * Cyberflex specific methods * ## ******************************************************************* def calculate_MAC(session_key, message, iv=CYBERFLEX_IV): - """" + """ Cyberflex MAC is the last Block of the input encrypted with DES3-CBC """ diff --git a/virtualsmartcard/src/vpicc/virtualsmartcard/SEutils.py b/virtualsmartcard/src/vpicc/virtualsmartcard/SEutils.py index cae1105..933be04 100644 --- a/virtualsmartcard/src/vpicc/virtualsmartcard/SEutils.py +++ b/virtualsmartcard/src/vpicc/virtualsmartcard/SEutils.py @@ -36,10 +36,11 @@ class ControlReferenceTemplate: def __init__(self, tag, config=""): """ Generates a new CRT - @param tag: Indicates the type of the CRT (HT, AT, KT, CCT, DST, CT-sym, - CT-asym) - @param config: A string containing TLV encoded Security Environment - parameters + + :param tag: Indicates the type of the CRT (HT, AT, KT, CCT, DST, CT-sym, \ + CT-asym) + :param config: A string containing TLV encoded Security Environment \ + parameters """ if tag not in (CRT_TEMPLATE["AT"], CRT_TEMPLATE["HT"], CRT_TEMPLATE["KAT"], CRT_TEMPLATE["CCT"], @@ -63,7 +64,8 @@ class ControlReferenceTemplate: def parse_SE_config(self, config): """ Parse a control reference template as given e.g. in an MSE APDU. - @param config : a TLV string containing the configuration for the CRT. + + :param config : a TLV string containing the configuration for the CRT. """ structure = unpack(config) @@ -87,7 +89,8 @@ class ControlReferenceTemplate: Set the algorithm to be used by this CRT. The algorithms are specified in a global dictionary. New cards may add or modify this table in order to support new or different algorithms. - @param data: reference to an algorithm + + :param data: reference to an algorithm """ if not ALGO_MAPPING.has_key(data): @@ -254,11 +257,13 @@ class Security_Environment(object): This methods parses a data field including Secure Messaging objects. SM_header indicates whether or not the header of the message shall be authenticated. It returns an unprotected command APDU - @param CAPDU: The protected CAPDU to be parsed - @param authenticate_header: Wether or not the header should be - included in authentication mechanisms - @return: Unprotected command APDU - """ + + :param CAPDU: The protected CAPDU to be parsed + :param authenticate_header: Whether or not the header should be + included in authentication mechanisms + :returns: Unprotected command APDU + """ + structure = unpack(CAPDU.data) return_data = ["",] expected = self.sm_objects @@ -399,7 +404,8 @@ class Security_Environment(object): def protect_response(self, sw, result): """ This method protects a response APDU using secure messaging mechanisms - It returns the protected data and the SW bytes + + :returns: the protected data and the SW bytes """ expected = self.sm_objects for pos in range(len(expected)): @@ -495,9 +501,10 @@ class Security_Environment(object): """ Compute a digital signature for the given data. Algorithm and key are specified in the current SE - @param p1: Must be 0x9E = Secure Messaging class for digital signatures - @param p2: Must be one of 0x9A, 0xAC, 0xBC. Indicates what kind of data - is included in the data field. + + :param p1: Must be 0x9E = Secure Messaging class for digital signatures + :param p2: Must be one of 0x9A, 0xAC, 0xBC. Indicates what kind of data + is included in the data field. """ if p1 != 0x9E or not p2 in (0x9A, 0xAC, 0xBC): @@ -522,9 +529,10 @@ class Security_Environment(object): def hash(self, p1, p2, data): """ - Hash the given data using the algorithm specified by the - current Security environment. - Return raw data (no TLV coding). + Hash the given data using the algorithm specified by the current + Security environment. + + :return: raw data (no TLV coding). """ if p1 != 0x90 or not p2 in (0x80, 0xA0): raise SwError(SW["ERR_INCORRECTP1P2"]) @@ -616,7 +624,8 @@ class Security_Environment(object): """ Encipher data using key, algorithm, IV and Padding specified by the current Security environment. - Return raw data (no TLV coding). + + :returns: raw data (no TLV coding). """ algo = self.ct.algorithm key = self.ct.key @@ -631,7 +640,8 @@ class Security_Environment(object): """ Decipher data using key, algorithm, IV and Padding specified by the current Security environment. - Return raw data (no TLV coding). Padding is not removed!!! + + :returns: raw data (no TLV coding). Padding is not removed!!! """ algo = self.ct.algorithm key = self.ct.key @@ -642,16 +652,16 @@ class Security_Environment(object): return SW["NORMAL"], plain def generate_public_key_pair(self, p1, p2, data): - """The GENERATE PUBLIC-KEY PAIR command either initiates the generation + """ + The GENERATE PUBLIC-KEY PAIR command either initiates the generation and storing of a key pair, i.e., a public key and a private key, in the card, or accesses a key pair previously generated in the card. - @param p1: - @param p2:'00' (no information provided) or reference of the key to be - generated - @param data: One or more CRTs associated to the key generation if P1-P2 - different from '0000' - + :param p1: should be 0x00 (generate new key) + :param p2:'00' (no information provided) or reference of the key to be \ + generated + :param data: One or more CRTs associated to the key generation if P1-P2 \ + different from '0000' """ from Crypto.PublicKey import RSA, DSA diff --git a/virtualsmartcard/src/vpicc/virtualsmartcard/SmartcardFilesystem.py b/virtualsmartcard/src/vpicc/virtualsmartcard/SmartcardFilesystem.py index 317178a..3f1b482 100644 --- a/virtualsmartcard/src/vpicc/virtualsmartcard/SmartcardFilesystem.py +++ b/virtualsmartcard/src/vpicc/virtualsmartcard/SmartcardFilesystem.py @@ -103,13 +103,12 @@ def write(old, newlist, offsets, datacoding, maxsize=None): """Returns the status bytes and the result of a write operation according to the given data coding. - @param old: string of old data - @param newlist: a list of new data string - @param offsets: a list of offsets, each for one new data strings - @param datacoding: DCB["ONETIMEWRITE"] (replace) or DCB["WRITEOR"] (logical or) - or DCB["WRITEAND"] (logical and) or DCB["PROPRIETARY"] - (logical xor) - @param maxsize: the maximum number of bytes in the result + :param old: string of old data + :param newlist: a list of new data string + :param offsets: a list of offsets, each for one new data strings + :param datacoding: DCB["ONETIMEWRITE"] (replace) or DCB["WRITEOR"] (logical or) + or DCB["WRITEAND"] (logical and) or DCB["PROPRIETARY"] (logical xor) + :param maxsize: the maximum number of bytes in the result """ result = old listindex = 0 @@ -686,8 +685,10 @@ class MF(DF): def selectFile(self, p1, p2, data): """ Function for instruction 0xa4. Takes the parameter bytes 'p1', 'p2' as - integers and 'data' as binary string. Returns the status bytes as two - byte long integer and the response data as binary string. + integers and 'data' as binary string. + + :returns: the status bytes as two byte long integer and the response + data as binary string. """ P2_FCI = 0 P2_FCP = 1 << 2 @@ -716,8 +717,9 @@ class MF(DF): """ Decodes 'p1', 'p2' and 'data' from a data unit command (i. e. read/write/update/search/erase binary) with *odd* instruction code. - Returns the specified TransparentStructureEF, a list of offsets and a - list of data strings. + + :returns: the specified TransparentStructureEF, a list of offsets and a + list of data strings. """ if p1 >> 7: # If bit 1 of INS is set to 0 and bit 8 of P1 to 1, then bits 7 @@ -741,8 +743,9 @@ class MF(DF): """ Decodes 'p1', 'p2' and 'data' from a data unit command (i. e. read/write/update/search/erase binary) with *even* instruction code. - Returns the specified TransparentStructureEF, a list of offsets and a - list of data strings. + + :returns the specified TransparentStructureEF, a list of offsets and a + list of data strings. """ # If bit 1 of INS is set to 1, then P1-P2 shall identify an EF. If # the first eleven bits of P1-P2 are set to 0 and if bits 5 to 1 of @@ -769,8 +772,10 @@ class MF(DF): def readBinaryPlain(self, p1, p2, data): """ Function for instruction 0xb0. Takes the parameter bytes 'p1', 'p2' as - integers and 'data' as binary string. Returns the status bytes as two - byte long integer and the response data as binary string. + integers and 'data' as binary string. + + :returns: the status bytes as two byte long integer and the response + data as binary string. """ ef, offsets, datalist = self.dataUnitsDecodePlain(p1, p2, data) result = ef.readbinary(offsets[0]) @@ -780,8 +785,10 @@ class MF(DF): def readBinaryEncapsulated(self, p1, p2, data): """ Function for instruction 0xb1. Takes the parameter bytes 'p1', 'p2' as - integers and 'data' as binary string. Returns the status bytes as two - byte long integer and the response data as binary string. + integers and 'data' as binary string. + + :returns: the status bytes as two byte long integer and the response + data as binary string. """ ef, offsets, datalist = self.dataUnitsDecodeEncapsulated(p1, p2, data) result = ef.readbinary(offsets[0]) @@ -793,8 +800,10 @@ class MF(DF): def writeBinaryPlain(self, p1, p2, data): """ Function for instruction 0xd0. Takes the parameter bytes 'p1', 'p2' as - integers and 'data' as binary string. Returns the status bytes as two - byte long integer and the response data as binary string. + integers and 'data' as binary string. + + :returns: the status bytes as two byte long integer and the response + data as binary string. """ ef, offsets, datalist = self.dataUnitsDecodePlain(p1, p2, data) ef.writebinary(offsets, datalist) @@ -815,8 +824,10 @@ class MF(DF): def updateBinaryPlain(self, p1, p2, data): """ Function for instruction 0xd6. Takes the parameter bytes 'p1', 'p2' as - integers and 'data' as binary string. Returns the status bytes as two - byte long integer and the response data as binary string. + integers and 'data' as binary string. + + :returns: the status bytes as two byte long integer and the response + data as binary string. """ ef, offsets, datalist = self.dataUnitsDecodePlain(p1, p2, data) ef.updatebinary(offsets, datalist) @@ -826,8 +837,10 @@ class MF(DF): def updateBinaryEncapsulated(self, p1, p2, data): """ Function for instruction 0xd7. Takes the parameter bytes 'p1', 'p2' as - integers and 'data' as binary string. Returns the status bytes as two - byte long integer and the response data as binary string. + integers and 'data' as binary string. + + :returns: the status bytes as two byte long integer and the response + data as binary string. """ ef, offsets, datalist = self.dataUnitsDecodeEncapsulated(p1, p2, data) ef.updatebinary(offsets, datalist) @@ -859,8 +872,10 @@ class MF(DF): def eraseBinaryPlain(self, p1, p2, data): """ Function for instruction 0x0e. Takes the parameter bytes 'p1', 'p2' as - integers and 'data' as binary string. Returns the status bytes as two - byte long integer and the response data as binary string. + integers and 'data' as binary string. + + :returns: the status bytes as two byte long integer and the response + data as binary string. """ ef, offsets, datalist = self.dataUnitsDecodePlain(p1, p2, data) # If INS = '0E', then, if present, the command data field encodes @@ -881,8 +896,10 @@ class MF(DF): def eraseBinaryEncapsulated(self, p1, p2, data): """ Function for instruction 0x0f. Takes the parameter bytes 'p1', 'p2' as - integers and 'data' as binary string. Returns the status bytes as two - byte long integer and the response data as binary string. + integers and 'data' as binary string. + + :returns: the status bytes as two byte long integer and the response + data as binary string. """ ef, offsets, datalist = self.dataUnitsDecodeEncapsulated(p1, p2, data) # If INS = '0F', then, if present, the command data field shall @@ -909,10 +926,11 @@ class MF(DF): def recordHandlingDecode(self, p1, p2): """ Decodes 'p1' and 'p2' from a record handling command (i. e. - read/write/update/append/search/erase record). Returns the specified - RecordStructureEF, the number or identifier of the record and a - reference, that specifies which record to select (i. e. the last 3 bits - of 'p1'). + read/write/update/append/search/erase record). + + :returns: the specified RecordStructureEF, the number or identifier of + the record and a reference, that specifies which record to select + (i. e. the last 3 bits of 'p1'). """ if p1 == 0xff: # RFU @@ -938,8 +956,10 @@ class MF(DF): def readRecordPlain(self, p1, p2, data): """ Function for instruction 0xb2. Takes the parameter bytes 'p1', 'p2' as - integers and 'data' as binary string. Returns the status bytes as two - byte long integer and the response data as binary string. + integers and 'data' as binary string. + + :returns: the status bytes as two byte long integer and the response + data as binary string. """ ef, num_id, reference = self.recordHandlingDecode(p1, p2) result = ef.readrecord(0, num_id, reference) @@ -953,8 +973,10 @@ class MF(DF): def readRecordEncapsulated(self, p1, p2, data): """ Function for instruction 0xb3. Takes the parameter bytes 'p1', 'p2' as - integers and 'data' as binary string. Returns the status bytes as two - byte long integer and the response data as binary string. + integers and 'data' as binary string. + + :returns: the status bytes as two byte long integer and the response + data as binary string. """ ef, num_id, reference = self.recordHandlingDecode(p1, p2) result = ef.readrecord(0, num_id, reference) @@ -964,8 +986,10 @@ class MF(DF): def writeRecord(self, p1, p2, data): """ Function for instruction 0xd2. Takes the parameter bytes 'p1', 'p2' as - integers and 'data' as binary string. Returns the status bytes as two - byte long integer and the response data as binary string. + integers and 'data' as binary string. + + :returns: the status bytes as two byte long integer and the response + data as binary string. """ ef, num_id, reference = self.recordHandlingDecode(p1, p2) if reference not in [ REF["IDENTIFIER_FIRST"], REF["IDENTIFIER_LAST"], @@ -980,8 +1004,10 @@ class MF(DF): def updateRecordPlain(self, p1, p2, data): """ Function for instruction 0xdc. Takes the parameter bytes 'p1', 'p2' as - integers and 'data' as binary string. Returns the status bytes as two - byte long integer and the response data as binary string. + integers and 'data' as binary string. + + :returns: the status bytes as two byte long integer and the response + data as binary string. """ ef, num_id, reference = self.recordHandlingDecode(p1, p2) if reference not in [ REF["IDENTIFIER_FIRST"], REF["IDENTIFIER_LAST"], @@ -996,8 +1022,10 @@ class MF(DF): def updateRecordEncapsulated(self, p1, p2, data): """ Function for instruction 0xdd. Takes the parameter bytes 'p1', 'p2' as - integers and 'data' as binary string. Returns the status bytes as two - byte long integer and the response data as binary string. + integers and 'data' as binary string. + + :returns: the status bytes as two byte long integer and the response + data as binary string. """ ef, num_id, reference = self.recordHandlingDecode(p1, p2) @@ -1033,8 +1061,10 @@ class MF(DF): def appendRecord(self, p1, p2, data): """ Function for instruction 0xe2. Takes the parameter bytes 'p1', 'p2' as - integers and 'data' as binary string. Returns the status bytes as two - byte long integer and the response data as binary string. + integers and 'data' as binary string. + + :returns: the status bytes as two byte long integer and the response + data as binary string. """ if p1 != 0 or (p2 & REF["REFERENCE_CONTROL"]) != 0: raise SwError(SW["ERR_INCORRECTP1P2"]) @@ -1046,8 +1076,10 @@ class MF(DF): def eraseRecord(self, p1, p2, data): """ Function for instruction 0x0c. Takes the parameter bytes 'p1', 'p2' as - integers and 'data' as binary string. Returns the status bytes as two - byte long integer and the response data as binary string. + integers and 'data' as binary string. + + :returns: the status bytes as two byte long integer and the response + data as binary string. """ ef, num_id, reference = self.recordHandlingDecode(p1, p2) if reference not in [ @@ -1062,9 +1094,11 @@ class MF(DF): def dataObjectHandlingDecodePlain(self, p1, p2, data): """ Decodes 'p1', 'p2' and 'data' from a data object handling command (i. - e. get/put data) with *even* instruction code. Returns the specified - file, True if the following list regards SIMPLE-TLV data objects False - otherwise and a list of (tag, length, value)-tuples. + e. get/put data) with *even* instruction code. + + :returns: the specified file, True if the following list regards + SIMPLE-TLV data objects False otherwise and a list of + (tag, length, value)-tuples. """ if self.current == None: raise SwError(SW["ERR_NOCURRENTEF"]) @@ -1109,9 +1143,11 @@ class MF(DF): def dataObjectHandlingDecodeEncapsulated(self, p1, p2, data): """ Decodes 'p1', 'p2' and 'data' from a data object handling command (i. - e. get/put data) with *odd* instruction code. Returns the specified - file, True if the following list regards SIMPLE-TLV data objects False - otherwise and a list of (tag, length, value)-tuples. + e. get/put data) with *odd* instruction code. + + :returns: the specified file, True if the following list regards + SIMPLE-TLV data objects False otherwise and a list of + (tag, length, value)-tuples. """ # If bit 1 of INS is set to 1, then P1-P2 shall identify a file. tlv_data = bertlv_unpack(data) @@ -1147,8 +1183,10 @@ class MF(DF): def getDataPlain(self, p1, p2, data): """ Function for instruction 0xca. Takes the parameter bytes 'p1', 'p2' as - integers and 'data' as binary string. Returns the status bytes as two - byte long integer and the response data as binary string. + integers and 'data' as binary string. + + :returns: the status bytes as two byte long integer and the response + data as binary string. """ file, isSimpleTlv, tlvlist = self.dataObjectHandlingDecodePlain(p1, p2, data) # TODO oversized answers @@ -1160,8 +1198,10 @@ class MF(DF): def getDataEncapsulated(self, p1, p2, data): """ Function for instruction 0xcb. Takes the parameter bytes 'p1', 'p2' as - integers and 'data' as binary string. Returns the status bytes as two - byte long integer and the response data as binary string. + integers and 'data' as binary string. + + :returns: the status bytes as two byte long integer and the response + data as binary string. """ file, tlv_data = self.dataObjectHandlingDecodeEncapsulated(p1, p2, data) # TODO oversized answers @@ -1176,8 +1216,10 @@ class MF(DF): def putDataPlain(self, p1, p2, data): """ Function for instruction 0xda. Takes the parameter bytes 'p1', 'p2' as - integers and 'data' as binary string. Returns the status bytes as two - byte long integer and the response data as binary string. + integers and 'data' as binary string. + + :returns: the status bytes as two byte long integer and the response + data as binary string. """ file, isSimpleTlv, tlvlist = self.dataObjectHandlingDecodePlain(p1, p2, data) file.putdata(isSimpleTlv, tlvlist) @@ -1187,8 +1229,10 @@ class MF(DF): def putDataEncapsulated(self, p1, p2, data): """ Function for instruction 0xdb. Takes the parameter bytes 'p1', 'p2' as - integers and 'data' as binary string. Returns the status bytes as two - byte long integer and the response data as binary string. + integers and 'data' as binary string. + + :returns: the status bytes as two byte long integer and the response + data as binary string. """ file, tlvlist = self.dataObjectHandlingDecodeEncapsulated(p1, p2, data) file.putdata(False, tlvlist) @@ -1270,8 +1314,10 @@ class MF(DF): def createFile(self, p1, p2, data): """ Function for instruction 0xe0. Takes the parameter bytes 'p1', 'p2' as - integers and 'data' as binary string. Returns the status bytes as two - byte long integer and the response data as binary string. + integers and 'data' as binary string. + + :returns: the status bytes as two byte long integer and the response + data as binary string. """ df = self.currentDF() if df == None: @@ -1287,8 +1333,10 @@ class MF(DF): def deleteFile(self, p1, p2, data): """ Function for instruction 0xe4. Takes the parameter bytes 'p1', 'p2' as - integers and 'data' as binary string. Returns the status bytes as two - byte long integer and the response data as binary string. + integers and 'data' as binary string. + + :returns: the status bytes as two byte long integer and the response + data as binary string. """ file = self._selectFile(p1, p2, data) file.parent.content.remove(file) @@ -1356,9 +1404,9 @@ class TransparentStructureEF(EF): Writes pieces of data to the specified offsets honoring the given coding byte. - offsets -- list of integers. Offsets. - datalist -- list of strings. Data pieces. - datacoding -- the data coding byte to use for writing + :param offsets: list of integers. Offsets. + :param datalist: list of strings. Data pieces. + :param datacoding: the data coding byte to use for writing """ data = self.getenc('data') if datacoding: @@ -1430,8 +1478,8 @@ class RecordStructureEF(EF): which kind of record structured file you want to create (i. e. linear/cyclic or variable/fixed EF). The record pointer is reset. - records -- list of Records - maxrecordsize -- integer. maximum length of a record's data. + :param records: list of Records + :para, maxrecordsize: integer. maximum length of a record's data. See EF for more. """ @@ -1495,8 +1543,9 @@ class RecordStructureEF(EF): """ Returns a list of records. Is to be involved by __getRecords. - number -- The requested record's number - reference -- Specifies which record to select (usually the last 3 bits of 'p1' of a record handling command) + :param number: The requested record's number + :param reference: Specifies which record to select (usually the last 3 + bits of 'p1' of a record handling command) """ result = [] records = self.getenc('records') @@ -1528,8 +1577,9 @@ class RecordStructureEF(EF): Returns a list of records and sets the recordpointer to the first record, that matched. Is to be involved by __getRecords. - id -- The requested record's identifier - reference -- Specifies which record to select (usually the last 3 bits of 'p1' of a record handling command) + :param id: The requested record's identifier + :param reference: Specifies which record to select (usually the last 3 + bits of 'p1' of a record handling command) """ result = [] records = self.getenc('records') diff --git a/virtualsmartcard/src/vpicc/virtualsmartcard/SmartcardSAM.py b/virtualsmartcard/src/vpicc/virtualsmartcard/SmartcardSAM.py index 49ead14..0a8a921 100644 --- a/virtualsmartcard/src/vpicc/virtualsmartcard/SmartcardSAM.py +++ b/virtualsmartcard/src/vpicc/virtualsmartcard/SmartcardSAM.py @@ -147,8 +147,8 @@ class SAM(object): def set_asym_algorithm(self, cipher, keytype): """ - @param cipher: Public/private key object from used for encryption - @param keytype: Type of the public key (e.g. RSA, DSA) + :param cipher: Public/private key object from used for encryption + :param keytype: Type of the public key (e.g. RSA, DSA) """ if not keytype in range(0x07, 0x08): raise SwError(SW["ERR_INCORRECTP1P2"]) @@ -289,8 +289,9 @@ class SAM(object): """ This method returns the key specified by the p2 parameter. The key may be 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 p1: Specifies the algorithm to use. Needed to know the keylength. + :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 diff --git a/virtualsmartcard/src/vpicc/virtualsmartcard/cards/cryptoflex.py b/virtualsmartcard/src/vpicc/virtualsmartcard/cards/cryptoflex.py index 8928da2..7c68aa3 100644 --- a/virtualsmartcard/src/vpicc/virtualsmartcard/cards/cryptoflex.py +++ b/virtualsmartcard/src/vpicc/virtualsmartcard/cards/cryptoflex.py @@ -37,10 +37,10 @@ class CryptoflexSE(Security_Environment): """ In the Cryptoflex card this command only supports RSA keys. - @param data: Contains the public exponent used for key generation - @param p1: The keynumber. Can be used later to refer to the generated key - @param p2: Used to specify the keylength. - The mapping is: 0x40 => 256 Bit, 0x60 => 512 Bit, 0x80 => 1024 + :param data: Contains the public exponent used for key generation + :param p1: The key number. Can be used later to refer to the generated key \ + :param p2: Used to specify the key length. The mapping is: 0x40 => 256 \ + Bit, 0x60 => 512 Bit, 0x80 => 1024 """ from Crypto.PublicKey import RSA from Crypto.Util.randpool import RandomPool @@ -107,9 +107,11 @@ class CryptoflexSAM(SAM): In the cryptoflex card, this is the verify key command. A key is send to the card in plain text and compared to a key stored in the card. This is used for authentication - @param data: Contains the key to be verified - @return: SW[NORMAL] in case of success otherwise SW[WARN_NOINFO63] + + :param data: Contains the key to be verified + :returns: SW[NORMAL] in case of success otherwise SW[WARN_NOINFO63] """ + return SW["NORMAL"], "" #FIXME #key = self._get_referenced_key(p1,p2)