[PATCH] osmo-sim-auth[master]: cosmetic: add/tweak log output, add vim indenting marker

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

Neels Hofmeyr gerrit-no-reply at lists.osmocom.org
Tue Mar 14 11:51:09 UTC 2017


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

cosmetic: add/tweak log output, add vim indenting marker

While testing the sysmoUSIM, I found that I wanted to see errors more
prominently and some output for cases that lacked any response at all.

Change-Id: Ia2ac1215ae948558324627f76e28c72a23dc6a68
---
M card/USIM.py
1 file changed, 13 insertions(+), 10 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-sim-auth refs/changes/52/2052/1

diff --git a/card/USIM.py b/card/USIM.py
index d8cbb85..a5adc5b 100644
--- a/card/USIM.py
+++ b/card/USIM.py
@@ -242,8 +242,7 @@
         # prepare input data for authentication
         if ctx in ('3G', 'VGCS', 'GBA', 'MBMS') and len(RAND) != 16 \
         and len(AUTN) != 16: 
-            if self.dbg: 
-                print '[WNG] authenticate: bad parameters'
+            print '[ERR] missing parameters or wrong length'
             return None
         
         inp = []
@@ -265,8 +264,7 @@
         # to avoid desynchronizing our USIM counter
             P2 = 0x80
             if len(RAND) != 16: 
-                if self.dbg: 
-                    print '[WNG] bad parameters'
+                print '[ERR] RAND has wrong length (%d, should be 16)' % len(RAND)
                 return None
             # override input value for 2G authent
             inp = [len(RAND)] + RAND
@@ -284,11 +282,14 @@
                     return values
                 # not adapted to 2G context with Kc, RES: to be confirmed...
                 if val[0] == 0xDB:
-                    if P2 == 0x81 and self.dbg: 
-                        print '[+] Successful 3G authentication. ' \
-                              'Get [RES, CK, IK(, Kc)]' 
-                    elif P2 == 0x84 and self.dbg: 
-                        print '[+] Successful GBA authentication. Get [RES]'
+                    if self.dbg:
+                        if P2 == 0x81:
+                            print '[+] Successful 3G authentication. ' \
+                                  'Get [RES, CK, IK(, Kc)]'
+                        elif P2 == 0x84:
+                            print '[+] Successful GBA authentication. Get [RES]'
+                        else:
+                            print '[+] response: %s' % hex(val)
                     values = LV_parser(val[1:])
                     # returned values can be (RES, CK, IK) or (RES, CK, IK, Kc)
                     return values
@@ -297,6 +298,8 @@
                         print '[+] Synchronization failure. Get [AUTS]'
                     values = LV_parser(val[1:])
                     return values
+                elif self.dbg:
+                    print '[+] response: %s' % hex(val)
         #else:
         if self.dbg: 
             print '[+] authentication error: %s' % self.coms()
@@ -398,5 +401,5 @@
         #bf from MF, and recursively under each DF
         #bf from each AID and recursively under each DF in AID
         pass
-    
 
+# vim: tabstop=4 shiftwidth=4 expandtab

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia2ac1215ae948558324627f76e28c72a23dc6a68
Gerrit-PatchSet: 1
Gerrit-Project: osmo-sim-auth
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>



More information about the gerrit-log mailing list