laforge has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/34154 )
Change subject: sim-rest-server: fix REST method info ......................................................................
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 --- M contrib/sim-rest-server.py 1 file changed, 24 insertions(+), 3 deletions(-)
Approvals: osmith: Looks good to me, but someone else must approve Jenkins Builder: Verified laforge: Looks good to me, approved
diff --git a/contrib/sim-rest-server.py b/contrib/sim-rest-server.py index 9f31168..83fb377 100755 --- a/contrib/sim-rest-server.py +++ b/contrib/sim-rest-server.py @@ -27,6 +27,9 @@ 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 @@
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()