From 34dce409b9489ebf3b9258440f7e2294a25d4cda Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Sat, 20 Jul 2024 15:53:02 +0200 Subject: [PATCH] pySim.global_platform.ota: Support KVN 0x70 for SCP02 This is a non-standard extension of sysmocom products. Change-Id: I00d52f7629aae190ee487ea3453f42b5f94cf42f --- pySim/global_platform/scp.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/pySim/global_platform/scp.py b/pySim/global_platform/scp.py index 967a582d..f68bcf91 100644 --- a/pySim/global_platform/scp.py +++ b/pySim/global_platform/scp.py @@ -115,6 +115,12 @@ class SCP(SecureChannel, abc.ABC): if not card_keys.kvn in range(self.kvn_range[0], self.kvn_range[1]+1): raise ValueError('%s cannot be used with KVN outside range 0x%02x..0x%02x' % (self.__class__.__name__, self.kvn_range[0], self.kvn_range[1])) + elif hasattr(self, 'kvn_ranges'): + # pylint: disable=no-member + if all([not card_keys.kvn in range(x[0], x[1]+1) for x in self.kvn_ranges]): + raise ValueError('%s cannot be used with KVN outside permitted ranges %s' % + (self.__class__.__name__, self.kvn_ranges)) + self.lchan_nr = lchan_nr self.card_keys = card_keys self.sk = None @@ -216,7 +222,8 @@ class SCP02(SCP): constr_iur = Struct('key_div_data'/Bytes(10), 'key_ver'/Int8ub, Const(b'\x02'), 'seq_counter'/Int16ub, 'card_challenge'/Bytes(6), 'card_cryptogram'/Bytes(8)) - kvn_range = [0x20, 0x2f] + # The 0x70 is a non-spec special-case of sysmoISIM-SJA2/SJA5 and possibly more sysmocom products + kvn_ranges = [[0x20, 0x2f], [0x70, 0x70]] def __init__(self, *args, **kwargs): self.overhead = 8