aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Welte <laforge@osmocom.org>2021-02-01 18:02:04 +0100
committerHarald Welte <laforge@osmocom.org>2021-02-01 18:02:04 +0100
commitc2124d0988d299fffb94bbe10369da77da242c33 (patch)
tree337feb5c867ca17d137f66cf96ac4df537b4ffaf
parent9a595c95cb22e80e1c298e7b8d0ef466b4128893 (diff)
fixup wip
-rw-r--r--pySim/filesystem.py17
-rw-r--r--pySim/ts_102_221.py3
2 files changed, 9 insertions, 11 deletions
diff --git a/pySim/filesystem.py b/pySim/filesystem.py
index 1d5a808..9b9480a 100644
--- a/pySim/filesystem.py
+++ b/pySim/filesystem.py
@@ -30,7 +30,6 @@ import json
import cmd2
from cmd2 import CommandSet, with_default_category, with_argparser
import argparse
-import codecs
from pySim.utils import sw_match, h2b, b2h
from pySim.exceptions import *
@@ -329,7 +328,7 @@ class TransparentEF(CardEF):
method = getattr(self, '_decode_hex', None)
if callable(method):
return method(raw_hex_data)
- raw_bin_data = codecs.decode(raw_hex_data, 'hex')
+ raw_bin_data = h2b(raw_hex_data)
method = getattr(self, '_decode_bin', None)
if callable(method):
return method(raw_bin_data)
@@ -353,7 +352,7 @@ class TransparentEF(CardEF):
method = getattr(self, '_encode_bin', None)
if callable(method):
raw_bin_data = method(abstract_data)
- return codecs.decode(raw_bin_data, 'hex')
+ return b2h(raw_bin_data)
raise NotImplementedError
@@ -409,7 +408,7 @@ class LinFixedEF(CardEF):
method = getattr(self, '_decode_record_hex', None)
if callable(method):
return method(raw_hex_data)
- raw_bin_data = codecs.decode(raw_hex_data, 'hex')
+ raw_bin_data = h2b(raw_hex_data)
method = getattr(self, '_decode_record_bin', None)
if callable(method):
return method(raw_bin_data)
@@ -420,7 +419,7 @@ class LinFixedEF(CardEF):
method = getattr(self, '_decode_record_bin', None)
if callable(method):
return method(raw_bin_data)
- raw_hex_data = codecs.encode(raw_bin_data, 'hex')
+ raw_hex_data = b2h(raw_bin_data)
method = getattr(self, '_decode_record_hex', None)
if callable(method):
return method(raw_hex_data)
@@ -434,7 +433,7 @@ class LinFixedEF(CardEF):
method = getattr(self, '_encode_record_bin', None)
if callable(method):
raw_bin_data = method(abstract_data)
- return codecs.decode(raw_bin_data, 'hex')
+ return b2h(raww_bin_data)
raise NotImplementedError
def encode_record_bin(self, abstract_data):
@@ -472,7 +471,7 @@ class TransRecEF(TransparentEF):
return method(raw_hex_data)
method = getattr(self, '_decode_record_bin', None)
if callable(method):
- raw_bin_data = codecs.decode(raw_hex_data, 'hex')
+ raw_bin_data = h2b(raw_hex_data)
return method(raw_bin_data)
return {'raw': raw_hex_data}
@@ -481,7 +480,7 @@ class TransRecEF(TransparentEF):
method = getattr(self, '_decode_record_bin', None)
if callable(method):
return method(raw_bin_data)
- raw_hex_data = codecs.encode(raw_bin_data, 'hex')
+ raw_hex_data = b2h(raw_bin_data)
method = getattr(self, '_decode_record_hex', None)
if callable(method):
return method(raw_hex_data)
@@ -513,7 +512,7 @@ class TransRecEF(TransparentEF):
def _encode_bin(self, abstract_data):
chunks = [self.encode_record_bin(x) for x in abstract_data]
-# FIXME: pad to file size
+ # FIXME: pad to file size
return b''.join(chunks)
diff --git a/pySim/ts_102_221.py b/pySim/ts_102_221.py
index b93c187..416224c 100644
--- a/pySim/ts_102_221.py
+++ b/pySim/ts_102_221.py
@@ -22,7 +22,6 @@ from struct import pack, unpack
from pySim.utils import *
from pySim.filesystem import *
-import codecs
FCP_TLV_MAP = {
'82': 'file_descriptor',
@@ -56,7 +55,7 @@ FCP_Proprietary_TLV_MAP = {
# ETSI TS 102 221 11.1.1.4.3
def interpret_file_descriptor(in_hex):
- in_bin = codecs.decode(in_hex, 'hex')
+ in_bin = h2b(in_hex)
out = {}
ft_dict = {
0: 'working_ef',