aboutsummaryrefslogtreecommitdiffstats
path: root/pySim
diff options
context:
space:
mode:
authorHarald Welte <laforge@osmocom.org>2024-02-04 23:01:48 +0100
committerHarald Welte <laforge@osmocom.org>2024-02-05 09:53:26 +0100
commite6e74229c9bba2f6eebe118a2f4626e9f4110dd1 (patch)
tree4d63982dc53095abda3ab14d7eff981c9cff9a87 /pySim
parent9ef65099d26008c631d33dd4dd217e0808052962 (diff)
pylint: pySim/esim/bsp.py
pySim/esim/bsp.py:1:0: C0114: Missing module docstring (missing-module-docstring) pySim/esim/bsp.py:28:0: C0413: Import "import abc" should be placed at the top of the module (wrong-import-position) pySim/esim/bsp.py:29:0: C0413: Import "from typing import List" should be placed at the top of the module (wrong-import-position) pySim/esim/bsp.py:30:0: C0413: Import "import logging" should be placed at the top of the module (wrong-import-position) pySim/esim/bsp.py:33:0: C0413: Import "from cryptography.hazmat.primitives import hashes" should be placed at the top of the module (wrong-import-position) pySim/esim/bsp.py:34:0: C0413: Import "from cryptography.hazmat.primitives.kdf.x963kdf import X963KDF" should be placed at the top of the module (wrong-import-position) pySim/esim/bsp.py:36:0: C0413: Import "from Cryptodome.Cipher import AES" should be placed at the top of the module (wrong-import-position) pySim/esim/bsp.py:37:0: C0413: Import "from Cryptodome.Hash import CMAC" should be placed at the top of the module (wrong-import-position) pySim/esim/bsp.py:39:0: C0413: Import "from pySim.utils import bertlv_encode_len, bertlv_parse_one, b2h" should be placed at the top of the module (wrong-import-position) pySim/esim/bsp.py:48:55: W0613: Unused argument 'padding' (unused-argument) pySim/esim/bsp.py:55:45: W0613: Unused argument 'multiple' (unused-argument) pySim/esim/bsp.py:84:8: W0107: Unnecessary pass statement (unnecessary-pass) pySim/esim/bsp.py:89:8: W0107: Unnecessary pass statement (unnecessary-pass) pySim/esim/bsp.py:94:8: W0107: Unnecessary pass statement (unnecessary-pass) pySim/esim/bsp.py:169:8: W0107: Unnecessary pass statement (unnecessary-pass) pySim/esim/bsp.py:292:8: W0612: Unused variable 'tdict' (unused-variable) pySim/esim/bsp.py:292:15: W0612: Unused variable 'l' (unused-variable) pySim/esim/bsp.py:292:23: W0612: Unused variable 'remain' (unused-variable) Change-Id: I64bd634606c375e767676a4b5ba7c2cc042350c2
Diffstat (limited to 'pySim')
-rw-r--r--pySim/esim/bsp.py13
1 files changed, 5 insertions, 8 deletions
diff --git a/pySim/esim/bsp.py b/pySim/esim/bsp.py
index cf2104a..2afbd46 100644
--- a/pySim/esim/bsp.py
+++ b/pySim/esim/bsp.py
@@ -23,7 +23,6 @@
# SGP.22 v3.0 Section 2.5.3:
# That block of data is split into segments of a maximum size of 1020 bytes (including the tag, length field and MAC).
-MAX_SEGMENT_SIZE = 1020
import abc
from typing import List
@@ -42,6 +41,8 @@ from pySim.utils import bertlv_encode_len, bertlv_parse_one, b2h
logger = logging.getLogger(__name__)
logger.addHandler(logging.NullHandler())
+MAX_SEGMENT_SIZE = 1020
+
class BspAlgo(abc.ABC):
blocksize: int
@@ -50,11 +51,11 @@ class BspAlgo(abc.ABC):
if in_len % multiple == 0:
return b''
pad_cnt = multiple - (in_len % multiple)
- return b'\x00' * pad_cnt
+ return bytes([padding]) * pad_cnt
def _pad_to_multiple(self, indat: bytes, multiple: int, padding: int = 0) -> bytes:
"""Pad the input data to multiples of 'multiple'."""
- return indat + self._get_padding(len(indat), self.blocksize, padding)
+ return indat + self._get_padding(len(indat), multiple, padding)
def __str__(self):
return self.__class__.__name__
@@ -81,17 +82,14 @@ class BspAlgoCrypt(BspAlgo, abc.ABC):
@abc.abstractmethod
def _unpad(self, padded: bytes) -> bytes:
"""Remove the padding from padded data."""
- pass
@abc.abstractmethod
def _encrypt(self, data:bytes) -> bytes:
"""Actual implementation, to be implemented by derived class."""
- pass
@abc.abstractmethod
def _decrypt(self, data:bytes) -> bytes:
"""Actual implementation, to be implemented by derived class."""
- pass
class BspAlgoCryptAES128(BspAlgoCrypt):
name = 'AES-CBC-128'
@@ -166,7 +164,6 @@ class BspAlgoMac(BspAlgo, abc.ABC):
@abc.abstractmethod
def _auth(self, temp_data: bytes) -> bytes:
"""To be implemented by algorithm specific derived class."""
- pass
class BspAlgoMacAES128(BspAlgoMac):
name = 'AES-CMAC-128'
@@ -289,7 +286,7 @@ class BspInstance:
def demac_only_one(self, ciphertext: bytes) -> bytes:
payload = self.m_algo.verify(ciphertext)
- tdict, l, val, remain = bertlv_parse_one(payload)
+ _tdict, _l, val, _remain = bertlv_parse_one(payload)
return val
def demac_only(self, ciphertext_list: List[bytes]) -> bytes: