def _send_apdu_raw(self, pdu): apdu = h2i(pdu) data, sw1, sw2 = self._con.transmit(apdu) sw = [sw1, sw2] # Return value return i2h(data), i2h(sw)
def send_apdu_raw(self, pdu): """see LinkBase.send_apdu_raw""" # print("PDU: " + pdu) apdu = h2i(pdu) data, sw1, sw2 = self._con.transmit(apdu) # print("DATA: " + data) sw = [sw1, sw2] # Return value # print("DATA: " + i2h(data)," SW: " + i2h(sw)) return i2h(data), i2h(sw)
def send_apdu_raw(self, pdu): """see LinkBase.send_apdu_raw""" apdu = h2i(pdu) data, sw1, sw2 = self._con.transmit(apdu) sw = [sw1, sw2] # Return value return i2h(data), i2h(sw)
def send_apdu_constr(self, cla, ins, p1, p2, cmd_constr, cmd_data, resp_constr): """Build and sends an APDU using a 'construct' definition; parses response. Args: cla : string (in hex) ISO 7816 class byte ins : string (in hex) ISO 7816 instruction byte p1 : string (in hex) ISO 7116 Parameter 1 byte p2 : string (in hex) ISO 7116 Parameter 2 byte cmd_cosntr : defining how to generate binary APDU command data cmd_data : command data passed to cmd_constr resp_cosntr : defining how to decode binary APDU response data Returns: Tuple of (decoded_data, sw) """ cmd = cmd_constr.build(cmd_data) if cmd_data else '' p3 = i2h([len(cmd)]) pdu = ''.join([cla, ins, p1, p2, p3, b2h(cmd)]) (data, sw) = self.send_apdu(pdu) if data: # filter the resulting dict to avoid '_io' members inside rsp = filter_dict(resp_constr.parse(h2b(data))) else: rsp = None return (rsp, sw)
def send_apdu_raw(self, pdu): """see LinkBase.send_apdu_raw""" if self._verbose is True: print("C-APDU : " + pdu) apdu = h2i(pdu) data, sw1, sw2 = self._con.transmit(apdu) sw = [sw1, sw2] if self._verbose is True: print("R-APDU + SW : " + i2h(data) + i2h(sw)) # Return value return i2h(data), i2h(sw)
def send_apdu_raw(self, pdu): """see LinkBase.send_apdu_raw""" str_pdu = str.upper(pdu) #print "CMD\t" + ' '.join([str_pdu[i:i+2] for i in range(0, len(str_pdu), 2)]) + ' \\' apdu = h2i(pdu) data, sw1, sw2 = self._con.transmit(apdu) sw = [sw1, sw2] #print "RESP: " + str.upper(i2h(sw)) + " " + str.upper(i2h(data)) #print "\t" + '(' + str.upper(i2h([sw1])) + ' ' + str.upper(i2h([sw2])) + ')' # Return value return i2h(data), i2h(sw)
def send_apdu_raw(self, pdu): """see LinkBase.send_apdu_raw""" apdu = h2i(pdu) # print("apdu >>> ") print(''.join(format(apdu, '02x') for apdu in apdu)) data, sw1, sw2 = self._con.transmit(apdu) #print ("response code: " + "sw1: " +str(hex(sw1)) + " sw2: " + str(hex(sw2))) print (''.join(format(data, '02x') for data in data)) # print("DATA: ") # print(hex(data)) # print("sw1: ") # print(hex(sw1)) # print("sw2: ") # print(hex(sw2)) sw = [sw1, sw2] # Return value return i2h(data), i2h(sw)