bsc: add TC_ciph_mode_a5_2_1
Verify that A5/1 is preferred over A5/2. Add encr_exp_enc_alg to
MSC_ConnectionHandler:TestHdlrEncrParams, so the expected encryption
algorithm can be different from what the MSC tells the BSC about the
capabilities of MS.
Related: OS#4975
Change-Id: I688d056bcfe73f7846f908a28f4621f944cf2178
diff --git a/bsc/MSC_ConnectionHandler.ttcn b/bsc/MSC_ConnectionHandler.ttcn
index 94ec2b9..fc12307 100644
--- a/bsc/MSC_ConnectionHandler.ttcn
+++ b/bsc/MSC_ConnectionHandler.ttcn
@@ -581,6 +581,7 @@
RSL_IE_Body expect_mr_conf_ie optional, /* typically present for AMR codecs */
bitstring expect_mr_s0_s7 optional, /* typically present for AMR codecs */
TestHdlrEncrParams encr optional,
+ OCT1 encr_exp_enc_alg optional, /* if set, expect a different enc_alg than encr.enc_alg */
TestHdlrParamsLcls lcls,
SCCP_PAR_Address sccp_addr_msc optional,
SCCP_PAR_Address sccp_addr_bsc optional,
@@ -610,6 +611,7 @@
expect_mr_conf_ie := omit,
expect_mr_s0_s7 := omit,
encr := omit,
+ encr_exp_enc_alg := omit,
lcls := {
gcr := omit,
cfg := omit,
@@ -713,6 +715,19 @@
}
}
+function f_cipher_mode_bssmap_to_rsl_exp_enc_alg() runs on MSC_ConnHdlr return RSL_AlgId
+{
+ var OCT1 enc_alg;
+
+ if (ispresent(g_pars.encr_exp_enc_alg)) {
+ enc_alg := g_pars.encr_exp_enc_alg;
+ } else {
+ enc_alg := g_pars.encr.enc_alg;
+ }
+
+ return f_cipher_mode_bssmap_to_rsl(enc_alg);
+}
+
function f_verify_encr_info(RSL_Message rsl) runs on MSC_ConnHdlr {
var RSL_IE_Body encr_info;
var RSL_AlgId alg_rsl;
@@ -731,7 +746,7 @@
/* RSL uses a different representation of the encryption algorithm,
* so we need to convert first */
- alg_rsl := f_cipher_mode_bssmap_to_rsl(g_pars.encr.enc_alg);
+ alg_rsl := f_cipher_mode_bssmap_to_rsl_exp_enc_alg();
if (alg_rsl == RSL_ALG_ID_A5_4 and ispresent(g_pars.encr.enc_kc128)) {
expect_kc := g_pars.encr.enc_kc128;
@@ -797,7 +812,7 @@
Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Unexpected Cipher Mode Complete");
} else {
setverdict(pass);
- var RSL_AlgId alg_rsl := f_cipher_mode_bssmap_to_rsl(g_pars.encr.enc_alg);
+ var RSL_AlgId alg_rsl := f_cipher_mode_bssmap_to_rsl_exp_enc_alg();
if (oct2int(bssap.pdu.bssmap.cipherModeComplete.chosenEncryptionAlgorithm.algorithmIdentifier) != enum2int(alg_rsl)) {
setverdict(fail, "Unexpected Encryption Algorithm ID in BSSMAP Cipher Mode Complete");
}
@@ -897,7 +912,7 @@
if (not f_rsl_find_ie(chan_act, RSL_IE_ENCR_INFO, encr_info)) {
Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Missing Encryption IE in CHAN ACT");
} else {
- var RSL_AlgId alg := f_cipher_mode_bssmap_to_rsl(g_pars.encr.enc_alg);
+ var RSL_AlgId alg := f_cipher_mode_bssmap_to_rsl_exp_enc_alg();
var octetstring expect_key;
if (alg == RSL_ALG_ID_A5_4) {
expect_key := g_pars.encr.enc_kc128;