laforge has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/40208?usp=email )
Change subject: personalization: implement UppAudit and BatchAudit
......................................................................
personalization: implement UppAudit and BatchAudit
Change-Id: Iaab336ca91b483ecdddd5c6c8e08dc475dc6bd0a
Jenkins: skip-card-test
---
M pySim/esim/saip/batch.py
M pySim/esim/saip/personalization.py
2 files changed, 225 insertions(+), 1 deletion(-)
Approvals:
laforge: Looks good to me, approved
Jenkins Builder: Verified
diff --git a/pySim/esim/saip/batch.py b/pySim/esim/saip/batch.py
index 92e8b1e..a8db5c4 100644
--- a/pySim/esim/saip/batch.py
+++ b/pySim/esim/saip/batch.py
@@ -19,11 +19,16 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import copy
-from typing import Generator
+import pprint
+from typing import Generator, Union
+from osmocom.utils import b2h
from pySim.esim.saip.personalization import ConfigurableParameter
from pySim.esim.saip import param_source
from pySim.esim.saip import ProfileElementSequence
+# a list of ConfigurableParameter classes and/or ConfigurableParameter class instances
+ParamList = list[Union[type[ConfigurableParameter], ConfigurableParameter]]
+
class BatchPersonalization:
"""Produce a series of eSIM profiles from predefined parameters.
Personalization parameters are derived from pysim.esim.saip.param_source.ParamSource.
@@ -118,3 +123,215 @@
raise ValueError(f'{p.param_cls.get_name()} fed by {p.src.name}: {e}') from e
yield pes
+
+
+class UppAudit(dict):
+ """
+ Key-value pairs collected from a single UPP DER or PES.
+
+ UppAudit itself is a dict, callers may use the standard python dict API to access key-value pairs read from the UPP.
+ """
+
+ @classmethod
+ def from_der(cls, der: bytes, params: ParamList, der_size=False):
+ """return a dict of parameter name and set of selected parameter values found in a DER encoded profile. Note:
+ some ConfigurableParameter implementations return more than one key-value pair, for example, Imsi returns
+ both 'IMSI' and 'IMSI-ACC' parameters.
+
+ e.g.
+ UppAudit.from_der(my_der, [Imsi, ])
+ --> {'IMSI': {'001010000000023'}, 'IMSI-ACC': {'5'}}
+
+ (where 'IMSI' == Imsi.name)
+
+ Read all parameters listed in params. params is a list of either ConfigurableParameter classes or
+ ConfigurableParameter class instances. This calls only classmethods, so each entry in params can either be the
+ class itself, or a class-instance of, a (non-abstract) ConfigurableParameter subclass.
+ For example, params = [Imsi, ] is equivalent to params = [Imsi(), ].
+
+ For der_size=True, also include a {'der_size':12345} entry.
+ """
+
+ # make an instance of this class
+ upp_audit = cls()
+
+ if der_size:
+ upp_audit['der_size'] = set((len(der), ))
+
+ pes = ProfileElementSequence.from_der(der)
+ for param in params:
+ try:
+ for valdict in param.get_values_from_pes(pes):
+ upp_audit.add_values(valdict)
+ except (TypeError, ValueError) as e:
+ raise ValueError(f'Error during audit for parameter {param}: {e}') from e
+ return upp_audit
+
+ def get_single_val(self, key, allow_absent=False, absent_val=None):
+ """
+ Return the audit's value for the given audit key (like 'IMSI' or 'IMSI-ACC').
+ Any kind of value may occur multiple times in a profile. When all of these agree to the same unambiguous value,
+ return that value. When they do not agree, raise a ValueError.
+ """
+ # key should be a string, but if someone passes a ConfigurableParameter, just use its default name
+ if ConfigurableParameter.is_super_of(key):
+ key = key.get_name()
+
+ assert isinstance(key, str)
+ v = self.get(key)
+ if v is None and allow_absent:
+ return absent_val
+ if not isinstance(v, set):
+ raise ValueError(f'audit value should be a set(), got {v!r}')
+ if len(v) != 1:
+ raise ValueError(f'expected a single value for {key}, got {v!r}')
+ v = tuple(v)[0]
+ return v
+
+ @staticmethod
+ def audit_val_to_str(v):
+ """
+ Usually, we want to see a single value in an audit. Still, to be able to collect multiple ambiguous values,
+ audit values are always python sets. Turn it into a nice string representation: only the value when it is
+ unambiguous, otherwise a list of the ambiguous values.
+ A value may also be completely absent, then return 'not present'.
+ """
+ def try_single_val(w):
+ 'change single-entry sets to just the single value'
+ if isinstance(w, set):
+ if len(w) == 1:
+ return tuple(w)[0]
+ if len(w) == 0:
+ return None
+ return w
+
+ v = try_single_val(v)
+ if isinstance(v, bytes):
+ v = b2h(v)
+ if v is None:
+ return 'not present'
+ return str(v)
+
+ def get_val_str(self, key):
+ """Return a string of the value stored for the given key"""
+ return UppAudit.audit_val_to_str(self.get(key))
+
+ def add_values(self, src:dict):
+ """Merge a plain dict of values into self, which is a dict of sets.
+ For example from
+ self == { 'a': {123} }
+ and
+ src == { 'a': 456, 'b': 789 }
+ then after this function call:
+ self == { 'a': {123, 456}, 'b': {789} }
+ """
+ assert isinstance(src, dict)
+ for key, srcval in src.items():
+ dstvalset = self.get(key)
+ if dstvalset is None:
+ dstvalset = set()
+ self[key] = dstvalset
+ dstvalset.add(srcval)
+
+ def __str__(self):
+ return '\n'.join(f'{key}: {self.get_val_str(key)}' for key in sorted(self.keys()))
+
+class BatchAudit(list):
+ """
+ Collect UppAudit instances for a batch of UPP, for example from a personalization.BatchPersonalization.
+ Produce an output CSV.
+
+ Usage example:
+
+ ba = BatchAudit(params=(personalization.Iccid, ))
+ for upp_der in upps:
+ ba.add_audit(upp_der)
+ print(ba.summarize())
+
+ with open('output.csv', 'wb') as csv_data:
+ csv_str = io.TextIOWrapper(csv_data, 'utf-8', newline='')
+ csv.writer(csv_str).writerows( ba.to_csv_rows() )
+ csv_str.flush()
+
+ BatchAudit itself is a list, callers may use the standard python list API to access the UppAudit instances.
+ """
+
+ def __init__(self, params: ParamList):
+ assert params
+ self.params = params
+
+ def add_audit(self, upp_der:bytes):
+ audit = UppAudit.from_der(upp_der, self.params)
+ self.append(audit)
+ return audit
+
+ def summarize(self):
+ batch_audit = UppAudit()
+
+ audits = self
+
+ if len(audits) > 2:
+ val_sep = ', ..., '
+ else:
+ val_sep = ', '
+
+ first_audit = None
+ last_audit = None
+ if len(audits) >= 1:
+ first_audit = audits[0]
+ if len(audits) >= 2:
+ last_audit = audits[-1]
+
+ if first_audit:
+ if last_audit:
+ for key in first_audit.keys():
+ first_val = first_audit.get_val_str(key)
+ last_val = last_audit.get_val_str(key)
+
+ if first_val == last_val:
+ val = first_val
+ else:
+ val_sep_with_newline = f"{val_sep.rstrip()}\n{' ' * (len(key) + 2)}"
+ val = val_sep_with_newline.join((first_val, last_val))
+ batch_audit[key] = val
+ else:
+ batch_audit.update(first_audit)
+
+ return batch_audit
+
+ def to_csv_rows(self, headers=True, sort_key=None):
+ """generator that yields all audits' values as rows, useful feed to a csv.writer."""
+ columns = set()
+ for audit in self:
+ columns.update(audit.keys())
+
+ columns = tuple(sorted(columns, key=sort_key))
+
+ if headers:
+ yield columns
+
+ for audit in self:
+ yield (audit.get_single_val(col, allow_absent=True, absent_val="") for col in columns)
+
+def esim_profile_introspect(upp):
+ pes = ProfileElementSequence.from_der(upp.read())
+ d = {}
+ d['upp'] = repr(pes)
+
+ def show_bytes_as_hexdump(item):
+ if isinstance(item, bytes):
+ return b2h(item)
+ if isinstance(item, list):
+ return list(show_bytes_as_hexdump(i) for i in item)
+ if isinstance(item, tuple):
+ return tuple(show_bytes_as_hexdump(i) for i in item)
+ if isinstance(item, dict):
+ d = {}
+ for k, v in item.items():
+ d[k] = show_bytes_as_hexdump(v)
+ return d
+ return item
+
+ l = list((pe.type, show_bytes_as_hexdump(pe.decoded)) for pe in pes)
+ d['pp'] = pprint.pformat(l, width=120)
+ return d
diff --git a/pySim/esim/saip/personalization.py b/pySim/esim/saip/personalization.py
index c633a9c..eb81934 100644
--- a/pySim/esim/saip/personalization.py
+++ b/pySim/esim/saip/personalization.py
@@ -260,6 +260,13 @@
'''
return cls.get_len_range()[1] or 16
+ @classmethod
+ def is_super_of(cls, other_class):
+ try:
+ return issubclass(other_class, cls)
+ except TypeError:
+ return False
+
class DecimalParam(ConfigurableParameter):
"""Decimal digits. The input value may be a string of decimal digits like '012345', or an int. The output of
validate_val() is a string with only decimal digits 0-9, in the required length with leading zeros if necessary.
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/40208?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: Iaab336ca91b483ecdddd5c6c8e08dc475dc6bd0a
Gerrit-Change-Number: 40208
Gerrit-PatchSet: 12
Gerrit-Owner: neels <nhofmeyr(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-CC: fixeria <vyanitskiy(a)sysmocom.de>
Attention is currently required from: fixeria, laforge, neels.
laforge has uploaded a new patch set (#13) to the change originally created by neels. ( https://gerrit.osmocom.org/c/pysim/+/40209?usp=email )
The following approvals got outdated and were removed:
Code-Review+1 by laforge
Change subject: personalization audit: optionally audit all (unknown) SD keys
......................................................................
personalization audit: optionally audit all (unknown) SD keys
By a flag, allow to audit also all Security Domain KVN that we have
*not* created ConfigurableParameter subclasses for.
For example, SCP80 has reserved kvn 0x01..0x0f, but we offer only
Scp80Kvn01, Scp80Kvn02, Scp80Kvn03. So we would not show kvn
0x04..0x0f in an audit.
This patch includes audits of all SD key kvn there may be in the UPP.
This will help to spot SD keys that may already be present in a UPP
template, with unexpected / unusual kvn.
Change-Id: Icaf6f7b589f117868633c0968a99f2f0252cf612
Jenkins: skip-card-test
---
M pySim/esim/saip/batch.py
1 file changed, 26 insertions(+), 3 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/09/40209/13
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/40209?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: newpatchset
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: Icaf6f7b589f117868633c0968a99f2f0252cf612
Gerrit-Change-Number: 40209
Gerrit-PatchSet: 13
Gerrit-Owner: neels <nhofmeyr(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-CC: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Attention: neels <nhofmeyr(a)sysmocom.de>
Gerrit-Attention: laforge <laforge(a)osmocom.org>
Gerrit-Attention: fixeria <vyanitskiy(a)sysmocom.de>
Attention is currently required from: fixeria, neels.
laforge has posted comments on this change by neels. ( https://gerrit.osmocom.org/c/pysim/+/40208?usp=email )
Change subject: personalization: implement UppAudit and BatchAudit
......................................................................
Patch Set 11: Code-Review+2
(1 comment)
File pySim/esim/saip/batch.py:
https://gerrit.osmocom.org/c/pysim/+/40208/comment/12f10cce_5853678a?usp=em… :
PS11, Line 143: {'001010000000023'}
> I follow your conclusions, but there is one initial assumption that I'd like to clarify: […]
Ok, I failed to realize the "safe-ness" of the code as-is in presence of multiple different IMSI instances, thanks for pointing that out. So we can merge it as-is for now.
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/40208?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: Iaab336ca91b483ecdddd5c6c8e08dc475dc6bd0a
Gerrit-Change-Number: 40208
Gerrit-PatchSet: 11
Gerrit-Owner: neels <nhofmeyr(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-CC: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Attention: neels <nhofmeyr(a)sysmocom.de>
Gerrit-Attention: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Comment-Date: Fri, 19 Jun 2026 10:37:22 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Comment-In-Reply-To: neels <nhofmeyr(a)sysmocom.de>
Comment-In-Reply-To: laforge <laforge(a)osmocom.org>
Attention is currently required from: fixeria.
neels has posted comments on this change by neels. ( https://gerrit.osmocom.org/c/pysim/+/41771?usp=email )
Change subject: generate sdkey classes from a list
......................................................................
Patch Set 9:
(2 comments)
File pySim/esim/saip/personalization.py:
https://gerrit.osmocom.org/c/pysim/+/41771/comment/9cc22dc1_3bdc3d0a?usp=em… :
PS7, Line 653: reserved_kvn = tuple()
> This is defined but never used anywhere?
I guess we can drop it then, cruft from an earlier patch version?
https://gerrit.osmocom.org/c/pysim/+/41771/comment/d6dc317d_985afb28?usp=em… :
PS7, Line 694: NO_OP = (('', {}))
> Likewise, defined but not used.
we can drop it, this is definitely cruft from an earlier patch version.
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/41771?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: Ic92ddea6e1fad8167ea75baf78ffc3eb419838c4
Gerrit-Change-Number: 41771
Gerrit-PatchSet: 9
Gerrit-Owner: neels <nhofmeyr(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-CC: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Attention: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Comment-Date: Thu, 18 Jun 2026 13:30:19 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: fixeria <vyanitskiy(a)sysmocom.de>
Attention is currently required from: fixeria, laforge.
neels has posted comments on this change by neels. ( https://gerrit.osmocom.org/c/pysim/+/40208?usp=email )
Change subject: personalization: implement UppAudit and BatchAudit
......................................................................
Patch Set 11:
(1 comment)
File pySim/esim/saip/batch.py:
https://gerrit.osmocom.org/c/pysim/+/40208/comment/2682c181_b25146ad?usp=em… :
PS11, Line 143: {'001010000000023'}
> Just to clarify: I think it's fine to not support multiple USIM NAA and/or multipel ISIM NAA for now […]
I follow your conclusions, but there is one initial assumption that I'd like to clarify:
"our code should be safe. So if we do not support multiple USIM NAAs or
multiple ISIM NAAs from the audit code (or any other part of the code),
it should safely abort and refuse to proceed with such a PESequence as
input data"
The audit code is safe in this way, because it does support multiple occurences.
Use cases in pseudo code:
UPP{ usim: {imsi: 1234} }
--audit--> {IMSI: {1234}}
UPP{ usim: {imsi: 1234}, isim: {imsi: 1234} }
--audit--> {IMSI: {1234}}
UPP{ usim: {imsi: 1234}, isim: {imsi: 1234}, usim2: {imsi: 5678}, isim2: {imsi: 5678}}
--audit--> {IMSI: {1234, 5678}}
(caller decides about expecting two IMSIs or not)
So code that is handling multiple USIM NAAs would expect both IMSIs in the resulting set. The audit would not indicate which IMSI is where exactly, but the aim of BatchAudit is to simplify.
If we add an exception as discussed, the last example would not return any result but raise an exception saying "multiple USIM NAAs are not supported". That change would reduce current usefulness, and the code raising the exception would also be a side island of code that has to specifically detect that situation -- it would not arise naturally from the code paths.
So, we are now deciding in this patch, to which level of detail the audit result returns its info. It's at this point not about preventing crashes from situations we don't support, because i expect no crashes in any use cases.
I can understand that it may be useful to get an indication of where specific data was read from. Currently there is no caller that needs to know this, so I am merely guessing about use cases you have in mind.
(IOW, all current callers would ignore the source indication and would always collapse to a single set() before evaluating.)
So, what is the next thing that should happen in this patch?
IIUC I can make a decision to leave the patch as-is, or to change the set() of values to a dict that has a place to indicate the source of the data?
Instead of inventing an xpath like syntax now, I would just put an empty placeholder for future expansion, because there are currently no use cases for it -- so that we can implement a path syntax when we know what exactly the place indication needs to indicate in order to be useful.
It may boil down to only a comment: "callers must check via isinstance() whether the result is a set() or a dict()", just to open up a path to future expansion.
In summary, I am unfortunately still convinced that the way the current patch returns multiple occurences is a good simplification that matches the use cases well -- "unfortunately" because I am trying to agree in order to reach a conclusion but the logic doesn't match up from my POV.
(BTW the argument I make about "this code is already used in production" is more like: "i've already played through all code paths end-to-end such that i have a clear picture of what we need this code to do, and thus i found what i believe is the optimal balance of detail and simplicity. The way this works has helped super well in various situations. I've found and fixed numerous UPP bugs with this: it is stable and useful. If i wrote it from scratch i would end up with exactly the same patch."
I am very happy to completely overhaul this code, and then adjust the production code -- if there is an actual use case that i missed.)
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/40208?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: Iaab336ca91b483ecdddd5c6c8e08dc475dc6bd0a
Gerrit-Change-Number: 40208
Gerrit-PatchSet: 11
Gerrit-Owner: neels <nhofmeyr(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-CC: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Attention: laforge <laforge(a)osmocom.org>
Gerrit-Attention: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Comment-Date: Thu, 18 Jun 2026 13:28:24 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: neels <nhofmeyr(a)sysmocom.de>
Comment-In-Reply-To: laforge <laforge(a)osmocom.org>
laforge has submitted this change. ( https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/42799?usp=email )
Change subject: CCID: Check if reader times out while expecting status words
......................................................................
CCID: Check if reader times out while expecting status words
A case 1 APDU is sent toward the reader. The reader expects two status
words. If none of these are sent by the SIM the reader must timeout and
send an error message back to the host.
Change-Id: I054b56a9e2f10e5b984ad0398efb4be5696ce16c
---
M ccid/CCID_Tests.ttcn
1 file changed, 35 insertions(+), 0 deletions(-)
Approvals:
Jenkins Builder: Verified
laforge: Looks good to me, approved
diff --git a/ccid/CCID_Tests.ttcn b/ccid/CCID_Tests.ttcn
index a637d10..a06c878 100644
--- a/ccid/CCID_Tests.ttcn
+++ b/ccid/CCID_Tests.ttcn
@@ -1011,6 +1011,40 @@
f_start_and_wait();
}
+/* The SIM does not send the expected status words. */
+private function f_TC_status_word_timeout() runs on CardemSlot_CT
+{
+ var octetstring req := c_UICC_MANAGE_CHANNEL;
+ var CCID_PDU ccid_pdu;
+
+ f_cardem_manager();
+
+ f_ccid_power_on(CCID_PWRSEL_3V0);
+
+ /* Send a request towards reader. */
+ CCID.send(ts_CCID_XfrBlock(g_slot_nr, req, 0));
+ /* Receive the request by SIM. */
+ f_cardem_receive(tr_SIMTRACE_CEMU_RX_DATA(?, req));
+ /* Receive the response from reader. */
+ ccid_pdu := f_ccid_receive(tr_CCID_DataBlock(g_slot_nr, ?, ?, ?));
+ if (ccid_pdu.hdr_in.bError != CCID_ERR_ICC_MUTE) {
+ setverdict(fail, "Unexpected Response or error code");
+ mtc.stop;
+ }
+
+ /* Stop simtrace emulation, to prevent race condition. */
+ vc_Cardem.stop;
+ vc_Cardem.done;
+}
+testcase TC_status_word_timeout() runs on Test_CT
+{
+ f_init();
+
+ f_start_handler(refers(f_TC_status_word_timeout), mp_simtrace_slot, true);
+
+ f_start_and_wait();
+}
+
/* TODO */
/* IccPowerOn with wrong voltage (> 0x04) */
@@ -1058,6 +1092,7 @@
execute( TC_truncated() );
execute( TC_truncated_response() );
execute( TC_empty_slot() );
+ execute( TC_status_word_timeout() );
}
--
To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/42799?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-Change-Id: I054b56a9e2f10e5b984ad0398efb4be5696ce16c
Gerrit-Change-Number: 42799
Gerrit-PatchSet: 5
Gerrit-Owner: jolly <andreas(a)eversberg.eu>
Gerrit-Reviewer: Hoernchen <ewild(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Attention is currently required from: Hoernchen, jolly.
laforge has posted comments on this change by jolly. ( https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/42799?usp=email )
Change subject: CCID: Check if reader times out while expecting status words
......................................................................
Patch Set 5: Code-Review+2
--
To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/42799?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-Change-Id: I054b56a9e2f10e5b984ad0398efb4be5696ce16c
Gerrit-Change-Number: 42799
Gerrit-PatchSet: 5
Gerrit-Owner: jolly <andreas(a)eversberg.eu>
Gerrit-Reviewer: Hoernchen <ewild(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Attention: Hoernchen <ewild(a)sysmocom.de>
Gerrit-Attention: jolly <andreas(a)eversberg.eu>
Gerrit-Comment-Date: Thu, 18 Jun 2026 12:28:23 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
laforge has submitted this change. ( https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/42805?usp=email )
Change subject: CCID: Check response of reader with empty SIM carrier
......................................................................
CCID: Check response of reader with empty SIM carrier
The reader has a SIM carrier inserted, but there is no response from the
SIM while expecting the ATR. The reader will get a timeout and is
expected to respond with a suitable error code.
The test uses the slot with the SIMtrace inserted. The SIMtrace will not
respond with an ATR. This way there is no (extra) empty slot required
for this test.
Change-Id: Ifebdcce8f9dd9a51de5a5cb6cf223041d5c38622
---
M ccid/CCID_Tests.ttcn
1 file changed, 41 insertions(+), 2 deletions(-)
Approvals:
Jenkins Builder: Verified
laforge: Looks good to me, approved
diff --git a/ccid/CCID_Tests.ttcn b/ccid/CCID_Tests.ttcn
index 8184bf3..a637d10 100644
--- a/ccid/CCID_Tests.ttcn
+++ b/ccid/CCID_Tests.ttcn
@@ -971,11 +971,49 @@
f_start_and_wait();
}
+/* The SIM slot is empty, but closed. There is no ATR received. */
+private function f_TC_empty_slot() runs on CardemSlot_CT
+{
+ var octetstring req := c_SIM_SELECT_EF_ICCID;
+ var octetstring res := '9000'O;
+ var CCID_PDU ccid_pdu;
+ var CCID_PDU par;
+
+ /* Do not start SIM emulation, so there is no ATR. */
+ f_cardem_transmit(ts_SIMTRACE_CEMU_SET_ATR(''O));
+ f_sleep(0.2);
+
+ f_ccid_power_on(CCID_PWRSEL_3V0, tr_CCID_HeaderIN_FAIL(CCID_ERR_ICC_MUTE, CCID_ICC_STATUS_PRES_INACT));
+
+ /* Send a request towards reader. */
+ CCID.send(ts_CCID_XfrBlock(g_slot_nr, req, 0));
+ /* Receive the response from reader. */
+ ccid_pdu := f_ccid_receive(tr_CCID_DataBlock(g_slot_nr, ?, ?, ?));
+ if (ccid_pdu.hdr_in.bError != CCID_ERR_CMD_NOT_SUPPORTED) {
+ setverdict(fail, "Unexpected Response or error code");
+ mtc.stop;
+ }
+ /* Send GetParameters on empty slot. */
+ par := f_ccid_get_par();
+ log(par);
+ // FIXME: check result code
+
+ /* Stop simtrace emulation, to prevent race condition. */
+ vc_Cardem.stop;
+ vc_Cardem.done;
+}
+testcase TC_empty_slot() runs on Test_CT
+{
+ f_init();
+
+ f_start_handler(refers(f_TC_empty_slot), mp_simtrace_slot, true);
+
+ f_start_and_wait();
+}
+
/* TODO */
/* IccPowerOn with wrong voltage (> 0x04) */
-/* XfrBlock on empty slot */
-/* GetParameters on empty slot */
/* SetParameters for bProtocolNum > 0x01 */
/* SetParameters: invalid parameters */
/* set unsupported frequency */
@@ -1019,6 +1057,7 @@
execute( TC_unsupp_secure() );
execute( TC_truncated() );
execute( TC_truncated_response() );
+ execute( TC_empty_slot() );
}
--
To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/42805?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-Change-Id: Ifebdcce8f9dd9a51de5a5cb6cf223041d5c38622
Gerrit-Change-Number: 42805
Gerrit-PatchSet: 5
Gerrit-Owner: jolly <andreas(a)eversberg.eu>
Gerrit-Reviewer: Hoernchen <ewild(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
laforge has submitted this change. ( https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/42827?usp=email )
(
2 is the latest approved patch-set.
No files were changed between the latest approved patch-set and the submitted one.
)Change subject: CCID: Add testenv.cfg to run tests using testenv
......................................................................
CCID: Add testenv.cfg to run tests using testenv
Change-Id: I97c9da414facf438aa28d5200c4152730ff763a2
---
A ccid/testenv.cfg
1 file changed, 5 insertions(+), 0 deletions(-)
Approvals:
Jenkins Builder: Verified
laforge: Looks good to me, approved
diff --git a/ccid/testenv.cfg b/ccid/testenv.cfg
new file mode 100644
index 0000000..a895ff3
--- /dev/null
+++ b/ccid/testenv.cfg
@@ -0,0 +1,5 @@
+[testsuite]
+program=CCID_Tests
+config=CCID_Tests.cfg
+podman_extra=--volume /dev/bus/usb:/dev/bus/usb
+
--
To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/42827?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-Change-Id: I97c9da414facf438aa28d5200c4152730ff763a2
Gerrit-Change-Number: 42827
Gerrit-PatchSet: 4
Gerrit-Owner: jolly <andreas(a)eversberg.eu>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>