mirror of
https://gitea.osmocom.org/sim-card/pysim.git
synced 2026-03-31 01:13:17 +03:00
[cosmetic] esim: Fix various typos in comments/messages/docs
Change-Id: I806c7a37951e72027ab9346169a3f8fe241f2c46
This commit is contained in:
@@ -225,7 +225,7 @@ class BspInstance:
|
|||||||
return cls(s_enc, s_mac, initial_mcv)
|
return cls(s_enc, s_mac, initial_mcv)
|
||||||
|
|
||||||
def encrypt_and_mac_one(self, tag: int, plaintext:bytes) -> bytes:
|
def encrypt_and_mac_one(self, tag: int, plaintext:bytes) -> bytes:
|
||||||
"""Encrypt + MAC a single plaintext TLV. Returns the protected ciphertex."""
|
"""Encrypt + MAC a single plaintext TLV. Returns the protected ciphertext."""
|
||||||
assert tag <= 255
|
assert tag <= 255
|
||||||
assert len(plaintext) <= self.max_payload_size
|
assert len(plaintext) <= self.max_payload_size
|
||||||
logger.debug("encrypt_and_mac_one(tag=0x%x, plaintext=%s)", tag, b2h(plaintext))
|
logger.debug("encrypt_and_mac_one(tag=0x%x, plaintext=%s)", tag, b2h(plaintext))
|
||||||
@@ -250,11 +250,11 @@ class BspInstance:
|
|||||||
return result
|
return result
|
||||||
|
|
||||||
def mac_only_one(self, tag: int, plaintext: bytes) -> bytes:
|
def mac_only_one(self, tag: int, plaintext: bytes) -> bytes:
|
||||||
"""MAC a single plaintext TLV. Returns the protected ciphertex."""
|
"""MAC a single plaintext TLV. Returns the protected ciphertext."""
|
||||||
assert tag <= 255
|
assert tag <= 255
|
||||||
assert len(plaintext) < self.max_payload_size
|
assert len(plaintext) < self.max_payload_size
|
||||||
maced = self.m_algo.auth(tag, plaintext)
|
maced = self.m_algo.auth(tag, plaintext)
|
||||||
# The data block counter for ICV caluclation is incremented also for each segment with C-MAC only.
|
# The data block counter for ICV calculation is incremented also for each segment with C-MAC only.
|
||||||
self.c_algo.block_nr += 1
|
self.c_algo.block_nr += 1
|
||||||
return maced
|
return maced
|
||||||
|
|
||||||
@@ -288,7 +288,7 @@ class BspInstance:
|
|||||||
def demac_only_one(self, ciphertext: bytes) -> bytes:
|
def demac_only_one(self, ciphertext: bytes) -> bytes:
|
||||||
payload = self.m_algo.verify(ciphertext)
|
payload = self.m_algo.verify(ciphertext)
|
||||||
_tdict, _l, val, _remain = bertlv_parse_one(payload)
|
_tdict, _l, val, _remain = bertlv_parse_one(payload)
|
||||||
# The data block counter for ICV caluclation is incremented also for each segment with C-MAC only.
|
# The data block counter for ICV calculation is incremented also for each segment with C-MAC only.
|
||||||
self.c_algo.block_nr += 1
|
self.c_algo.block_nr += 1
|
||||||
return val
|
return val
|
||||||
|
|
||||||
|
|||||||
@@ -26,15 +26,15 @@ logger = logging.getLogger(__name__)
|
|||||||
logger.setLevel(logging.DEBUG)
|
logger.setLevel(logging.DEBUG)
|
||||||
|
|
||||||
class ApiParam(abc.ABC):
|
class ApiParam(abc.ABC):
|
||||||
"""A class reprsenting a single parameter in the API."""
|
"""A class representing a single parameter in the API."""
|
||||||
@classmethod
|
@classmethod
|
||||||
def verify_decoded(cls, data):
|
def verify_decoded(cls, data):
|
||||||
"""Verify the decoded reprsentation of a value. Should raise an exception if somthing is odd."""
|
"""Verify the decoded representation of a value. Should raise an exception if something is odd."""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def verify_encoded(cls, data):
|
def verify_encoded(cls, data):
|
||||||
"""Verify the encoded reprsentation of a value. Should raise an exception if somthing is odd."""
|
"""Verify the encoded representation of a value. Should raise an exception if something is odd."""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ class Iccid(ConfigurableParameter):
|
|||||||
If the string of digits is only 18 digits long, a Luhn check digit will be added."""
|
If the string of digits is only 18 digits long, a Luhn check digit will be added."""
|
||||||
|
|
||||||
def validate(self):
|
def validate(self):
|
||||||
# convert to string as it migt be an integer
|
# convert to string as it might be an integer
|
||||||
iccid_str = str(self.input_value)
|
iccid_str = str(self.input_value)
|
||||||
if len(iccid_str) < 18 or len(iccid_str) > 20:
|
if len(iccid_str) < 18 or len(iccid_str) > 20:
|
||||||
raise ValueError('ICCID must be 18, 19 or 20 digits long')
|
raise ValueError('ICCID must be 18, 19 or 20 digits long')
|
||||||
@@ -86,7 +86,7 @@ class Imsi(ConfigurableParameter):
|
|||||||
the last digit of the IMSI."""
|
the last digit of the IMSI."""
|
||||||
|
|
||||||
def validate(self):
|
def validate(self):
|
||||||
# convert to string as it migt be an integer
|
# convert to string as it might be an integer
|
||||||
imsi_str = str(self.input_value)
|
imsi_str = str(self.input_value)
|
||||||
if len(imsi_str) < 6 or len(imsi_str) > 15:
|
if len(imsi_str) < 6 or len(imsi_str) > 15:
|
||||||
raise ValueError('IMSI must be 6..15 digits long')
|
raise ValueError('IMSI must be 6..15 digits long')
|
||||||
@@ -300,7 +300,7 @@ class Adm2(Pin, keyReference=0x0B):
|
|||||||
|
|
||||||
|
|
||||||
class AlgoConfig(ConfigurableParameter, metaclass=ClassVarMeta):
|
class AlgoConfig(ConfigurableParameter, metaclass=ClassVarMeta):
|
||||||
"""Configurable Algorithm parameter. bytes."""
|
"""Configurable Algorithm parameter."""
|
||||||
key = None
|
key = None
|
||||||
def validate(self):
|
def validate(self):
|
||||||
if not isinstance(self.input_value, (io.BytesIO, bytes, bytearray)):
|
if not isinstance(self.input_value, (io.BytesIO, bytes, bytearray)):
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ def check_signed(signed: x509.Certificate, signer: x509.Certificate) -> bool:
|
|||||||
"""Verify if 'signed' certificate was signed using 'signer'."""
|
"""Verify if 'signed' certificate was signed using 'signer'."""
|
||||||
# this code only works for ECDSA, but this is all we need for GSMA eSIM
|
# this code only works for ECDSA, but this is all we need for GSMA eSIM
|
||||||
pkey = signer.public_key()
|
pkey = signer.public_key()
|
||||||
# this 'signed.signature_algorithm_parameters' below requires cryptopgraphy 41.0.0 :(
|
# this 'signed.signature_algorithm_parameters' below requires cryptography 41.0.0 :(
|
||||||
pkey.verify(signed.signature, signed.tbs_certificate_bytes, signed.signature_algorithm_parameters)
|
pkey.verify(signed.signature, signed.tbs_certificate_bytes, signed.signature_algorithm_parameters)
|
||||||
|
|
||||||
def cert_get_subject_key_id(cert: x509.Certificate) -> bytes:
|
def cert_get_subject_key_id(cert: x509.Certificate) -> bytes:
|
||||||
@@ -189,7 +189,7 @@ class CertAndPrivkey:
|
|||||||
def ecdsa_sign(self, plaintext: bytes) -> bytes:
|
def ecdsa_sign(self, plaintext: bytes) -> bytes:
|
||||||
"""Sign some input-data using an ECDSA signature compliant with SGP.22,
|
"""Sign some input-data using an ECDSA signature compliant with SGP.22,
|
||||||
which internally refers to Global Platform 2.2 Annex E, which in turn points
|
which internally refers to Global Platform 2.2 Annex E, which in turn points
|
||||||
to BSI TS-03111 which states "concatengated raw R + S values". """
|
to BSI TS-03111 which states "concatenated raw R + S values". """
|
||||||
sig = self.priv_key.sign(plaintext, ec.ECDSA(hashes.SHA256()))
|
sig = self.priv_key.sign(plaintext, ec.ECDSA(hashes.SHA256()))
|
||||||
# convert from DER format to BSI TR-03111; first get long integers; then convert those to bytes
|
# convert from DER format to BSI TR-03111; first get long integers; then convert those to bytes
|
||||||
return ecdsa_dss_to_tr03111(sig)
|
return ecdsa_dss_to_tr03111(sig)
|
||||||
|
|||||||
Reference in New Issue
Block a user