bsc: improve encryption testing config TestHdlrEncrParams

Clean up: absorb pars.encr_exp_enc_alg into TestHdlrEncrParams as
pars.encr.alg_expect.

Remove the automagic encr alg choice from test procedures, instead put
all magic in the pars.encr configuration setup; like this all encr alg
values remain fixed through the tests, less confusing.

Add separate alg_chosen for BSSMAP: So far, we have only one algorithm
field for both the mask of permitted algorithms in the Encryption
Information IS and the Chosen Encryption Algorithm IE. However, in the
Chosen Enc Alg there must be only one bit set. Thus we cannot easily run
a test where more than one alg is permitted and where the BSSMAP Chosen
Enc Alg IE is involved.

We've recently come to realize that the Chosen Encryption Algorithm IE
may also be omitted from BSSMAP messages, in which case osmo-bsc should
still work. To be able to test BSSMAP messages with omitted Chosen
Encryption Algorithm, allow to set alg_chosen == omit.

Keep t_EncrParams() in a way that all current tests (that set only one
bit in alg_permitted) still run the same as they always did.

Add t_EncrParams2() for a proper template.
Add a convenience function to configure encryption testing.

Related: SYS#5839
Change-Id: I6590ecf4a146dbed494d9d72f5a79441877e9010
diff --git a/bsc/BSC_Tests.ttcn b/bsc/BSC_Tests.ttcn
index dadd5bf..69e187c 100644
--- a/bsc/BSC_Tests.ttcn
+++ b/bsc/BSC_Tests.ttcn
@@ -1673,10 +1673,12 @@
 	var template BSSMAP_IE_KC128 kc128 := omit;
 	if (ispresent(enc)) {
 		var TestHdlrEncrParams v_enc := valueof(enc);
-		encryptionInformation := valueof(ts_BSSMAP_IE_EncrInfo(v_enc.enc_key, v_enc.enc_alg));
-		chosenEncryptionAlgorithm := valueof(
-			ts_BSSMAP_IE_ChosenEncryptionAlgorithm(int2oct(enum2int(
-				f_cipher_mode_bssmap_to_rsl(v_enc.enc_alg)), 1)));
+		encryptionInformation := valueof(ts_BSSMAP_IE_EncrInfo(v_enc.enc_key, v_enc.enc_alg_permitted));
+		if (ispresent(v_enc.enc_alg_chosen)) {
+			chosenEncryptionAlgorithm := valueof(
+				ts_BSSMAP_IE_ChosenEncryptionAlgorithm(int2oct(enum2int(
+					f_cipher_mode_bssmap_to_rsl(v_enc.enc_alg_chosen)), 1)));
+		}
 		if (ispresent(v_enc.enc_kc128)) {
 			kc128 := ts_BSSMAP_IE_Kc128(v_enc.enc_kc128);
 		}
@@ -3781,8 +3783,7 @@
 	var MSC_ConnHdlr vc_conn;
 	var TestHdlrParams pars := f_gen_test_hdlr_pars();
 
-	pars.encr := valueof(t_EncrParams('05'O, f_rnd_octstring(8))); /* A5/0 and A5/2 (0x01|0x04)*/
-	pars.encr_exp_enc_alg := '04'O; /* A5/2 */
+	pars.encr := f_encr_params('05'O, '04'O); /* A5/0 and A5/2 (0x01|0x04)*/
 
 	f_init(1, true);
 	f_vty_encryption_a5("0 1 2 3");
@@ -3797,8 +3798,7 @@
 	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 */
+	pars.encr := f_encr_params('06'O, '02'O); /* A5/1 and A5/2 (0x02|0x04)*/
 
 	f_init(1, true);
 	f_vty_encryption_a5("1 2");
@@ -6108,27 +6108,27 @@
 	f_shutdown_helper();
 }
 
-function f_tc_ho_into_this_bsc_a5(OCT1 encr_alg) runs on test_CT {
+function f_tc_ho_into_this_bsc_a5(TestHdlrEncrParams encr) runs on test_CT {
 	var TestHdlrParams pars := f_gen_test_hdlr_pars();
-	pars.encr := valueof(t_EncrParams(encr_alg, f_rnd_octstring(8), f_rnd_octstring(16)));
+	pars.encr := encr;
 	f_tc_ho_into_this_bsc_main(pars);
 	f_shutdown_helper();
 }
 
 testcase TC_ho_into_this_bsc_a5_0() runs on test_CT {
-	f_tc_ho_into_this_bsc_a5('01'O);
+	f_tc_ho_into_this_bsc_a5(f_encr_params('01'O));
 }
 
 testcase TC_ho_into_this_bsc_a5_1() runs on test_CT {
-	f_tc_ho_into_this_bsc_a5('02'O);
+	f_tc_ho_into_this_bsc_a5(f_encr_params('02'O));
 }
 
 testcase TC_ho_into_this_bsc_a5_3() runs on test_CT {
-	f_tc_ho_into_this_bsc_a5('08'O);
+	f_tc_ho_into_this_bsc_a5(f_encr_params('08'O));
 }
 
 testcase TC_ho_into_this_bsc_a5_4() runs on test_CT {
-	f_tc_ho_into_this_bsc_a5('10'O);
+	f_tc_ho_into_this_bsc_a5(f_encr_params('10'O));
 }
 
 testcase TC_ho_into_this_bsc_tla_v6() runs on test_CT {