コード例 #1
0
ファイル: trans_visa.py プロジェクト: zhangbinhu/CardScript
 def second_gac(self):
     tag8D = self.get_tag(PROCESS_STEP.READ_RECORD, '8D')
     data = tools.assemble_dol(tag8D)
     resp = super().gac(Crypto_Type.TC, data)
     if resp.sw != 0x9000:
         Log.info('send gac1 failed.')
         return
     return resp
コード例 #2
0
ファイル: trans_base.py プロジェクト: zhangbinhu/CardScript
 def do_dda(self,fDDA=False):
     tag9F47 = self.get_tag(PROCESS_STEP.READ_RECORD,'9F47')
     if not tag9F47:
         Log.error('tag9F47: %s',tag9F47)
         Log.error('require tag9F47 failed whereby dda failed')
         return False
     tag9F4B = ''
     ddol = ''
     if fDDA:
         tag9F4B = self.get_tag(PROCESS_STEP.GPO,'9F4B')
         tag9F69 = self.get_tag(PROCESS_STEP.READ_RECORD,'9F69')
         if not tag9F69:
             Log.error('tag9F69: %s',tag9F69)
             Log.error('require tag9F69 failed whereby dda failed')
             return False
         # 这里无需再判断终端数据是否存在,在GPO阶段已经验证过
         tag9F37 = terminal.get_terminal('9F37')
         tag9F02 = terminal.get_terminal('9F02')
         tag5F2A = terminal.get_terminal('5F2A')
         # 这里默认使用ddol代替fDDA的签名数据
         # 签名使用的tag9F36自动包含在了tag9F4B恢复数据中,这里无需重复包含
         ddol = tag9F37 + tag9F02 + tag5F2A + tag9F69 
     else:
         tag9F49 = self.get_tag(PROCESS_STEP.READ_RECORD,'9F49')
         if not tag9F49:
             Log.error('tag9F49: %s',tag9F49)
             Log.error('require tag9F49 failed whereby dda failed')
             return False
         ddol = tools.assemble_dol(tag9F49)
         if not ddol:
             Log.error('tag9F49: %s',tag9F49)
             Log.error('can not get terminal ddol data whereby dda failed')
             return False
         tag9F4B = self.gen_9F4B(ddol)
     if not tag9F4B:
         Log.error('can not get tag9F4B data whereby dda failed')
         return False
     issuer_pub_key = self._get_issuer_pub_key()
     if not issuer_pub_key:
         Log.error('get issuer public key failed where by dda failed.')
         return False
     icc_pub_key = self._get_icc_pub_key(issuer_pub_key)
     if not icc_pub_key:
         Log.error('get icc public key failed where by dda failed.')
         return False
     if not auth.validate_9F4B(icc_pub_key,tag9F47,ddol,tag9F4B):
         Log.error('icc public key: %s',icc_pub_key)
         Log.error('tag9F47: %s',tag9F47)
         Log.error('sig data: %s',ddol)
         Log.error('tag9F4B: %s',tag9F4B)
         Log.error('validate tag9F4B failed whereby dda failed')
         return False
     Log.info('dda authentication sucess.')
     return True
コード例 #3
0
 def gpo(self):
     tag9F38 = self.get_tag(PROCESS_STEP.SELECT, '9F38')
     data = ''
     if tag9F38:
         data = tools.assemble_dol(tag9F38)
     resp = super().gpo(data)
     if resp.sw == 0x9000:
         tools.output_apdu_info(resp)
         self.store_tag_group(PROCESS_STEP.GPO,
                              utils.parse_tlv(resp.response))
         # self.run_case('case_gpo','run_visa',resp)
     return resp
コード例 #4
0
 def second_gac(self):
     tag8D = self.get_tag(PROCESS_STEP.READ_RECORD, '8D')
     data = tools.assemble_dol(tag8D)
     resp = super().gac(Crypto_Type.TC, data)
     if resp.sw != 0x9000:
         Log.info('send gac1 failed.')
         return
     tlvs = utils.parse_tlv(resp.response)
     tools.output_apdu_info(resp)
     self.store_tag_group(PROCESS_STEP.SECOND_GAC,
                          utils.parse_tlv(resp.response))
     return resp
コード例 #5
0
ファイル: trans_visa.py プロジェクト: zhangbinhu/CardScript
 def gpo_VSDC(self):
     tag9F38 = self.get_tag(PROCESS_STEP.SELECT, '9F38')
     data = ''
     if tag9F38:
         data = tools.assemble_dol(tag9F38)
     resp = super().gpo(data)
     if resp.sw == 0x9000:
         tools.output_not_tlv_gpo_info(resp)
         self.store_tag(PROCESS_STEP.GPO, '82', resp.response[4:8])
         self.store_tag(PROCESS_STEP.GPO, '94', resp.response[8:])
         self.run_case('case_gpo', 'run_visa', resp)
     return resp
コード例 #6
0
 def gpo(self):
     tag9F38 = self.get_tag(PROCESS_STEP.SELECT, '9F38')
     pdol = ''
     if tag9F38:
         pdol = tools.assemble_dol(tag9F38)
     resp = super().gpo(pdol)
     if resp.sw == 0x9000:
         tools.output_apdu_info(resp)
         tlvs = utils.parse_tlv(resp.response)
         self.store_tag_group(PROCESS_STEP.GPO, tlvs)
         self.run_case('case_gpo', resp)
     return resp
コード例 #7
0
 def first_gac(self):
     tag8C = self.get_tag(PROCESS_STEP.READ_RECORD, '8C')
     data = tools.assemble_dol(tag8C)
     resp = super().gac(Crypto_Type.ARQC, data)
     if resp.sw != 0x9000:
         Log.info('send gac1 failed.')
         return
     tlvs = utils.parse_tlv(resp.response)
     tools.output_apdu_info(resp)
     self.store_tag_group(PROCESS_STEP.FIRST_GAC,
                          utils.parse_tlv(resp.response))
     self.run_case('case_first_gac', 'run_mc', resp)
     return resp
コード例 #8
0
ファイル: trans_visa.py プロジェクト: zhangbinhu/CardScript
 def first_gac(self):
     tag8C = self.get_tag(PROCESS_STEP.READ_RECORD, '8C')
     data = tools.assemble_dol(tag8C)
     resp = super().gac(Crypto_Type.ARQC, data)
     if resp.sw != 0x9000:
         Log.info('send gac1 failed.')
         return
     tlvs = utils.parse_tlv(resp.response)
     if len(tlvs) != 1 and tlvs[0].tag != '80':
         Log.info('gac1 response data error')
     data = tlvs[0].value
     self.store_tag(PROCESS_STEP.FIRST_GAC, '9F27', data[0:2])
     self.store_tag(PROCESS_STEP.FIRST_GAC, '9F36', data[2:6])
     self.store_tag(PROCESS_STEP.FIRST_GAC, '9F26', data[6:22])
     self.store_tag(PROCESS_STEP.FIRST_GAC, '9F10', data[22:])
     return resp