laforge has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/34153 )
Change subject: sim-rest-server: use UiccCardBase instead of UsimCard
......................................................................
sim-rest-server: use UiccCardBase instead of UsimCard
The class UsimCard is deprecated and only still used in very old
legacy applications. let's use the more modern UiccCardBase class
instead.
Related: RT#67094
Change-Id: I3676f033833665751c0d953176eafe175b20c14a
---
M contrib/sim-rest-server.py
1 file changed, 16 insertions(+), 2 deletions(-)
Approvals:
laforge: Looks good to me, approved
osmith: Looks good to me, but someone else must approve
Jenkins Builder: Verified
diff --git a/contrib/sim-rest-server.py b/contrib/sim-rest-server.py
index ccf4430..9f31168 100755
--- a/contrib/sim-rest-server.py
+++ b/contrib/sim-rest-server.py
@@ -26,7 +26,7 @@
from pySim.transport import ApduTracer
from pySim.transport.pcsc import PcscSimLink
from pySim.commands import SimCardCommands
-from pySim.cards import UsimCard
+from pySim.cards import UiccCardBase
from pySim.exceptions import *
class ApduPrintTracer(ApduTracer):
@@ -39,7 +39,7 @@
tp.connect()
scc = SimCardCommands(tp)
- card = UsimCard(scc)
+ card = UiccCardBase(scc)
# this should be part of UsimCard, but FairewavesSIM breaks with that :/
scc.cla_byte = "00"
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/34153
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I3676f033833665751c0d953176eafe175b20c14a
Gerrit-Change-Number: 34153
Gerrit-PatchSet: 2
Gerrit-Owner: dexter <pmaier(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: osmith <osmith(a)sysmocom.de>
Gerrit-MessageType: merged
laforge has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/34151 )
Change subject: cards: get rid of method read_iccid
......................................................................
cards: get rid of method read_iccid
The method read_iccid in class CardBase should be put back to
legacy/cards.py. The reason for this is that it falls in the same
category like read_imsi, read_ki, etc. We should not use those old
methods in future programs since we have a more modern infrastructure
(lchan) now.
Also pySim-shell.py is the only caller of this method now. It is not
used in any other place.
Related: RT#67094
Change-Id: Ied3ae6fd107992abcc1b5ea3edb0eb4bdcd2f892
---
M pySim-shell.py
M pySim/cards.py
M pySim/legacy/cards.py
3 files changed, 32 insertions(+), 11 deletions(-)
Approvals:
laforge: Looks good to me, approved
osmith: Looks good to me, but someone else must approve
Jenkins Builder: Verified
diff --git a/pySim-shell.py b/pySim-shell.py
index 2727a5b..af7dbca 100755
--- a/pySim-shell.py
+++ b/pySim-shell.py
@@ -52,7 +52,7 @@
from pySim.transport import init_reader, ApduTracer, argparse_add_reader_args, ProactiveHandler
from pySim.cards import card_detect, SimCardBase, UiccCardBase
from pySim.utils import h2b, b2h, i2h, swap_nibbles, rpad, JsonEncoder, bertlv_parse_one, sw_match
-from pySim.utils import sanitize_pin_adm, tabulate_str_list, boxed_heading_str, Hexstr
+from pySim.utils import sanitize_pin_adm, tabulate_str_list, boxed_heading_str, Hexstr, dec_iccid
from pySim.card_handler import CardHandler, CardHandlerAuto
from pySim.filesystem import CardDF, CardADF, CardModel, CardApplication
@@ -240,7 +240,10 @@
self.register_command_set(Iso7816Commands())
self.register_command_set(Ts102222Commands())
self.register_command_set(PySimCommands())
- self.iccid, sw = self.card.read_iccid()
+
+ self.lchan.select('MF/EF.ICCID', self)
+ self.iccid = dec_iccid(self.lchan.read_binary()[0])
+
self.lchan.select('MF', self)
rc = True
else:
diff --git a/pySim/cards.py b/pySim/cards.py
index c87c488..b1adcf2 100644
--- a/pySim/cards.py
+++ b/pySim/cards.py
@@ -23,7 +23,7 @@
#
from typing import Optional, Dict, Tuple
-from pySim.ts_102_221 import EF_DIR, EF_ICCID
+from pySim.ts_102_221 import EF_DIR
from pySim.ts_51_011 import DF_GSM
from pySim.transport import LinkBase
import abc
@@ -69,14 +69,6 @@
# callers having to do hasattr('read_aids') ahead of every call.
return []
- def read_iccid(self) -> Tuple[Optional[Hexstr], SwHexstr]:
- ef_iccid = EF_ICCID()
- (res, sw) = self._scc.read_binary(ef_iccid.fid)
- if sw == '9000':
- return (dec_iccid(res), sw)
- else:
- return (None, sw)
-
class SimCardBase(CardBase):
"""Here we only add methods for commands specified in TS 51.011, without
diff --git a/pySim/legacy/cards.py b/pySim/legacy/cards.py
index e64b5c3..496ce78 100644
--- a/pySim/legacy/cards.py
+++ b/pySim/legacy/cards.py
@@ -59,6 +59,13 @@
(res, sw) = self._scc.verify_chv(self._adm_chv_num, key)
return sw
+ def read_iccid(self):
+ (res, sw) = self._scc.read_binary(EF['ICCID'])
+ if sw == '9000':
+ return (dec_iccid(res), sw)
+ else:
+ return (None, sw)
+
def update_iccid(self, iccid):
data, sw = self._scc.update_binary(EF['ICCID'], enc_iccid(iccid))
return sw
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/34151
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: Ied3ae6fd107992abcc1b5ea3edb0eb4bdcd2f892
Gerrit-Change-Number: 34151
Gerrit-PatchSet: 2
Gerrit-Owner: dexter <pmaier(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: osmith <osmith(a)sysmocom.de>
Gerrit-MessageType: merged
laforge has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/34152 )
Change subject: sim-rest-server: do not select ADF.USIM in connect_to_card
......................................................................
sim-rest-server: do not select ADF.USIM in connect_to_card
When the function connect_to_card is done, it selects ADF.USIM. This
might be contraproductive in case someone needs to access files on MF
level in one of the REST methods. Instead fo ADF.USIM, let's use MF as a
common ground to start from.
At the moment the only existing REST (info, auth) immediately select
ADF.USIM after calling connect_to_card already, so there are no further
modifications necessary.
Related: RT#67094
Change-Id: I16e7f3c991c83f81989ecc4e4764bb6cc799c01d
---
M contrib/sim-rest-server.py
1 file changed, 22 insertions(+), 1 deletion(-)
Approvals:
laforge: Looks good to me, approved
osmith: Looks good to me, but someone else must approve
Jenkins Builder: Verified
diff --git a/contrib/sim-rest-server.py b/contrib/sim-rest-server.py
index f2ed63e..ccf4430 100755
--- a/contrib/sim-rest-server.py
+++ b/contrib/sim-rest-server.py
@@ -46,7 +46,9 @@
scc.sel_ctrl = "0004"
card.read_aids()
- card.select_adf_by_aid(adf='usim')
+
+ # ensure that MF is selected when we are done.
+ card._scc.select_file('3f00')
return tp, scc, card
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/34152
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I16e7f3c991c83f81989ecc4e4764bb6cc799c01d
Gerrit-Change-Number: 34152
Gerrit-PatchSet: 2
Gerrit-Owner: dexter <pmaier(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: osmith <osmith(a)sysmocom.de>
Gerrit-MessageType: merged
Attention is currently required from: wbokslag.
laforge has posted comments on this change. ( https://gerrit.osmocom.org/c/osmo-tetra/+/34001 )
Change subject: Added functions that prepare for decryption
......................................................................
Patch Set 5: Verified+1
--
To view, visit https://gerrit.osmocom.org/c/osmo-tetra/+/34001
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-tetra
Gerrit-Branch: master
Gerrit-Change-Id: I4e6147f206ad6046f32e08015ec9721b64382ca1
Gerrit-Change-Number: 34001
Gerrit-PatchSet: 5
Gerrit-Owner: wbokslag <w.bokslag(a)midnightblue.nl>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Attention: wbokslag <w.bokslag(a)midnightblue.nl>
Gerrit-Comment-Date: Mon, 21 Aug 2023 18:35:46 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment
Attention is currently required from: wbokslag.
laforge has posted comments on this change. ( https://gerrit.osmocom.org/c/osmo-tetra/+/34001 )
Change subject: Added functions that prepare for decryption
......................................................................
Patch Set 5: Code-Review+2
--
To view, visit https://gerrit.osmocom.org/c/osmo-tetra/+/34001
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-tetra
Gerrit-Branch: master
Gerrit-Change-Id: I4e6147f206ad6046f32e08015ec9721b64382ca1
Gerrit-Change-Number: 34001
Gerrit-PatchSet: 5
Gerrit-Owner: wbokslag <w.bokslag(a)midnightblue.nl>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Attention: wbokslag <w.bokslag(a)midnightblue.nl>
Gerrit-Comment-Date: Mon, 21 Aug 2023 18:35:29 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment