mirror of https://gerrit.osmocom.org/pysim
fix various typos all over the code
Change-Id: Ic8392a951bf94f67b51e35bed95d0e856f7a9250
This commit is contained in:
parent
790b2709bd
commit
c9cdce3e02
|
@ -33,7 +33,7 @@ Transport base class
|
|||
calypso / OsmocomBB transport
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
This allows the use of the SIM slot of an an OsmocomBB compatible phone with the TI Calypso chipset,
|
||||
This allows the use of the SIM slot of an OsmocomBB compatible phone with the TI Calypso chipset,
|
||||
using the L1CTL interface to talk to the layer1.bin firmware on the phone.
|
||||
|
||||
.. automodule:: pySim.transport.calypso
|
||||
|
@ -67,7 +67,7 @@ Serial/UART transport
|
|||
This transport implements interfacing smart cards via
|
||||
very simplistic UART readers. These readers basically
|
||||
wire together the Rx+Tx pins of a RS232 UART, provide
|
||||
a fixed crystal oscilator for clock, and operate the UART
|
||||
a fixed crystal oscillator for clock, and operate the UART
|
||||
at 9600 bps. These readers are sometimes called `Phoenix`.
|
||||
|
||||
.. automodule:: pySim.transport.serial
|
||||
|
|
|
@ -79,7 +79,7 @@ class PysimApp(cmd2.Cmd):
|
|||
onchange_cb=self._onchange_apdu_trace))
|
||||
|
||||
def poutput_json(self, data, force_no_pretty = False):
|
||||
"""line cmd2.putput() but for a json serializable dict."""
|
||||
"""like cmd2.poutput() but for a JSON serializable dict."""
|
||||
if force_no_pretty or self.json_pretty_print == False:
|
||||
output = json.dumps(data, cls=JsonEncoder)
|
||||
else:
|
||||
|
@ -220,7 +220,7 @@ class PySimCommands(CommandSet):
|
|||
# always restore the currently selected file to the file that
|
||||
# was selected before executing the action() callback.
|
||||
if df_before_action != self._cmd.rs.selected_file:
|
||||
raise RuntimeError("inconsistant walk, %s is currently selected but expecting %s to be selected"
|
||||
raise RuntimeError("inconsistent walk, %s is currently selected but expecting %s to be selected"
|
||||
% (str(self._cmd.rs.selected_file), str(df_before_action)))
|
||||
|
||||
def do_tree(self, opts):
|
||||
|
@ -299,9 +299,9 @@ class PySimCommands(CommandSet):
|
|||
self._cmd.poutput("# " + b)
|
||||
|
||||
if context['ERR'] and context['DF_SKIP']:
|
||||
raise RuntimeError("unable to export %i elementry file(s) and %i dedicated file(s)" % (context['ERR'], context['DF_SKIP']))
|
||||
raise RuntimeError("unable to export %i elementary file(s) and %i dedicated file(s)" % (context['ERR'], context['DF_SKIP']))
|
||||
elif context['ERR']:
|
||||
raise RuntimeError("unable to export %i elementry file(s)" % context['ERR'])
|
||||
raise RuntimeError("unable to export %i elementary file(s)" % context['ERR'])
|
||||
elif context['DF_SKIP']:
|
||||
raise RuntimeError("unable to export %i dedicated files(s)" % context['ERR'])
|
||||
|
||||
|
@ -353,7 +353,7 @@ class Iso7816Commands(CommandSet):
|
|||
"""Verify (authenticate) using specified PIN code"""
|
||||
pin = self.get_code(opts.pin_code)
|
||||
(data, sw) = self._cmd.card._scc.verify_chv(opts.pin_nr, h2b(pin))
|
||||
self._cmd.poutput("CHV verfication successful")
|
||||
self._cmd.poutput("CHV verification successful")
|
||||
|
||||
unblock_chv_parser = argparse.ArgumentParser()
|
||||
unblock_chv_parser.add_argument('--pin-nr', type=int, default=1, help='PUK Number, 1=PIN1, 2=PIN2 or custom value (decimal)')
|
||||
|
@ -536,7 +536,7 @@ if __name__ == '__main__':
|
|||
card_key_provider_register(CardKeyProviderCsv(csv_default))
|
||||
|
||||
# If the user supplies an ADM PIN at via commandline args authenticate
|
||||
# immediatley so that the user does not have to use the shell commands
|
||||
# immediately so that the user does not have to use the shell commands
|
||||
pin_adm = sanitize_pin_adm(opts.pin_adm, opts.pin_adm_hex)
|
||||
if pin_adm:
|
||||
try:
|
||||
|
|
|
@ -94,7 +94,7 @@ class Card(object):
|
|||
in ETSI TS 151 011 for the details of the access_tech field coding.
|
||||
Some common values:
|
||||
access_tech = '0080' # Only GSM is selected
|
||||
access_tech = 'FFFF' # All technologues selected, even Reserved for Future Use ones
|
||||
access_tech = 'FFFF' # All technologies selected, even Reserved for Future Use ones
|
||||
"""
|
||||
# get size and write EF.HPLMNwAcT
|
||||
data = self._scc.read_binary(EF['HPLMNwAcT'], length=None, offset=0)
|
||||
|
@ -476,7 +476,7 @@ class _MagicSimBase(Card):
|
|||
each possible provider uses a specific record number in each EF. The
|
||||
indexes used are ( where N is the number of providers supported ) :
|
||||
- [2 .. N+1] for the operator name
|
||||
- [1 .. N] for the programable EFs
|
||||
- [1 .. N] for the programmable EFs
|
||||
|
||||
* 3f00/7f4d/8f0c : Operator Name
|
||||
|
||||
|
@ -618,7 +618,7 @@ class MagicSim(_MagicSimBase):
|
|||
class FakeMagicSim(Card):
|
||||
"""
|
||||
Theses cards have a record based EF 3f00/000c that contains the provider
|
||||
informations. See the program method for its format. The records go from
|
||||
information. See the program method for its format. The records go from
|
||||
1 to N.
|
||||
"""
|
||||
|
||||
|
|
|
@ -53,7 +53,7 @@ class CardFile(object):
|
|||
fid : File Identifier (4 hex digits)
|
||||
sfid : Short File Identifier (2 hex digits, optional)
|
||||
name : Brief name of the file, lik EF_ICCID
|
||||
desc : Descriptoin of the file
|
||||
desc : Description of the file
|
||||
parent : Parent CardFile object within filesystem hierarchy
|
||||
"""
|
||||
if not isinstance(self, CardADF) and fid == None:
|
||||
|
@ -387,7 +387,7 @@ class TransparentEF(CardEF):
|
|||
|
||||
@with_default_category('Transparent EF Commands')
|
||||
class ShellCommands(CommandSet):
|
||||
"""Shell commands specific for Trransparent EFs."""
|
||||
"""Shell commands specific for transparent EFs."""
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
|
||||
|
@ -462,7 +462,7 @@ class TransparentEF(CardEF):
|
|||
fid : File Identifier (4 hex digits)
|
||||
sfid : Short File Identifier (2 hex digits, optional)
|
||||
name : Brief name of the file, lik EF_ICCID
|
||||
desc : Descriptoin of the file
|
||||
desc : Description of the file
|
||||
parent : Parent CardFile object within filesystem hierarchy
|
||||
size : tuple of (minimum_size, recommended_size)
|
||||
"""
|
||||
|
@ -686,7 +686,7 @@ class LinFixedEF(CardEF):
|
|||
fid : File Identifier (4 hex digits)
|
||||
sfid : Short File Identifier (2 hex digits, optional)
|
||||
name : Brief name of the file, lik EF_ICCID
|
||||
desc : Descriptoin of the file
|
||||
desc : Description of the file
|
||||
parent : Parent CardFile object within filesystem hierarchy
|
||||
rec_len : tuple of (minimum_length, recommended_length)
|
||||
"""
|
||||
|
@ -808,8 +808,8 @@ class TransRecEF(TransparentEF):
|
|||
Args:
|
||||
fid : File Identifier (4 hex digits)
|
||||
sfid : Short File Identifier (2 hex digits, optional)
|
||||
name : Brief name of the file, lik EF_ICCID
|
||||
desc : Descriptoin of the file
|
||||
name : Brief name of the file, like EF_ICCID
|
||||
desc : Description of the file
|
||||
parent : Parent CardFile object within filesystem hierarchy
|
||||
rec_len : Length of the fixed-length records within transparent EF
|
||||
size : tuple of (minimum_size, recommended_size)
|
||||
|
@ -991,7 +991,7 @@ class RuntimeState(object):
|
|||
or the underlying card profile.
|
||||
|
||||
Args:
|
||||
sw : Status word as string of 4 hexd digits
|
||||
sw : Status word as string of 4 hex digits
|
||||
|
||||
Returns:
|
||||
Tuple of two strings
|
||||
|
@ -1026,9 +1026,9 @@ class RuntimeState(object):
|
|||
f = CardDF(fid=fid, sfid=None, name="DF." + str(fid).upper(), desc="dedicated file, manually added at runtime")
|
||||
else:
|
||||
if (select_resp['file_descriptor']['structure'] == 'transparent'):
|
||||
f = TransparentEF(fid=fid, sfid=None, name="EF." + str(fid).upper(), desc="elementry file, manually added at runtime")
|
||||
f = TransparentEF(fid=fid, sfid=None, name="EF." + str(fid).upper(), desc="elementary file, manually added at runtime")
|
||||
else:
|
||||
f = LinFixedEF(fid=fid, sfid=None, name="EF." + str(fid).upper(), desc="elementry file, manually added at runtime")
|
||||
f = LinFixedEF(fid=fid, sfid=None, name="EF." + str(fid).upper(), desc="elementary file, manually added at runtime")
|
||||
|
||||
self.selected_file.add_files([f])
|
||||
self.selected_file = f
|
||||
|
@ -1223,7 +1223,7 @@ class CardApplication(object):
|
|||
"""Interpret a given status word within the application.
|
||||
|
||||
Args:
|
||||
sw : Status word as string of 4 hexd digits
|
||||
sw : Status word as string of 4 hex digits
|
||||
|
||||
Returns:
|
||||
Tuple of two strings
|
||||
|
@ -1231,7 +1231,7 @@ class CardApplication(object):
|
|||
return interpret_sw(self.sw, sw)
|
||||
|
||||
class CardProfile(object):
|
||||
"""A Card Profile describes a card, it's filessystem hierarchy, an [initial] list of
|
||||
"""A Card Profile describes a card, it's filesystem hierarchy, an [initial] list of
|
||||
applications as well as profile-specific SW and shell commands. Every card has
|
||||
one card profile, but there may be multiple applications within that profile."""
|
||||
def __init__(self, name, **kw):
|
||||
|
@ -1265,7 +1265,7 @@ class CardProfile(object):
|
|||
"""Interpret a given status word within the profile.
|
||||
|
||||
Args:
|
||||
sw : Status word as string of 4 hexd digits
|
||||
sw : Status word as string of 4 hex digits
|
||||
|
||||
Returns:
|
||||
Tuple of two strings
|
||||
|
|
|
@ -471,14 +471,14 @@ class EF_ECC(LinFixedEF):
|
|||
|
||||
# TS 31.102 Section 4.2.17
|
||||
class EF_LOCI(TransparentEF):
|
||||
def __init__(self, fid='6f7e', sfid=0x0b, name='EF.LOCI', desc='Locationn information', size={11,11}):
|
||||
def __init__(self, fid='6f7e', sfid=0x0b, name='EF.LOCI', desc='Location information', size={11,11}):
|
||||
super().__init__(fid, sfid=sfid, name=name, desc=desc, size=size)
|
||||
self._construct = Struct('tmsi'/HexAdapter(Bytes(4)), 'lai'/HexAdapter(Bytes(5)), 'rfu'/Int8ub,
|
||||
'lu_status'/Int8ub)
|
||||
|
||||
# TS 31.102 Section 4.2.23
|
||||
class EF_PSLOCI(TransparentEF):
|
||||
def __init__(self, fid='6f73', sfid=0x0c, name='EF.PSLOCI', desc='PS Locationn information', size={14,14}):
|
||||
def __init__(self, fid='6f73', sfid=0x0c, name='EF.PSLOCI', desc='PS Location information', size={14,14}):
|
||||
super().__init__(fid, sfid=sfid, name=name, desc=desc, size=size)
|
||||
self._construct = Struct('ptmsi'/HexAdapter(Bytes(4)), 'ptmsi_sig'/HexAdapter(Bytes(3)),
|
||||
'rai'/HexAdapter(Bytes(6)), 'rau_status'/Int8ub)
|
||||
|
|
|
@ -126,7 +126,7 @@ class EF_PCSCF(LinFixedEF):
|
|||
|
||||
# TS 31.103 Section 4.2.9
|
||||
class EF_GBABP(TransparentEF):
|
||||
def __init__(self, fid='6fd5', sfid=None, name='EF.GBABP', desc='GBA Bootstrappng'):
|
||||
def __init__(self, fid='6fd5', sfid=None, name='EF.GBABP', desc='GBA Bootstrapping'):
|
||||
super().__init__(fid=fid, sfid=sfid, name=name, desc=desc)
|
||||
|
||||
# TS 31.103 Section 4.2.10
|
||||
|
|
|
@ -423,7 +423,7 @@ class EF_EXT(LinFixedEF):
|
|||
# TS 51.011 Section 10.5.16
|
||||
class EF_CMI(LinFixedEF):
|
||||
def __init__(self, fid='6f58', sfid=None, name='EF.CMI', rec_len={2,21},
|
||||
desc='Comparison Method Informatoin'):
|
||||
desc='Comparison Method Information'):
|
||||
super().__init__(fid, sfid=sfid, name=name, desc=desc, rec_len=rec_len)
|
||||
self._construct = Struct('alpha_id'/Bytes(this._.total_len-1), 'comparison_method_id'/Int8ub)
|
||||
|
||||
|
@ -871,7 +871,7 @@ def decode_select_response(resp_hex):
|
|||
ret['file_characteristics'] = b2h(resp_bin[13])
|
||||
ret['num_direct_child_df'] = int(resp_bin[14], 16)
|
||||
ret['num_direct_child_ef'] = int(resp_bin[15], 16)
|
||||
ret['num_chv_unbkock_adm_codes'] = int(resp_bin[16])
|
||||
ret['num_chv_unblock_adm_codes'] = int(resp_bin[16])
|
||||
# CHV / UNBLOCK CHV stats
|
||||
elif file_type in ['working_ef']:
|
||||
file_struct = struct_of_file_map[resp_bin[13]] if resp_bin[13] in struct_of_file_map else resp_bin[13]
|
||||
|
|
|
@ -111,7 +111,7 @@ def enc_imsi(imsi:str):
|
|||
return ei
|
||||
|
||||
def dec_imsi(ef:Hexstr) -> Optional[str]:
|
||||
"""Converts an EF value to the imsi string representation"""
|
||||
"""Converts an EF value to the IMSI string representation"""
|
||||
if len(ef) < 4:
|
||||
return None
|
||||
l = int(ef[0:2], 16) * 2 # Length of the IMSI string
|
||||
|
|
Loading…
Reference in New Issue