Change in osmo-ttcn3-hacks[master]: bsc: implement ttcn API and cfg for A5/4

neels gerrit-no-reply at lists.osmocom.org
Tue Jun 15 13:19:07 UTC 2021


neels has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/24669 )


Change subject: bsc: implement ttcn API and cfg for A5/4
......................................................................

bsc: implement ttcn API and cfg for A5/4

Implement tools for OsmoBSC a5/4 support testing:

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

Related: SYS#5324
Change-Id: Ifa48a8498dde7d04fb29f497013bdb5a1e5f3597
---
M bsc/BSC_Tests.ttcn
M bsc/MSC_ConnectionHandler.ttcn
M bsc/osmo-bsc.cfg
3 files changed, 25 insertions(+), 8 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-ttcn3-hacks refs/changes/69/24669/1

diff --git a/bsc/BSC_Tests.ttcn b/bsc/BSC_Tests.ttcn
index e3720e5..b9e6bfd 100644
--- a/bsc/BSC_Tests.ttcn
+++ b/bsc/BSC_Tests.ttcn
@@ -3461,7 +3461,7 @@
 	f_init(1, true);
 	f_sleep(1.0);
 
-	pars.encr := valueof(t_EncrParams('20'O, f_rnd_octstring(8)));
+	pars.encr := valueof(t_EncrParams('20'O, f_rnd_octstring(8), f_rnd_octstring(16)));
 	vc_conn := f_start_handler(refers(f_TC_assignment_a5_not_sup), pars);
 	vc_conn.done;
 	f_shutdown_helper();
diff --git a/bsc/MSC_ConnectionHandler.ttcn b/bsc/MSC_ConnectionHandler.ttcn
index c266c19..799d41e 100644
--- a/bsc/MSC_ConnectionHandler.ttcn
+++ b/bsc/MSC_ConnectionHandler.ttcn
@@ -544,12 +544,14 @@
 
 type record TestHdlrEncrParams {
 	OCT1		enc_alg,
-	octetstring	enc_key
+	octetstring	enc_key,
+	octetstring	enc_kc128 optional
 };
 
-template (value) TestHdlrEncrParams t_EncrParams(OCT1 alg, octetstring key) := {
+template (value) TestHdlrEncrParams t_EncrParams(OCT1 alg, octetstring key, template (omit) octetstring kc128 := omit) := {
 	enc_alg := alg,
-	enc_key := key
+	enc_key := key,
+	enc_kc128 := kc128
 }
 
 type record TestHdlrParamsLcls {
@@ -714,6 +716,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)));
@@ -725,9 +728,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, 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)) {
@@ -838,8 +848,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 {
diff --git a/bsc/osmo-bsc.cfg b/bsc/osmo-bsc.cfg
index b64a63d..7b0fa2a 100644
--- a/bsc/osmo-bsc.cfg
+++ b/bsc/osmo-bsc.cfg
@@ -69,7 +69,7 @@
 network
  network country code 1
  mobile network code 1
- encryption a5 0 1 3
+ encryption a5 0 1 3 4
  neci 1
  paging any use tch 0
  handover 1

-- 
To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/24669
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-Change-Id: Ifa48a8498dde7d04fb29f497013bdb5a1e5f3597
Gerrit-Change-Number: 24669
Gerrit-PatchSet: 1
Gerrit-Owner: neels <nhofmeyr at sysmocom.de>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210615/13940f02/attachment.htm>


More information about the gerrit-log mailing list