summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2018-01-24 22:41:21 +0100
committerHarald Welte <laforge@gnumonks.org>2018-01-24 23:05:35 +0100
commit161142834ff57d9493072e2d9c9f35df90b37daa (patch)
treea617579d65cbd17850d73567acf9ab5deed0ab5c
parentc638f4dbe92065a798f5dd5692476210138dce0a (diff)
msc: TC_lu_imsi_auth_tmsi_encr_13_13
Add a first test for encryption (cipher mode command/complete) Change-Id: I8a8a5c55d87bb251896664679920b96f678673a0
-rw-r--r--library/BSSMAP_Templates.ttcn39
-rw-r--r--msc_tests/BSC_ConnectionHandler.ttcn15
-rw-r--r--msc_tests/MSC_Tests.ttcn18
3 files changed, 68 insertions, 4 deletions
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 @@ template (value) BSSMAP_IE_EncryptionInformation ts_BSSMAP_IE_EncrInfo(OCT8 kc,
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 @@ modifies ts_BSSAP_BSSMAP := {
}
}
+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 @@ type record BSC_ConnHdlrPars {
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 @@ function f_gen_auth_vec_2g() return AuthVector {
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 @@ runs on BSC_ConnHdlr {
}
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 @@ runs on BSC_ConnHdlr {
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 @@ function f_start_handler(void_fn fn, charstring id, integer imsi_suffix) runs on
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 @@ testcase TC_lu_auth_2G_fail() runs on MTC_CT {
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?