Change in osmo-ttcn3-hacks[master]: bsc: reduce args to f_cipher_mode()

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/+/24668 )

Change subject: bsc: reduce args to f_cipher_mode()
......................................................................

bsc: reduce args to f_cipher_mode()

Instead of passing each part individually, simply pass the entire
TestHdlrEncrParams to f_cipher_mode().

Preparation for A5/4.

Add the kc128 to TestHdlrEncrParams instead of a function arg. kc128 is
so far unused, but will be used in an upcoming patch adding A5/4.

Related: SYS#5324
Change-Id: I2cb8282e55436da5ae64ab569df87d5d5a0dd2f0
---
M bsc/BSC_Tests.ttcn
M bsc/MSC_ConnectionHandler.ttcn
2 files changed, 14 insertions(+), 12 deletions(-)

Approvals:
  neels: Looks good to me, approved
  dexter: 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 38e591c..719fce6 100644
--- a/bsc/BSC_Tests.ttcn
+++ b/bsc/BSC_Tests.ttcn
@@ -3452,7 +3452,7 @@
 	}
 
 	/* Start ciphering, expect Cipher Mode Reject */
-	f_cipher_mode(g_pars.encr.enc_alg, g_pars.encr.enc_key, exp_fail := true);
+	f_cipher_mode(g_pars.encr, exp_fail := true);
 }
 testcase TC_assignment_fr_a5_not_sup() runs on test_CT {
 	var TestHdlrParams pars := f_gen_test_hdlr_pars();
@@ -6776,7 +6776,7 @@
 		/* start ciphering, if requested */
 		if (ispresent(g_pars.encr)) {
 			f_logp(BSCVTY, "start ciphering");
-			f_cipher_mode(g_pars.encr.enc_alg, g_pars.encr.enc_key);
+			f_cipher_mode(g_pars.encr);
 		}
 	}
 
diff --git a/bsc/MSC_ConnectionHandler.ttcn b/bsc/MSC_ConnectionHandler.ttcn
index a4f1f51..8e915ac 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 {
@@ -711,25 +713,25 @@
 	}
 }
 
-function f_cipher_mode(OCT1 alg, OCT8 key, template OCT16 kc128 := omit, boolean exp_fail := false)
+function f_cipher_mode(TestHdlrEncrParams enc, boolean exp_fail := false)
 runs on MSC_ConnHdlr {
 	var PDU_BSSAP bssap;
 	var RSL_Message rsl;
 	var RSL_AlgId alg_rsl;
 
-	if (isvalue(kc128)) {
-		BSSAP.send(ts_BSSMAP_CipherModeCmdKc128(alg, key, valueof(kc128)));
+	if (isvalue(enc.enc_kc128)) {
+		BSSAP.send(ts_BSSMAP_CipherModeCmdKc128(enc.enc_alg, enc.enc_key, valueof(enc.enc_kc128)));
 	} else {
-		BSSAP.send(ts_BSSMAP_CipherModeCmd(alg, key));
+		BSSAP.send(ts_BSSMAP_CipherModeCmd(enc.enc_alg, enc.enc_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);
+	alg_rsl := f_chipher_mode_bssmap_to_rsl(enc.enc_alg);
 
 	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, enc.enc_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)) {
@@ -1147,7 +1149,7 @@
 
 	/* start ciphering, if requested */
 	if (ispresent(g_pars.encr)) {
-		f_cipher_mode(g_pars.encr.enc_alg, g_pars.encr.enc_key);
+		f_cipher_mode(g_pars.encr);
 	}
 
 	/* bail out early if no assignment requested */

-- 
To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/24668
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: I2cb8282e55436da5ae64ab569df87d5d5a0dd2f0
Gerrit-Change-Number: 24668
Gerrit-PatchSet: 5
Gerrit-Owner: neels <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter <pmaier at sysmocom.de>
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-Reviewer: neels <nhofmeyr at sysmocom.de>
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/32676e83/attachment.htm>


More information about the gerrit-log mailing list