Change in pysim[master]: pySim-read.py: Add ability to read Cards with correct CLA, P1 and P2 ...

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

laforge gerrit-no-reply at lists.osmocom.org
Mon Apr 27 10:17:56 UTC 2020


laforge has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/17880 )

Change subject: pySim-read.py: Add ability to read Cards with correct CLA, P1 and P2 bytes
......................................................................

pySim-read.py: Add ability to read Cards with correct CLA, P1 and P2 bytes

Initially the Card is read assuming a UICC SIM, but in case its not, an
error 6e00 will be thrown indicating CLA not supported and Card has just Classic SIM application.

Ref: https://web.archive.org/web/20090630004017/http://cheef.ru/docs/HowTo/APDU.info

The above link provides the bytes to use for CLA, P1, P2 in APDU

Change-Id: Ifea328eff3a381d7b82118e22d2bc0ec5f8a87e4
---
M pySim-read.py
1 file changed, 11 insertions(+), 1 deletion(-)

Approvals:
  laforge: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/pySim-read.py b/pySim-read.py
index 3e25c76..8f81443 100755
--- a/pySim-read.py
+++ b/pySim-read.py
@@ -92,6 +92,17 @@
 	# Wait for SIM card
 	sl.wait_for_card()
 
+	# Assuming UICC SIM
+	scc.cla_byte = "00"
+	scc.sel_ctrl = "0004"
+
+	# Testing for Classic SIM or UICC
+	(res, sw) = sl.send_apdu(scc.cla_byte + "a4" + scc.sel_ctrl + "02" + "3f00")
+	if sw == '6e00':
+		# Just a Classic SIM
+		scc.cla_byte = "a0"
+		scc.sel_ctrl = "0000"
+
 	# Program the card
 	print("Reading ...")
 
@@ -236,6 +247,5 @@
 	else:
 		print("SIM Service Table: Can't read, response code = %s" % (sw,))
 
-
 	# Done for this card and maybe for everything ?
 	print("Done !\n")

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

Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: Ifea328eff3a381d7b82118e22d2bc0ec5f8a87e4
Gerrit-Change-Number: 17880
Gerrit-PatchSet: 5
Gerrit-Owner: herlesupreeth <herlesupreeth at gmail.com>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: herlesupreeth <herlesupreeth at gmail.com>
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-CC: guilly at gmail.com <guilly at gmail.com>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20200427/8b894d17/attachment.htm>


More information about the gerrit-log mailing list