msc: TC_lu_imsi_auth_tmsi_encr_13_13
Add a first test for encryption (cipher mode command/complete)
Change-Id: I8a8a5c55d87bb251896664679920b96f678673a0
diff --git a/library/BSSMAP_Templates.ttcn b/library/BSSMAP_Templates.ttcn
index 5331505..33c370e 100644
--- a/library/BSSMAP_Templates.ttcn
+++ b/library/BSSMAP_Templates.ttcn
@@ -367,6 +367,14 @@
key := kc
}
+template BSSMAP_IE_EncryptionInformation tr_BSSMAP_IE_EncrInfo(template OCT8 kc := ?, template OCT1 algs := ?) := {
+ elementIdentifier := '0A'O,
+ lengthIndicator := ?, /* overwritten */
+ permittedAlgorithms := algs,
+ key := kc
+}
+
+
template (value) BSSMAP_IE_CircuitIdentityCode ts_BSSMAP_IE_CIC(uint11_t span, uint5_t ts) := {
elementIdentifier := '01'O, /* overwritten */
@@ -748,6 +756,37 @@
}
}
+template PDU_BSSAP tr_BSSMAP_CipherModeCmd(template OCT1 alg, template OCT8 key)
+modifies tr_BSSAP_BSSMAP := {
+ pdu := {
+ bssmap := {
+ cipherModeCommand := {
+ messageType := '53'O,
+ layer3HeaderInfo := *,
+ encryptionInformation := tr_BSSMAP_IE_EncrInfo(key, alg),
+ cipherResponseMode := *,
+ kC128 := *
+ }
+ }
+ }
+}
+
+template PDU_BSSAP ts_BSSMAP_CipherModeCompl(OCT1 alg)
+modifies ts_BSSAP_BSSMAP := {
+ pdu := {
+ bssmap := {
+ cipherModeComplete := {
+ messageType := '55'O,
+ layer3MessageContents := omit,
+ chosenEncryptionAlgorithm := {
+ elementIdentifier := '2C'O,
+ algorithmIdentifier := alg
+ }
+ }
+ }
+ }
+}
+
template PDU_BSSAP tr_BSSMAP_CipherModeCompl(template OCT1 alg := ?) modifies tr_BSSAP_BSSMAP := {
pdu := {
bssmap := {
diff --git a/msc_tests/BSC_ConnectionHandler.ttcn b/msc_tests/BSC_ConnectionHandler.ttcn
index 330f25a..656fb4e 100644
--- a/msc_tests/BSC_ConnectionHandler.ttcn
+++ b/msc_tests/BSC_ConnectionHandler.ttcn
@@ -33,7 +33,8 @@
hexstring msisdn,
OCT4 tmsi optional,
BSSMAP_IE_ClassmarkInformationType2 cm2,
- BSSMAP_IE_ClassmarkInformationType3 cm3 optional
+ BSSMAP_IE_ClassmarkInformationType3 cm3 optional,
+ octetstring kc optional
};
@@ -161,10 +162,12 @@
return vec;
}
-function f_perform_lu(boolean expect_auth, boolean expect_tmsi, boolean send_early_cm)
+function f_perform_lu(boolean expect_auth, boolean expect_tmsi, boolean send_early_cm,
+ boolean expect_ciph := false)
runs on BSC_ConnHdlr {
var PDU_ML3_MS_NW l3_lu := f_build_lu_imsi(g_pars.imsi)
var PDU_DTAP_MT dtap_mt;
+ var AuthVector vec;
/* tell GSUP dispatcher to send this IMSI to us */
f_create_gsup_expect(hex2str(g_pars.imsi));
@@ -177,7 +180,7 @@
}
if (expect_auth) {
- var AuthVector vec := f_gen_auth_vec_2g();
+ vec := f_gen_auth_vec_2g();
var GSUP_IE auth_tuple := valueof(ts_GSUP_IE_AuthTuple2G(vec.rand, vec.sres, vec.kc));
GSUP.receive(tr_GSUP_SAI_REQ(g_pars.imsi));
GSUP.send(ts_GSUP_SAI_RES(g_pars.imsi, auth_tuple));
@@ -186,6 +189,12 @@
BSSAP.send(ts_PDU_DTAP_MO(ts_ML3_MT_MM_AUTH_RESP_2G(vec.sres)));
}
+ if (expect_ciph) {
+ BSSAP.receive(tr_BSSMAP_CipherModeCmd(?, vec.kc));
+ g_pars.kc := vec.kc;
+ BSSAP.send(ts_BSSMAP_CipherModeCompl('02'O));
+ }
+
/* Expect MSC to perform LU with HLR */
GSUP.receive(tr_GSUP_UL_REQ(g_pars.imsi));
GSUP.send(ts_GSUP_ISD_REQ(g_pars.imsi, g_pars.msisdn));
diff --git a/msc_tests/MSC_Tests.ttcn b/msc_tests/MSC_Tests.ttcn
index 367cd79..74d1b93 100644
--- a/msc_tests/MSC_Tests.ttcn
+++ b/msc_tests/MSC_Tests.ttcn
@@ -331,7 +331,8 @@
msisdn := f_gen_msisdn(imsi_suffix),
tmsi := omit,
cm2 := valueof(ts_CM2_default),
- cm3 := omit
+ cm3 := omit,
+ kc := omit
};
vc_conn := BSC_ConnHdlr.create(id);
@@ -1087,6 +1088,21 @@
vc_conn.done;
}
+private function f_tc_lu_imsi_auth_tmsi_encr_13_13(charstring id, BSC_ConnHdlrPars pars) runs on BSC_ConnHdlr {
+ g_pars := pars;
+ f_perform_lu(true, true, true, true);
+}
+testcase TC_lu_imsi_auth_tmsi_encr_13_13() runs on MTC_CT {
+ var BSC_ConnHdlr vc_conn;
+ f_init();
+ f_vty_config(MSCVTY, "network", "authentication required");
+ f_vty_config(MSCVTY, "msc", "assign-tmsi");
+ f_vty_config(MSCVTY, "network", "encryption a5 1 3");
+
+ vc_conn := f_start_handler(refers(f_tc_lu_imsi_auth_tmsi_encr_13_13), testcasename(), 24);
+ vc_conn.done;
+}
+
/* TODO:
* continue to send repeated MO signalling messages to keep channel open: does MSC tmeout?