def get_data(self, msb_tag, lsb_tag): """ Returns the command/response pair for the GET DATA command. The msb_tag and lsb_tag represent the most significant and least significant part of the tag byte respectively.""" # GET DATA command encoding. # Same problem as in READ RECORD. See read_record() for more details. tmp = CommandAPDU(0x80, 0xca, msb_tag, lsb_tag).getBytes() tmp.append(0) command = CommandAPDU(tmp) return self.send_command(command)
def get_data(self, msb_tag, lsb_tag): """ Returns the command/response pair for the GET DATA command. The msb_tag and lsb_tag represent the most significant and least significant part of the tag byte respectively.""" # GET DATA command encoding. # Same problem as in READ RECORD. See read_record() for more details. tmp = CommandAPDU(0x80, 0xca, msb_tag, lsb_tag).getBytes() tmp.append(0) command = CommandAPDU(tmp) return self.send_command(command)
def select(self, aid): """ Returns the command/response pair for the SELECT command. Parameter aid is a byte string representing the aid to select.""" aid = util.str2ba(aid) # SELECT command encoding. command = CommandAPDU(0x00, 0xa4, 0x04, 0x00, aid) return self.send_command(command)
def read_record(self, sfi, rnbr): # read record command encoding. # command = CommandAPDU(0x00, 0x82, rnbr, (sfi << 3 | 4)) # TODO: for some reason, the commented command above DOES NOT WORK. # you need to manually add the Le parameter of the read_record command # Le. This should be investigated further but in the meantime, # let's use a work around and add it ourself manually. # Does this only happen when there is no command body? read further # about it in EMV book 3 v4.3 tmp = CommandAPDU(0x00, 0xb2, rnbr, (sfi << 3 | 4)).getBytes() tmp.append(0) command = CommandAPDU(tmp) return self.send_command(command)
def read_record(self, sfi, rnbr): # read record command encoding. # command = CommandAPDU(0x00, 0x82, rnbr, (sfi << 3 | 4)) # TODO: for some reason, the commented command above DOES NOT WORK. # you need to manually add the Le parameter of the read_record command # Le. This should be investigated further but in the meantime, # let's use a work around and add it ourself manually. # Does this only happen when there is no command body? read further # about it in EMV book 3 v4.3 tmp = CommandAPDU(0x00, 0xb2, rnbr, (sfi << 3 | 4)).getBytes() tmp.append(0) command = CommandAPDU(tmp) return self.send_command(command)
def internal_authenticate(self, auth_data): """ Return the command/response pair for the INTERNAL AUTHENTICATE command. The parameter auth_data shall be encoded according to the DDOL. """ #TODO: test card does not support DDA. Find a test card that does and # test this function. command = CommandAPDU(0x00, 0x88, 0x00, 0x00, auth_data) return self.send_command(command)
def get_processing_options(self, pdol='\x83\00'): """ Returns the command/response pair for the GET PROCESSING OPTIONS command. If the pdol parameter is not specified, the default pdol value of 0x8300 is used.""" # GET PROCESSING OPTIONS encoding command = CommandAPDU(0x80, 0xa8, 0x00, 0x00, pdol) return self.send_command(command)
def get_challenge(self): """returns the command/response pair for the GET CHALLENGE command.""" # This Java package is either cursed or I do not get it. # the command below will not work. Issuing the command by "hand" # as a work around until further investigation. This is similar # to the read_record, and get_data problem. # command = CommandAPDU(0x00, 0x84, 0x00, 0x00) command = CommandAPDU('\x00\x84\x00\x00\x00') return self.send_command(command)