bsc: implement ttcn API and cfg for A5/4

Implement tools for OsmoBSC a5/4 support testing:

- in f_cipher_mode() and f_check_chan_act(), expect Kc128 key as
  appropriate, using recently added g_pars.encr.enc_kc128
- osmo-bsc.cfg: allow a5/4

Related: SYS#5324
Change-Id: Ifa48a8498dde7d04fb29f497013bdb5a1e5f3597
diff --git a/bsc/MSC_ConnectionHandler.ttcn b/bsc/MSC_ConnectionHandler.ttcn
index 8e915ac..ec1f806 100644
--- a/bsc/MSC_ConnectionHandler.ttcn
+++ b/bsc/MSC_ConnectionHandler.ttcn
@@ -718,6 +718,7 @@
 	var PDU_BSSAP bssap;
 	var RSL_Message rsl;
 	var RSL_AlgId alg_rsl;
+	var octetstring expect_kc;
 
 	if (isvalue(enc.enc_kc128)) {
 		BSSAP.send(ts_BSSMAP_CipherModeCmdKc128(enc.enc_alg, enc.enc_key, valueof(enc.enc_kc128)));
@@ -729,9 +730,16 @@
 	 * so we need to convert first */
 	alg_rsl := f_chipher_mode_bssmap_to_rsl(enc.enc_alg);
 
+	if (alg_rsl == RSL_ALG_ID_A5_4 and ispresent(enc.enc_kc128)) {
+		expect_kc := enc.enc_kc128;
+	} else {
+		expect_kc := enc.enc_key;
+	}
+	log("for encryption algo ", alg_rsl, " expect kc = ", expect_kc);
+
 	alt {
 	/* RSL/UE Side */
-	[] RSL.receive(tr_RSL_ENCR_CMD(g_chan_nr, ?, alg_rsl, enc.enc_key)) -> value rsl {
+	[] RSL.receive(tr_RSL_ENCR_CMD(g_chan_nr, ?, alg_rsl, expect_kc)) -> value rsl {
 		var PDU_ML3_NW_MS l3 := dec_PDU_ML3_NW_MS(rsl.ies[3].body.l3_info.payload);
 		log("Rx L3 from net: ", l3);
 		if (ischosen(l3.msgs.rrm.cipheringModeCommand)) {
@@ -842,8 +850,15 @@
 			Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Missing Encryption IE in CHAN ACT");
 		} else {
 			var RSL_AlgId alg := f_chipher_mode_bssmap_to_rsl(g_pars.encr.enc_alg);
-			if (not match(encr_info, tr_EncrInfo(alg, g_pars.encr.enc_key))) {
-				Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Wrong Encryption IE in CHAN ACT");
+			var octetstring expect_key;
+			if (alg == RSL_ALG_ID_A5_4) {
+				expect_key := g_pars.encr.enc_kc128;
+			} else {
+				expect_key := g_pars.encr.enc_key;
+			}
+			if (not match(encr_info, tr_EncrInfo(alg, expect_key))) {
+				Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
+							"Unexpected Kc in Encryption IE in RSL ENCR CMD");
 			}
 		}
 	} else {