[PATCH] osmo-gsm-tester[master]: Introduce auth_algo modem config attribute

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

Pau Espin Pedrol gerrit-no-reply at lists.osmocom.org
Thu Aug 24 15:30:20 UTC 2017


Review at  https://gerrit.osmocom.org/3605

Introduce auth_algo modem config attribute

Algorithm to use to generate response for the challenge during
authentication time is hardcoded in the sim card and cannot be easily
changed. Thus specify in the config of each modem the algorithm used by
the SIM Card. This attribute is used add subscriber_add() time, when the
IMSI, KI and algorithm to use in the MSC to authenticate a given
subscriber is stored in the database. This way we can easily set up
a specific algorithm for each SimCard/Modem, in case different SimCards
are configured with different algorithms.

This can be used to specificially test different algorithms too. For
instance, let's imagine we have 2 simcards, one configured to use comp128v1
and another one with xor, and we create a test which ckecks that XOR is
algo is working fine. We don't want to accidentally select the modem
with comp128v1 in this case. Thus we can use this attribute to create a
scenario file matching 'auth_algo: xor' to ensure always the correct
modem is picked.

Change-Id: Ifdf74630afeb05452994bbc9eb62a745a1d745ce
---
M example/resources.conf
M src/osmo_gsm_tester/ofono_client.py
M src/osmo_gsm_tester/osmo_hlr.py
M src/osmo_gsm_tester/osmo_nitb.py
M src/osmo_gsm_tester/resource.py
M src/osmo_gsm_tester/schema.py
6 files changed, 40 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-gsm-tester refs/changes/05/3605/1

diff --git a/example/resources.conf b/example/resources.conf
index 2f08c93..f190c2f 100644
--- a/example/resources.conf
+++ b/example/resources.conf
@@ -55,18 +55,22 @@
   path: '/sierra_1'
   imsi: '901700000009031'
   ki: '80A37E6FDEA931EAC92FFA5F671EFEAD'
+  auth_algo: 'xor'
 
 - label: sierra_2
   path: '/sierra_2'
   imsi: '901700000009029'
   ki: '00969E283349D354A8239E877F2E0866'
+  auth_algo: 'xor'
 
 - label: gobi_0
   path: '/gobi_0'
   imsi: '901700000009030'
   ki: 'BB70807226393CDBAC8DD3439FF54252'
+  auth_algo: 'xor'
 
 - label: gobi_3
   path: '/gobi_3'
   imsi: '901700000009032'
   ki: '2F70DCA43C45ACB97E947FDD0C7CA30A'
+  auth_algo: 'xor'
diff --git a/src/osmo_gsm_tester/ofono_client.py b/src/osmo_gsm_tester/ofono_client.py
index 00cfd47..ed7e3e4 100644
--- a/src/osmo_gsm_tester/ofono_client.py
+++ b/src/osmo_gsm_tester/ofono_client.py
@@ -403,6 +403,9 @@
             return self._ki
         return self.conf.get('ki')
 
+    def auth_algo(self):
+        return self.conf.get('auth_algo', None)
+
     def _on_netreg_property_changed(self, name, value):
         self.dbg('%r.PropertyChanged() -> %s=%s' % (I_NETREG, name, value))
 
diff --git a/src/osmo_gsm_tester/osmo_hlr.py b/src/osmo_gsm_tester/osmo_hlr.py
index 08de07c..0b763c7 100644
--- a/src/osmo_gsm_tester/osmo_hlr.py
+++ b/src/osmo_gsm_tester/osmo_hlr.py
@@ -114,8 +114,18 @@
         modem.set_msisdn(msisdn)
         subscriber_id = self.next_subscriber_id
         self.next_subscriber_id += 1
+
         if not algo:
-            algo = self.AUTH_ALGO_COMP128v1 if modem.ki() else self.AUTH_ALGO_NONE
+            alg_str = modem.auth_algo()
+            if alg_str is None or alg_str == 'none':
+                algo = self.AUTH_ALGO_NONE
+            elif alg_str == 'comp128v1':
+                algo = self.AUTH_ALGO_COMP128v1
+            elif alg_str == 'xor':
+                algo = self.AUTH_ALGO_XOR
+        if algo != self.AUTH_ALGO_NONE and not modem.ki():
+            raise log.Error("Auth algo %r selected and no KI specified" % algo)
+
         self.log('Add subscriber', msisdn=msisdn, imsi=modem.imsi(), subscriber_id=subscriber_id, algo=algo)
         conn = sqlite3.connect(self.db_file)
         try:
diff --git a/src/osmo_gsm_tester/osmo_nitb.py b/src/osmo_gsm_tester/osmo_nitb.py
index be3b24b..8f91bbd 100644
--- a/src/osmo_gsm_tester/osmo_nitb.py
+++ b/src/osmo_gsm_tester/osmo_nitb.py
@@ -112,12 +112,24 @@
     def mcc_mnc(self):
         return (self.mcc(), self.mnc())
 
-    def subscriber_add(self, modem, msisdn=None):
+    def subscriber_add(self, modem, msisdn=None, algo=None):
         if msisdn is None:
             msisdn = self.suite_run.resources_pool.next_msisdn(modem)
         modem.set_msisdn(msisdn)
+
+        if not algo:
+            alg_str = modem.auth_algo()
+            if not alg_str or alg_str == 'none':
+                algo = None
+            elif alg_str == 'comp128v1':
+                algo = 'comp128v1'
+            elif alg_str == 'xor':
+                algo = 'xor'
+        if algo is not None and not modem.ki():
+            raise log.Error("Auth algo %r selected and no KI specified" % algo)
+
         self.log('Add subscriber', msisdn=msisdn, imsi=modem.imsi())
-        OsmoNitbCtrl(self).subscriber_add(modem.imsi(), msisdn, modem.ki())
+        OsmoNitbCtrl(self).subscriber_add(modem.imsi(), msisdn, modem.ki(), algo)
 
     def subscriber_delete(self, modem):
         self.log('Delete subscriber', imsi=modem.imsi())
@@ -155,8 +167,6 @@
 
     def subscriber_add(self, imsi, msisdn, ki=None, algo=None):
         created = False
-        if ki and not algo:
-            algo = 'comp128v1'
 
         if algo:
             value = '%s,%s,%s,%s' % (imsi,msisdn,algo,ki)
diff --git a/src/osmo_gsm_tester/resource.py b/src/osmo_gsm_tester/resource.py
index 9470f48..c55140a 100644
--- a/src/osmo_gsm_tester/resource.py
+++ b/src/osmo_gsm_tester/resource.py
@@ -64,6 +64,7 @@
         'modem[].path': schema.STR,
         'modem[].imsi': schema.IMSI,
         'modem[].ki': schema.KI,
+        'modem[].auth_algo': schema.AUTH_ALGO,
     }
 
 WANT_SCHEMA = util.dict_add(
diff --git a/src/osmo_gsm_tester/schema.py b/src/osmo_gsm_tester/schema.py
index 4c9b9cd..4df33f2 100644
--- a/src/osmo_gsm_tester/schema.py
+++ b/src/osmo_gsm_tester/schema.py
@@ -61,6 +61,11 @@
 def msisdn(val):
     match_re('MSISDN', MSISDN_RE, val)
 
+def auth_algo(val):
+    if val in ('none', 'xor', 'comp128v1'):
+        return
+    raise ValueError('Unknown Authentication Algorithm: %r' % val)
+
 INT = 'int'
 STR = 'str'
 BOOL_STR = 'bool_str'
@@ -71,6 +76,7 @@
 KI = 'ki'
 MSISDN = 'msisdn'
 TRX_REMOTE_IP = 'trx_remote_ip'
+AUTH_ALGO = 'auth_algo'
 SCHEMA_TYPES = {
         INT: int,
         STR: str,
@@ -82,6 +88,7 @@
         KI: ki,
         MSISDN: msisdn,
         TRX_REMOTE_IP: ipv4,
+        AUTH_ALGO: auth_algo,
     }
 
 def validate(config, schema):

-- 
To view, visit https://gerrit.osmocom.org/3605
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ifdf74630afeb05452994bbc9eb62a745a1d745ce
Gerrit-PatchSet: 1
Gerrit-Project: osmo-gsm-tester
Gerrit-Branch: master
Gerrit-Owner: Pau Espin Pedrol <pespin at sysmocom.de>



More information about the gerrit-log mailing list