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

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

laforge gerrit-no-reply at lists.osmocom.org
Mon Jun 21 16:26:09 UTC 2021


laforge has submitted this change. ( 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:

- 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
---
M bsc/BSC_Tests.ttcn
M bsc/MSC_ConnectionHandler.ttcn
M bsc/osmo-bsc.cfg
3 files changed, 20 insertions(+), 5 deletions(-)

Approvals:
  laforge: Looks good to me, approved
  pespin: Looks good to me, but someone else must approve
  Jenkins Builder: Verified



diff --git a/bsc/BSC_Tests.ttcn b/bsc/BSC_Tests.ttcn
index 719fce6..a2a7804 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 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 {
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: 6
Gerrit-Owner: neels <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-Reviewer: pespin <pespin at sysmocom.de>
Gerrit-CC: fixeria <vyanitskiy at sysmocom.de>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210621/894cbbf2/attachment.htm>


More information about the gerrit-log mailing list