aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMerlin Chlosta <merlin.chlosta@rub.de>2021-04-01 16:15:28 +0200
committerMerlin Chlosta <merlin.chlosta@rub.de>2021-04-02 14:10:10 +0200
commit05ca36b3f39a50e02e9725eca0b84c324a2df4b4 (patch)
treeef4031d0959f8bb2c116d5a9814098fb87ea26c0 /tests
parentdd2091a3e0125eb7a47355be512eea1063cd6383 (diff)
Add decoder/encoder for EF.SUCI_Calc_Info
Diffstat (limited to 'tests')
-rwxr-xr-x[-rw-r--r--]tests/test_utils.py30
1 files changed, 29 insertions, 1 deletions
diff --git a/tests/test_utils.py b/tests/test_utils.py
index bcf6140..badde55 100644..100755
--- a/tests/test_utils.py
+++ b/tests/test_utils.py
@@ -1,9 +1,26 @@
#!/usr/bin/env python3
import unittest
-import pySim.utils as utils
+from pySim import utils
+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"
@@ -81,5 +98,16 @@ class DecTestCase(unittest.TestCase):
expected += "\tffffff0000 # unused\n"
self.assertEqual(utils.format_xplmn_w_act(input_str), expected)
+
+ def testDecodeSuciCalcInfo(self):
+ suci_calc_info = EF_SUCI_Calc_Info()
+ decoded = suci_calc_info._decode_hex(self.testfile_suci_calc_info)
+ self.assertDictEqual(self.decoded_testfile_suci, decoded)
+
+ def testEncodeSuciCalcInfo(self):
+ suci_calc_info = EF_SUCI_Calc_Info()
+ 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()