pespin has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/36868?usp=email )


Change subject: asterisk: Compute nonce from rand and autn params
......................................................................

asterisk: Compute nonce from rand and autn params

Change-Id: I2809eec496a1c2c2b5f6e3d5d3bb1c33a788bd58
---
M asterisk/IMS_ConnectionHandler.ttcn
M asterisk/gen_links.sh
M asterisk/regen_makefile.sh
3 files changed, 25 insertions(+), 4 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-ttcn3-hacks 
refs/changes/68/36868/1

diff --git a/asterisk/IMS_ConnectionHandler.ttcn 
b/asterisk/IMS_ConnectionHandler.ttcn
index dcf3646..d1e3185 100644
--- a/asterisk/IMS_ConnectionHandler.ttcn
+++ b/asterisk/IMS_ConnectionHandler.ttcn
@@ -10,6 +10,7 @@
  */
 module IMS_ConnectionHandler {

+import from TCCEncoding_Functions all;
 import from TCCOpenSecurity_Functions all;
 import from General_Types all;
 import from Osmocom_Types all;
@@ -65,7 +66,8 @@
        charstring user,
        charstring display_name,
        charstring password,
-       charstring nonce,
+       octetstring rand,
+       octetstring autn,
        charstring ipsec_auth_key,
        integer ipsec_local_spi_c,
        integer ipsec_local_spi_s,
@@ -147,7 +149,8 @@
        display_name := f_sip_str_quote(display_name),
        password := password,
        /* The Nonce field is the Base64 encoded version of the RAND value and 
concatenated with the AUTN: */
-       nonce := "FJh2MfZfjjeIoHmLbrzQjvbhmnzLAoAAoGsZyVRFFuU=",
+       rand := '14987631f65f8e3788a0798b6ebcd08e'O,
+       autn := 'f6e19a7ccb028000a06b19c9544516e5'O,
        ipsec_auth_key := "0x5238297dfcca759bd05d48ff49bc63fa00000000",
        ipsec_local_spi_c := 4142,
        ipsec_local_spi_s := 4143,
@@ -214,6 +217,13 @@
        }
 }

+private function f_nonce_from_rand_autn(octetstring rand, octetstring autn) 
return charstring {
+       var octetstring concat := rand & autn;
+       var charstring nonce := enc_MIME_Base64(concat);
+       log("rand=", rand, " & autn=",autn, " => nonce=", nonce);
+       return nonce;
+}
+
 /* HTTP Digest Authentication Using AKA (AKAv1-MD5): RFC 3310 */
 function f_tr_Authorization_AKAv1MD5(WwwAuthenticate www_authenticate,
                                     charstring username,
@@ -404,7 +414,7 @@
                        ts_Param("realm", f_sip_str_quote(g_pars.realm)),
                        ts_Param("qop", f_sip_str_quote("auth")),
                        ts_Param("algorithm", "AKAv1-MD5"),
-                       ts_Param("nonce", f_sip_str_quote(g_pars.nonce))
+                       ts_Param("nonce", 
f_sip_str_quote(f_nonce_from_rand_autn(g_pars.rand, g_pars.autn)))
                        /* "opaque not needed in IMS "*/
                };
                wwwAuthenticate := ts_WwwAuthenticate( { 
ts_Challenge_digestCln(digestCln) } )
diff --git a/asterisk/gen_links.sh b/asterisk/gen_links.sh
index 3c4495f..e42ffe3 100755
--- a/asterisk/gen_links.sh
+++ b/asterisk/gen_links.sh
@@ -7,7 +7,8 @@
 DIR=$BASEDIR/titan.Libraries.TCCUsefulFunctions/src
 FILES="TCCInterface_Functions.ttcn TCCConversion_Functions.ttcn 
TCCConversion.cc TCCInterface.cc TCCInterface_ip.h "
 FILES+="TCCOpenSecurity_Functions.ttcn TCCOpenSecurity.cc 
TCCOpenSecurity_Functions.hh "
-FILES+="TCCDateTime.cc TCCDateTime_Functions.ttcn"
+FILES+="TCCDateTime.cc TCCDateTime_Functions.ttcn "
+FILES+="TCCEncoding_Functions.ttcn TCCEncoding.cc " # Base64
 gen_links $DIR $FILES

 DIR=$BASEDIR/titan.TestPorts.Common_Components.Socket-API/src
diff --git a/asterisk/regen_makefile.sh b/asterisk/regen_makefile.sh
index 8f7eae9..f0c9bcb 100755
--- a/asterisk/regen_makefile.sh
+++ b/asterisk/regen_makefile.sh
@@ -14,6 +14,7 @@
        SDP_EncDec.cc
        SIPmsg_PT.cc
        TCCConversion.cc
+       TCCEncoding.cc
        TCCInterface.cc
        TCCOpenSecurity.cc
        TCCDateTime.cc

--
To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/36868?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-Change-Id: I2809eec496a1c2c2b5f6e3d5d3bb1c33a788bd58
Gerrit-Change-Number: 36868
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pes...@sysmocom.de>
Gerrit-MessageType: newchange

Reply via email to