Change in pysim[master]: SUCI_Calc_Info: avoid repetition of test vectors

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/.

merlinchlosta gerrit-no-reply at lists.osmocom.org
Fri Apr 2 09:30:27 UTC 2021


merlinchlosta has uploaded this change for review. ( https://gerrit.osmocom.org/c/pysim/+/23576 )


Change subject: SUCI_Calc_Info: avoid repetition of test vectors
......................................................................

SUCI_Calc_Info: avoid repetition of test vectors

Change-Id: I4d1b5f10a7679387578383b72cb9a30ac74f2a07
---
M tests/test_utils.py
1 file changed, 20 insertions(+), 28 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/76/23576/1

diff --git a/tests/test_utils.py b/tests/test_utils.py
index 9fa2ba0..badde55 100755
--- a/tests/test_utils.py
+++ b/tests/test_utils.py
@@ -5,6 +5,22 @@
 from pySim.ts_31_102 import EF_SUCI_Calc_Info
 
 class DecTestCase(unittest.TestCase):
+	# TS33.501 Annex C.4 test keys
+	hnet_pubkey_profile_b = "0272DA71976234CE833A6907425867B82E074D44EF907DFB4B3E21C1C2256EBCD1" # ID 27 in test file
+	hnet_pubkey_profile_a = "5A8D38864820197C3394B92613B20B91633CBD897119273BF8E4A6F4EEC0A650" # ID 30 in test file  
+
+	# TS31.121 4.9.4 EF_SUCI_Calc_Info test file
+	testfile_suci_calc_info = "A006020101020000A14B80011B8121" +hnet_pubkey_profile_b +"80011E8120" +hnet_pubkey_profile_a
+
+	decoded_testfile_suci = {
+		'prot_scheme_id_list': [
+			{'priority': 0, 'identifier': 2, 'key_index': 1},
+			{'priority': 1, 'identifier': 1, 'key_index': 2},
+			{'priority': 2, 'identifier': 0, 'key_index': 0}],
+		'hnet_pubkey_list': [
+			{'hnet_pubkey_identifier': 27, 'hnet_pubkey': hnet_pubkey_profile_b.lower()}, # because h2b/b2h returns all lower-case
+			{'hnet_pubkey_identifier': 30, 'hnet_pubkey': hnet_pubkey_profile_a.lower()}]
+	}
 
 	def testSplitHexStringToListOf5ByteEntries(self):
 		input_str = "ffffff0003ffffff0002ffffff0001"
@@ -84,38 +100,14 @@
 
 
 	def testDecodeSuciCalcInfo(self):
-		# TS31.121 4.9.4 EF_SUCI_Calc_Info test file
-		testfile = "A006020101020000A14B80011B81210272DA71976234CE833A6907425867B82E074D44EF907DFB4B3E21C1C2256EBCD180011E81205A8D38864820197C3394B92613B20B91633CBD897119273BF8E4A6F4EEC0A650"
-		expected = {
-			'prot_scheme_id_list': [
-				{'priority': 0, 'identifier': 2, 'key_index': 1},
-				{'priority': 1, 'identifier': 1, 'key_index': 2},
-				{'priority': 2, 'identifier': 0, 'key_index': 0}],
-			'hnet_pubkey_list': [
-				{'hnet_pubkey_identifier': 27, 'hnet_pubkey': '0272DA71976234CE833A6907425867B82E074D44EF907DFB4B3E21C1C2256EBCD1'.lower()}, # because h2b/b2h returns all lower-case
-				{'hnet_pubkey_identifier': 30, 'hnet_pubkey': '5A8D38864820197C3394B92613B20B91633CBD897119273BF8E4A6F4EEC0A650'.lower()}]
-			}
 		suci_calc_info = EF_SUCI_Calc_Info()
-		decoded = suci_calc_info._decode_hex(testfile)
-		self.assertDictEqual(expected, decoded)
+		decoded = suci_calc_info._decode_hex(self.testfile_suci_calc_info)
+		self.assertDictEqual(self.decoded_testfile_suci, decoded)
 
 	def testEncodeSuciCalcInfo(self):
-		# TS31.121 4.9.4 EF_SUCI_Calc_Info test file
-		expected = "A006020101020000A14B80011B81210272DA71976234CE833A6907425867B82E074D44EF907DFB4B3E21C1C2256EBCD180011E81205A8D38864820197C3394B92613B20B91633CBD897119273BF8E4A6F4EEC0A650"
-
-		decoded_testfile = {
-			'prot_scheme_id_list': [
-				{'priority': 0, 'identifier': 2, 'key_index': 1},
-				{'priority': 1, 'identifier': 1, 'key_index': 2},
-				{'priority': 2, 'identifier': 0, 'key_index': 0}],
-			'hnet_pubkey_list': [
-				{'hnet_pubkey_identifier': 27, 'hnet_pubkey': '0272DA71976234CE833A6907425867B82E074D44EF907DFB4B3E21C1C2256EBCD1'.lower()},
-				{'hnet_pubkey_identifier': 30, 'hnet_pubkey': '5A8D38864820197C3394B92613B20B91633CBD897119273BF8E4A6F4EEC0A650'.lower()}]
-			}
-
 		suci_calc_info = EF_SUCI_Calc_Info()
-		encoded = suci_calc_info._encode_hex(decoded_testfile)
-		self.assertEqual(encoded.lower(), expected.lower())
+		encoded = suci_calc_info._encode_hex(self.decoded_testfile_suci)
+		self.assertEqual(encoded.lower(), self.testfile_suci_calc_info.lower())
 
 if __name__ == "__main__":
 	unittest.main()

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

Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I4d1b5f10a7679387578383b72cb9a30ac74f2a07
Gerrit-Change-Number: 23576
Gerrit-PatchSet: 1
Gerrit-Owner: merlinchlosta <merlin.chlosta at rub.de>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210402/c7bb8888/attachment.htm>


More information about the gerrit-log mailing list