asterisk: Compute nonce from rand and autn params

Change-Id: I2809eec496a1c2c2b5f6e3d5d3bb1c33a788bd58
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) } )