From 7d13845285ccdd2f8a310c19bdbeb685fd1a205e Mon Sep 17 00:00:00 2001 From: Philipp Maier Date: Wed, 16 Aug 2023 11:47:36 +0200 Subject: [PATCH] sim-rest-server: fix REST method info The REST megthd info uses deprecated methods to read the ICCID and the IMSI from the card. However, we can replace those methods by selecting the files we are interested in manually and then reading them. Related: RT#67094 Change-Id: Ib0178823abb18187404249cfed71cfb3123d1d74 --- contrib/sim-rest-server.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/contrib/sim-rest-server.py b/contrib/sim-rest-server.py index 9f311688..83fb377d 100755 --- a/contrib/sim-rest-server.py +++ b/contrib/sim-rest-server.py @@ -27,6 +27,9 @@ from pySim.transport import ApduTracer from pySim.transport.pcsc import PcscSimLink from pySim.commands import SimCardCommands from pySim.cards import UiccCardBase +from pySim.utils import dec_iccid, dec_imsi +from pySim.ts_51_011 import EF_IMSI +from pySim.ts_102_221 import EF_ICCID from pySim.exceptions import * class ApduPrintTracer(ApduTracer): @@ -134,10 +137,14 @@ class SimRestServer: tp, scc, card = connect_to_card(slot) + ef_iccid = EF_ICCID() + (iccid, sw) = card._scc.read_binary(ef_iccid.fid) + card.select_adf_by_aid(adf='usim') - iccid, sw = card.read_iccid() - imsi, sw = card.read_imsi() - res = {"imsi": imsi, "iccid": iccid } + ef_imsi = EF_IMSI() + (imsi, sw) = card._scc.read_binary(ef_imsi.fid) + + res = {"imsi": dec_imsi(imsi), "iccid": dec_iccid(iccid) } tp.disconnect()