bsc: f_cipher_mode(): fail quicker on key mismatch

Related: SYS#5324
Change-Id: Ia79779f4229da4a5af271235a5e82c6fd59ea3a2
diff --git a/bsc/MSC_ConnectionHandler.ttcn b/bsc/MSC_ConnectionHandler.ttcn
index ec1f806..0d46bc6 100644
--- a/bsc/MSC_ConnectionHandler.ttcn
+++ b/bsc/MSC_ConnectionHandler.ttcn
@@ -739,9 +739,19 @@
 
 	alt {
 	/* RSL/UE Side */
-	[] RSL.receive(tr_RSL_ENCR_CMD(g_chan_nr, ?, alg_rsl, expect_kc)) -> value rsl {
+	[] RSL.receive(tr_RSL_ENCR_CMD(g_chan_nr, ?, alg_rsl, ?)) -> 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);
+
+		var RSL_IE_Body encr_info;
+		if (not f_rsl_find_ie(rsl, RSL_IE_ENCR_INFO, encr_info)) {
+			Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Missing Encryption IE in RSL ENCR CMD");
+		} else {
+			if (not match(encr_info, tr_EncrInfo(alg_rsl, expect_kc))) {
+				Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
+							"Unexpected Kc in Encryption IE in RSL ENCR CMD");
+			}
+		}
 		if (ischosen(l3.msgs.rrm.cipheringModeCommand)) {
 			f_rsl_reply(ts_RRM_CiphModeCompl, rsl);
 		}