mirror of
https://gitea.osmocom.org/sim-card/pysim.git
synced 2026-03-30 06:26:53 +03:00
cards: use python style commends to describe methods
Change-Id: Iae862d8f0a191c7015a94f9516ef5804265f7a82
This commit is contained in:
@@ -74,9 +74,7 @@ class SimCard(object):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
def verify_adm(self, key):
|
def verify_adm(self, key):
|
||||||
'''
|
"""Authenticate with ADM key"""
|
||||||
Authenticate with ADM key
|
|
||||||
'''
|
|
||||||
(res, sw) = self._scc.verify_chv(self._adm_chv_num, key)
|
(res, sw) = self._scc.verify_chv(self._adm_chv_num, key)
|
||||||
return sw
|
return sw
|
||||||
|
|
||||||
@@ -135,10 +133,7 @@ class SimCard(object):
|
|||||||
return (None, sw)
|
return (None, sw)
|
||||||
|
|
||||||
def update_oplmn_act(self, mcc, mnc, access_tech='FFFF'):
|
def update_oplmn_act(self, mcc, mnc, access_tech='FFFF'):
|
||||||
"""
|
"""get size and write EF.OPLMNwAcT, See note in update_hplmn_act()"""
|
||||||
See note in update_hplmn_act()
|
|
||||||
"""
|
|
||||||
# get size and write EF.OPLMNwAcT
|
|
||||||
data = self._scc.read_binary(EF['OPLMNwAcT'], length=None, offset=0)
|
data = self._scc.read_binary(EF['OPLMNwAcT'], length=None, offset=0)
|
||||||
size = len(data[0]) // 2
|
size = len(data[0]) // 2
|
||||||
hplmn = enc_plmn(mcc, mnc)
|
hplmn = enc_plmn(mcc, mnc)
|
||||||
@@ -154,10 +149,7 @@ class SimCard(object):
|
|||||||
return (None, sw)
|
return (None, sw)
|
||||||
|
|
||||||
def update_plmn_act(self, mcc, mnc, access_tech='FFFF'):
|
def update_plmn_act(self, mcc, mnc, access_tech='FFFF'):
|
||||||
"""
|
"""get size and write EF.PLMNwAcT, See note in update_hplmn_act()"""
|
||||||
See note in update_hplmn_act()
|
|
||||||
"""
|
|
||||||
# get size and write EF.PLMNwAcT
|
|
||||||
data = self._scc.read_binary(EF['PLMNwAcT'], length=None, offset=0)
|
data = self._scc.read_binary(EF['PLMNwAcT'], length=None, offset=0)
|
||||||
size = len(data[0]) // 2
|
size = len(data[0]) // 2
|
||||||
hplmn = enc_plmn(mcc, mnc)
|
hplmn = enc_plmn(mcc, mnc)
|
||||||
@@ -265,8 +257,8 @@ class SimCard(object):
|
|||||||
else:
|
else:
|
||||||
return (None, sw)
|
return (None, sw)
|
||||||
|
|
||||||
# Fetch all the AIDs present on UICC
|
|
||||||
def read_aids(self):
|
def read_aids(self):
|
||||||
|
"""Fetch all the AIDs present on UICC"""
|
||||||
self._aids = []
|
self._aids = []
|
||||||
try:
|
try:
|
||||||
# Find out how many records the EF.DIR has
|
# Find out how many records the EF.DIR has
|
||||||
@@ -282,8 +274,8 @@ class SimCard(object):
|
|||||||
self._aids = []
|
self._aids = []
|
||||||
return self._aids
|
return self._aids
|
||||||
|
|
||||||
# Select ADF.U/ISIM in the Card using its full AID
|
|
||||||
def select_adf_by_aid(self, adf="usim"):
|
def select_adf_by_aid(self, adf="usim"):
|
||||||
|
"""Select ADF.U/ISIM in the Card using its full AID"""
|
||||||
# Find full AID by partial AID:
|
# Find full AID by partial AID:
|
||||||
if is_hex(adf):
|
if is_hex(adf):
|
||||||
for aid in self._aids:
|
for aid in self._aids:
|
||||||
@@ -300,13 +292,13 @@ class SimCard(object):
|
|||||||
return self._scc.select_adf(aid)
|
return self._scc.select_adf(aid)
|
||||||
return (None, None)
|
return (None, None)
|
||||||
|
|
||||||
# Erase the contents of a file
|
|
||||||
def erase_binary(self, ef):
|
def erase_binary(self, ef):
|
||||||
|
"""Erase the contents of a file"""
|
||||||
len = self._scc.binary_size(ef)
|
len = self._scc.binary_size(ef)
|
||||||
self._scc.update_binary(ef, "ff" * len, offset=0, verify=True)
|
self._scc.update_binary(ef, "ff" * len, offset=0, verify=True)
|
||||||
|
|
||||||
# Erase the contents of a single record
|
|
||||||
def erase_record(self, ef, rec_no):
|
def erase_record(self, ef, rec_no):
|
||||||
|
"""Erase the contents of a single record"""
|
||||||
len = self._scc.record_size(ef)
|
len = self._scc.record_size(ef)
|
||||||
self._scc.update_record(ef, rec_no, "ff" * len, force_len=False, verify=True)
|
self._scc.update_record(ef, rec_no, "ff" * len, force_len=False, verify=True)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user