示例#1
0
 def lock_app(self):
     tag9F36 = self.get_tag('9F36')
     tag9F26 = self.get_tag(PROCESS_STEP.FIRST_GAC, '9F26')
     key_input = '000000000000' + tag9F36 + '000000000000' + algorithm.xor(
         tag9F36, 'FFFF')
     mac_input = '841E000008' + tag9F36 + tag9F26
     key_mac = algorithm.xor(key_input, self.session_key_mac)
     mac = algorithm.des3_mac(key_mac, mac_input)
     apdu.lock_app(mac)
示例#2
0
 def put_data(self, tag, value):
     tag9F36 = self.get_tag('9F36')
     tag9F26 = self.get_tag(PROCESS_STEP.FIRST_GAC, '9F26')
     key_input = '000000000000' + tag9F36 + '000000000000' + algorithm.xor(
         tag9F36, 'FFFF')
     if len(tag) == 2:
         tag = '00' + tag
     data_len = utils.int_to_hex_str(len(value) // 2 + 8)
     mac_input = '04DA' + tag + data_len + tag9F36 + tag9F26 + value
     key_mac = algorithm.xor(key_input, self.key_mac)
     mac = algorithm.des3_mac(key_mac, mac_input)
     apdu.put_data(tag, value, mac)
示例#3
0
def _gen_session_key(key, left_div_data, right_div_data):
    left_key = algorithm.des3_encrypt(key, left_div_data)
    tmp = algorithm.xor(left_key, right_div_data)
    right_key = algorithm.des3_encrypt(key, tmp)
    return left_key + right_key