Change in pysim[master]: cards: don't use pyTLV

dexter gerrit-no-reply at lists.osmocom.org
Tue Mar 23 15:51:36 UTC 2021


dexter has uploaded this change for review. ( https://gerrit.osmocom.org/c/pysim/+/23475 )


Change subject: cards: don't use pyTLV
......................................................................

cards: don't use pyTLV

To generate the the ims-hdomain, impi and impu TLV string it is not
necessary to use pyTLV, a simple format string works just as well
but without creating a dependency pyTLV.

Change-Id: I17009223f55a9efadfde419c5514702496072cb9
Related: OS#4963
---
M pySim/cards.py
1 file changed, 3 insertions(+), 7 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/75/23475/1

diff --git a/pySim/cards.py b/pySim/cards.py
index c640591..4d02ac6 100644
--- a/pySim/cards.py
+++ b/pySim/cards.py
@@ -27,7 +27,6 @@
 from pySim.ts_31_103 import EF_ISIM_ADF_map
 from pySim.utils import *
 from smartcard.util import toBytes
-from pytlv.TLV import *
 
 class Card(object):
 
@@ -367,8 +366,7 @@
 			hex_str = s2h('ims.' + plmn_str + '.3gppnetwork.org')
 
 		# Build TLV
-		tlv = TLV(['80'])
-		content = tlv.build({'80': hex_str})
+		content = ("80%02x%s" % (len(hex_str)//2, hex_str)).upper()
 
 		bin_size_bytes = self._scc.binary_size(EF_ISIM_ADF_map['DOMAIN'])
 		data, sw = self._scc.update_binary(EF_ISIM_ADF_map['DOMAIN'], rpad(content, bin_size_bytes*2))
@@ -389,8 +387,7 @@
 		if impi:
 			hex_str = s2h(impi)
 		# Build TLV
-		tlv = TLV(['80'])
-		content = tlv.build({'80': hex_str})
+		content = ("80%02x%s" % (len(hex_str)//2, hex_str)).upper()
 
 		bin_size_bytes = self._scc.binary_size(EF_ISIM_ADF_map['IMPI'])
 		data, sw = self._scc.update_binary(EF_ISIM_ADF_map['IMPI'], rpad(content, bin_size_bytes*2))
@@ -415,8 +412,7 @@
 		if impu:
 			hex_str = s2h(impu)
 		# Build TLV
-		tlv = TLV(['80'])
-		content = tlv.build({'80': hex_str})
+		content = ("80%02x%s" % (len(hex_str)//2, hex_str)).upper()
 
 		rec_size_bytes = self._scc.record_size(EF_ISIM_ADF_map['IMPU'])
 		impu_tlv = rpad(content, rec_size_bytes*2)

-- 
To view, visit https://gerrit.osmocom.org/c/pysim/+/23475
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I17009223f55a9efadfde419c5514702496072cb9
Gerrit-Change-Number: 23475
Gerrit-PatchSet: 1
Gerrit-Owner: dexter <pmaier at sysmocom.de>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210323/dcd4db22/attachment.htm>


More information about the gerrit-log mailing list