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

bsc: Verify correct encryption n RSL CHAN_ACT during assignment

Change-Id: Iff77586ea39da32df570048b1d83f5a0edb5a533
---
M bsc/BSC_Tests.ttcn
M bsc/MSC_ConnectionHandler.ttcn
2 files changed, 41 insertions(+), 1 deletion(-)


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

diff --git a/bsc/BSC_Tests.ttcn b/bsc/BSC_Tests.ttcn
index b3c7c61..14f3724 100644
--- a/bsc/BSC_Tests.ttcn
+++ b/bsc/BSC_Tests.ttcn
@@ -1443,7 +1443,6 @@
        ass_cmd.pdu.bssmap.assignmentRequest.codecList := 
valueof(ts_BSSMAP_IE_CodecList({ts_CodecFR}));
 
        f_establish_fully(ass_cmd, exp_compl);
-       f_cipher_mode(g_pars.encr.enc_alg, g_pars.encr.enc_key);
 }
 testcase TC_assignment_fr_a5_0() runs on test_CT {
        var MSC_ConnHdlr vc_conn;
diff --git a/bsc/MSC_ConnectionHandler.ttcn b/bsc/MSC_ConnectionHandler.ttcn
index c1ff963..fe524dc 100644
--- a/bsc/MSC_ConnectionHandler.ttcn
+++ b/bsc/MSC_ConnectionHandler.ttcn
@@ -544,6 +544,37 @@
        modify_done := false
 }
 
+private template RSL_IE_Body tr_EncrInfo(template RSL_AlgId alg, template 
octetstring key) := {
+       encr_info := {
+               len := ?,
+               alg_id := alg,
+               key := key
+       }
+}
+
+/* ensure the RSL CHAN ACT (during assignment) contains values we expect 
depending on test case */
+private function f_check_chan_act(AssignmentState st, RSL_Message chan_act) 
runs on MSC_ConnHdlr {
+       var RSL_IE_Body encr_info;
+       if (ispresent(g_pars.encr) and g_pars.encr.enc_alg != '01'O) {
+               if (not f_rsl_find_ie(chan_act, RSL_IE_ENCR_INFO, encr_info)) {
+                       setverdict(fail, "Missing Encryption IE in CHAN ACT");
+               } else {
+                       var RSL_AlgId alg := 
f_chipher_mode_bssmap_to_rsl(g_pars.encr.enc_alg);
+                       if (not match(encr_info, tr_EncrInfo(alg, 
g_pars.encr.enc_key))) {
+                               setverdict(fail, "Wrong Encryption IE in CHAN 
ACT");
+                       }
+               }
+       } else {
+               if (f_rsl_find_ie(chan_act, RSL_IE_ENCR_INFO, encr_info)) {
+                       if (encr_info.encr_info.alg_id != RSL_ALG_ID_A5_0) {
+                               setverdict(fail, "Unexpected Encryption in CHAN 
ACT");
+                       }
+               }
+       }
+       /* FIXME: validate RSL_IE_ACT_TYPE, RSL_IE_CHAN_MODE, 
RSL_IE_CHAN_IDENT, RSL_IE_BS_POWER,
+        * RSL_IE_MS_POWER, RSL_IE_TIMING_ADVANCE */
+}
+
 altstep as_assignment(inout AssignmentState st) runs on MSC_ConnHdlr {
        var RSL_Message rsl;
        [not st.rr_ass_cmpl_seen] RSL.receive(tr_RSL_DATA_REQ(g_chan_nr)) -> 
value rsl {
@@ -566,6 +597,10 @@
                        st.old_chan_nr := g_chan_nr;
                        g_chan_nr := new_chan_nr;
                        st.rr_ass_cmpl_seen := true;
+                       /* obtain channel activation from RSL_Emulation for new 
channel */
+                       var RSL_Message chan_act := 
f_rslem_get_last_act(RSL_PROC, 0, g_chan_nr);
+                       /* check it (e.g. for correct ciphering parameters) */
+                       f_check_chan_act(st, chan_act);
                        repeat;
                } else {
                        setverdict(fail, "Unexpected L3 received", l3);
@@ -666,6 +701,12 @@
        f_create_chan_and_exp();
        /* we should now have a COMPL_L3 at the MSC */
        BSSAP.receive(tr_BSSMAP_ComplL3);
+
+       /* start ciphering, if requested */
+       if (ispresent(g_pars.encr)) {
+               f_cipher_mode(g_pars.encr.enc_alg, g_pars.encr.enc_key);
+       }
+
        f_create_mgcp_expect(mgcpcrit);
        BSSAP.send(ass_cmd);
 

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Iff77586ea39da32df570048b1d83f5a0edb5a533
Gerrit-PatchSet: 1
Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-Owner: Harald Welte <lafo...@gnumonks.org>

Reply via email to