[PATCH] osmo-ttcn3-hacks[master]: msc: convert bssmap chipher to rsl chiper representation

dexter gerrit-no-reply at lists.osmocom.org
Wed Feb 7 17:46:47 UTC 2018


Review at  https://gerrit.osmocom.org/6314

msc: convert bssmap chipher to rsl chiper representation

The representation of the chiphering algorithm is different bssmap
and RSL. BSSMAP uses a bitmask and RSL a numeric value. For A50 and
A51 the values match up by coincidence, from A53 on they differ.

- Add a function to convert the BSSMAP representation to the RSL
  representation and use the converted value to set up the temlate
  for the expected RSL message

Change-Id: I274c1ff0b5636c48411f994f918e783b468cb3be
---
M bsc/MSC_ConnectionHandler.ttcn
1 file changed, 47 insertions(+), 1 deletion(-)


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

diff --git a/bsc/MSC_ConnectionHandler.ttcn b/bsc/MSC_ConnectionHandler.ttcn
index 5a645bd..51aebd2 100644
--- a/bsc/MSC_ConnectionHandler.ttcn
+++ b/bsc/MSC_ConnectionHandler.ttcn
@@ -323,19 +323,65 @@
 	f_rsl_send_l3(l3, link_id, chan_nr);
 }
 
+/* Convert the chipher representation on BSSMAP to the representation used on RSL */
+function f_chipher_mode_bssmap_to_rsl(OCT1 alg_bssmap) return OCT1
+{
+	/* A5 0 */
+	if (alg_bssmap == '01'O) {
+		return '01'O;
+	}
+	/* A5 1 */
+	else if (alg_bssmap == '02'O) {
+		return '02'O;
+	}
+	/* A5 2 */
+	else if (alg_bssmap == '04'O) {
+		return '03'O;
+	}
+	/* A5 3 */
+	else if (alg_bssmap == '08'O) {
+		return '04'O;
+	}
+	/* A5 4 */
+	else if (alg_bssmap == '10'O) {
+		return '05'O;
+	}
+	/* A5 5 */
+	else if (alg_bssmap == '20'O) {
+		return '06'O;
+	}
+	/* A5 6 */
+	else if (alg_bssmap == '40'O) {
+		return '07'O;
+	}
+	/* A5 7 */
+	else if (alg_bssmap == '80'O) {
+		return '08'O;
+	} else {
+		setverdict(fail, "Unexpected Encryption Algorithm");
+		return '00'O;
+	}
+}
+
 function f_cipher_mode(OCT1 alg, OCT8 key, template OCT16 kc128 := omit, boolean exp_fail := false)
 runs on MSC_ConnHdlr {
 	var PDU_BSSAP bssap;
 	var RSL_Message rsl;
+	var OCT1 alg_rsl;
 
 	if (isvalue(kc128)) {
 		BSSAP.send(ts_BSSMAP_CipherModeCmdKc128(alg, key, valueof(kc128)));
 	} else {
 		BSSAP.send(ts_BSSMAP_CipherModeCmd(alg, key));
 	}
+
+	/* RSL uses a different representation of the encryption algorithm,
+	 * so we need to convert first */
+	alg_rsl := f_chipher_mode_bssmap_to_rsl(alg);
+
 	alt {
 	/* RSL/UE Side */
-	[] RSL.receive(tr_RSL_ENCR_CMD(g_chan_nr, ?, alg, key)) -> value rsl {
+	[] RSL.receive(tr_RSL_ENCR_CMD(g_chan_nr, ?, alg_rsl, key)) -> 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)) {

-- 
To view, visit https://gerrit.osmocom.org/6314
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I274c1ff0b5636c48411f994f918e783b468cb3be
Gerrit-PatchSet: 1
Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-Owner: dexter <pmaier at sysmocom.de>


More information about the gerrit-log mailing list