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
This commit is contained in:
Oliver Smith 2021-07-09 08:45:51 +02:00 committed by laforge
parent 26a3db7d70
commit 1dff88d369
3 changed files with 36 additions and 3 deletions

View File

@ -3351,6 +3351,22 @@ testcase TC_ciph_mode_a5_1() runs on test_CT {
vc_conn.done;
f_shutdown_helper();
}
/* OS#4975: verify that A5/1 is preferred over A5/2 */
testcase TC_ciph_mode_a5_2_1() runs on test_CT {
var MSC_ConnHdlr vc_conn;
var TestHdlrParams pars := f_gen_test_hdlr_pars();
pars.encr := valueof(t_EncrParams('06'O, f_rnd_octstring(8))); /* A5/1 and A5/2 (0x02|0x04)*/
pars.encr_exp_enc_alg := '02'O; /* A5/1 */
f_init(1, true);
f_vty_encryption_a5("1 2");
f_sleep(1.0);
vc_conn := f_start_handler(refers(f_tc_ciph_mode_a5), pars);
vc_conn.done;
f_vty_encryption_a5_reset();
f_shutdown_helper();
}
testcase TC_ciph_mode_a5_3() runs on test_CT {
var MSC_ConnHdlr vc_conn;
var TestHdlrParams pars := f_gen_test_hdlr_pars();
@ -9228,6 +9244,7 @@ control {
execute( TC_assignment_fr_a5_not_sup() );
execute( TC_ciph_mode_a5_0() );
execute( TC_ciph_mode_a5_1() );
execute( TC_ciph_mode_a5_2_1() );
execute( TC_ciph_mode_a5_3() );
execute( TC_ciph_mode_a5_4() );

View File

@ -581,6 +581,7 @@ type record TestHdlrParams {
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 @@ template (value) TestHdlrParams t_def_TestHdlrPars := {
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(OCT1 alg_bssmap) return RSL_AlgId
}
}
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 @@ function f_verify_encr_info(RSL_Message rsl) runs on MSC_ConnHdlr {
/* 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 @@ runs on MSC_ConnHdlr {
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 @@ private function f_check_chan_act(AssignmentState st, RSL_Message chan_act) runs
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;

View File

@ -54,6 +54,7 @@
<testcase classname='BSC_Tests' name='TC_assignment_fr_a5_not_sup' time='MASKED'/>
<testcase classname='BSC_Tests' name='TC_ciph_mode_a5_0' time='MASKED'/>
<testcase classname='BSC_Tests' name='TC_ciph_mode_a5_1' time='MASKED'/>
<testcase classname='BSC_Tests' name='TC_ciph_mode_a5_2_1' time='MASKED'/>
<testcase classname='BSC_Tests' name='TC_ciph_mode_a5_3' time='MASKED'/>
<testcase classname='BSC_Tests' name='TC_ciph_mode_a5_4' time='MASKED'/>
<testcase classname='BSC_Tests' name='TC_assignment_codec_fr' time='MASKED'/>