From 84857accf3caa50dcc6f793d07aec7044c031ad1 Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Fri, 6 Sep 2024 15:40:19 +0200 Subject: [PATCH] pySim-shell: Detect different eUICC types and print during start-up Change-Id: I54ea4ce663693f3951040dcc8a16bf532bf99c02 --- pySim/cdma_ruim.py | 2 +- pySim/euicc.py | 42 ++++++++++++++++++++++++++++++++++++++++++ pySim/ts_102_221.py | 2 +- pySim/ts_51_011.py | 2 +- 4 files changed, 45 insertions(+), 3 deletions(-) diff --git a/pySim/cdma_ruim.py b/pySim/cdma_ruim.py index f5382c9d..f20e77cd 100644 --- a/pySim/cdma_ruim.py +++ b/pySim/cdma_ruim.py @@ -178,7 +178,7 @@ class DF_CDMA(CardDF): class CardProfileRUIM(CardProfile): '''R-UIM card profile as per 3GPP2 C.S0023-D''' - ORDER = 2 + ORDER = 20 def __init__(self): super().__init__('R-UIM', desc='CDMA R-UIM Card', cla="a0", diff --git a/pySim/euicc.py b/pySim/euicc.py index c7b59d9b..63748188 100644 --- a/pySim/euicc.py +++ b/pySim/euicc.py @@ -31,8 +31,10 @@ from osmocom.utils import Hexstr from osmocom.tlv import * from osmocom.construct import * +from pySim.exceptions import SwMatchError from pySim.utils import Hexstr, SwHexstr, SwMatchstr from pySim.commands import SimCardCommands +from pySim.ts_102_221 import CardProfileUICC import pySim.global_platform # SGP.02 Section 2.2.2 @@ -555,3 +557,43 @@ class CardApplicationECASD(pySim.global_platform.CardApplicationSD): @with_default_category('Application-Specific Commands') class AddlShellCommands(CommandSet): pass + +class CardProfileEuiccSGP32(CardProfileUICC): + ORDER = 5 + + def __init__(self): + super().__init__(name='IoT eUICC (SGP.32)') + + @classmethod + def _try_match_card(cls, scc: SimCardCommands) -> None: + # try a command only supported by SGP.32 + scc.cla_byte = "00" + scc.select_adf(AID_ISD_R) + CardApplicationISDR.store_data_tlv(scc, GetCertsReq(), GetCertsResp) + +class CardProfileEuiccSGP22(CardProfileUICC): + ORDER = 6 + + def __init__(self): + super().__init__(name='Consumer eUICC (SGP.22)') + + @classmethod + def _try_match_card(cls, scc: SimCardCommands) -> None: + # try to read EID from ISD-R + scc.cla_byte = "00" + scc.select_adf(AID_ISD_R) + eid = CardApplicationISDR.get_eid(scc) + # TODO: Store EID identity? + +class CardProfileEuiccSGP02(CardProfileUICC): + ORDER = 7 + + def __init__(self): + super().__init__(name='M2M eUICC (SGP.02)') + + @classmethod + def _try_match_card(cls, scc: SimCardCommands) -> None: + scc.cla_byte = "00" + scc.select_adf(AID_ECASD) + scc.get_data(0x5a) + # TODO: Store EID identity? diff --git a/pySim/ts_102_221.py b/pySim/ts_102_221.py index 9fed6af5..f09b1e35 100644 --- a/pySim/ts_102_221.py +++ b/pySim/ts_102_221.py @@ -786,7 +786,7 @@ class EF_UMPC(TransparentEF): class CardProfileUICC(CardProfile): - ORDER = 1 + ORDER = 10 def __init__(self, name='UICC'): files = [ diff --git a/pySim/ts_51_011.py b/pySim/ts_51_011.py index 8cbca581..26dce8bf 100644 --- a/pySim/ts_51_011.py +++ b/pySim/ts_51_011.py @@ -1086,7 +1086,7 @@ class DF_GSM(CardDF): class CardProfileSIM(CardProfile): - ORDER = 3 + ORDER = 30 def __init__(self): sw = {