def unblock_chv(self, chv_no, code): self.select_file(['3f00', '7f20', '6f38']) fc = rpad(b2h(code.encode()), 16) if chv_no == 1: chv_no = 0 return self._tp.send_apdu_checksw("a02c00" + ('%02x' % chv_no) + "10" + fc)
def program(self, p): # Go to dir self._scc.select_file(['3f00', '7f4d']) # Home PLMN in PLMN_Sel format hplmn = self._e_plmn(p['mcc'], p['mnc']) # Operator name ( 3f00/7f4d/8f0c ) self._scc.update_record( self._files['name'][0], 2, rpad(b2h(p['name']), 32) + ('%02x' % len(p['name'])) + '01') # ICCID/IMSI/Ki/HPLMN ( 3f00/7f4d/8f0d ) v = '' # inline Ki if self._ki_file is None: v += p['ki'] # ICCID v += '3f00' + '2fe2' + '0a' + self._e_iccid(p['iccid']) # IMSI v += '7f20' + '6f07' + '09' + self._e_imsi(p['imsi']) # Ki if self._ki_file: v += self._ki_file + '10' + p['ki'] # PLMN_Sel v += '6f30' + '18' + rpad(hplmn, 36) self._scc.update_record(self._files['b_ef'][0], 1, rpad(v, self._files['b_ef'][1] * 2)) # SMSP ( 3f00/7f4d/8f0e ) # FIXME # Write PLMN_Sel forcefully as well r = self._scc.select_file(['3f00', '7f20', '6f30']) tl = int(r[-1][4:8], 16) hplmn = self._e_plmn(p['mcc'], p['mnc']) self._scc.update_binary('6f30', hplmn + 'ff' * (tl - 3))
def prepare_text(text): tokens = tokenizer.tokenize(text)[:args.seq_len - 2] token_ids = tokenizer.encode(tokens, add_special_tokens=True) token_ids_len = len(token_ids) rspace = args.seq_len - token_ids_len # <= args.seq_len token_ids = rpad(token_ids, rspace, tokenizer.pad_token_id) return ( cuda(torch.tensor(token_ids)).long(), cuda(torch.tensor(token_ids_len)).long(), )
def program(self, p): # Home PLMN r = self._scc.select_file(['3f00', '7f20', '6f30']) tl = int(r[-1][4:8], 16) hplmn = self._e_plmn(p['mcc'], p['mnc']) self._scc.update_binary('6f30', hplmn + 'ff' * (tl - 3)) # Get total number of entries and entry size rec_cnt, rec_len = self._get_infos() # Set first entry entry = ( '81' + # 1b Status: Valid & Active rpad(b2h(p['name'][0:14]), 28) + # 14b Entry Name self._e_iccid(p['iccid']) + # 10b ICCID self._e_imsi(p['imsi']) + # 9b IMSI_len + id_type(9) + IMSI p['ki'] + # 16b Ki lpad(p['smsp'], 80) # 40b SMSP (padded with ff if needed) ) self._scc.update_record('000c', 1, entry)
def _e_iccid(self, iccid): return swap_nibbles(rpad(iccid, 20))
def change_chv(self, chv_no, curr_pin, new_pin): fc = rpad(b2h(curr_pin.encode()), 16) + rpad(b2h(new_pin.encode()), 16) return self._tp.send_apdu_checksw("a02400" + ('%02x' % chv_no) + "10" + fc)
def enable_chv(self, code): self.select_file(['3f00', '7f20', '6f38']) fc = rpad(b2h(code.encode()), 16) return self._tp.send_apdu_checksw("a028000108" + fc)
def disable_chv(self, code): fc = rpad(b2h(code.encode()), 16) return self._tp.send_apdu_checksw('a026000108' + fc)
def verify_chv(self, chv_no, code): self.select_file(['3f00', '7f20']) fc = rpad(b2h(code.encode()), 16) return self._tp.send_apdu_checksw('a02000' + ('%02x' % chv_no) + '08' + fc)