[PATCH] osmo-msc[master]: fix BSSMAP Cipher Mode Cmd: properly set permitted algorithms

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/.

Neels Hofmeyr gerrit-no-reply at lists.osmocom.org
Thu Dec 14 20:36:47 UTC 2017


fix BSSMAP Cipher Mode Cmd: properly set permitted algorithms

The bit shifting is performed in gsm0808_enc_encrypt_info(), and must not be
done when populating the gsm0808_encrypt_info struct.

Provide vlr_ciph_to_gsm0808_alg_id() to translate the enum vlr_ciph to the
GSM0808_* constants we need to put in the gsm0808_encrypt_info struct instead.

Change-Id: If75f95e8a5cc8b9979610ce6d746c1f0073ee39a
---
M include/osmocom/msc/vlr.h
M src/libmsc/a_iface.c
2 files changed, 17 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-msc refs/changes/76/5376/2

diff --git a/include/osmocom/msc/vlr.h b/include/osmocom/msc/vlr.h
index 9e6b12c..640d35b 100644
--- a/include/osmocom/msc/vlr.h
+++ b/include/osmocom/msc/vlr.h
@@ -7,6 +7,7 @@
 #include <osmocom/gsm/protocol/gsm_23_003.h>
 #include <osmocom/gsm/protocol/gsm_04_08_gprs.h>
 #include <osmocom/gsm/gsm23003.h>
+#include <osmocom/gsm/gsm0808.h>
 #include <osmocom/msc/gsm_data.h>
 // for GSM_NAME_LENGTH
 #include <osmocom/msc/gsm_subscriber.h>
@@ -172,6 +173,21 @@
 	VLR_CIPH_A5_3, /*< A5/3, 'new secure' encryption */
 };
 
+static inline uint8_t vlr_ciph_to_gsm0808_alg_id(enum vlr_ciph ciph)
+{
+	switch (ciph) {
+	default:
+	case VLR_CIPH_NONE:
+		return GSM0808_ALG_ID_A5_0;
+	case VLR_CIPH_A5_1:
+		return GSM0808_ALG_ID_A5_1;
+	case VLR_CIPH_A5_2:
+		return GSM0808_ALG_ID_A5_2;
+	case VLR_CIPH_A5_3:
+		return GSM0808_ALG_ID_A5_3;
+	}
+}
+
 struct vlr_ops {
 	/* encode + transmit an AUTH REQ towards the MS.
 	 * \param[in] at  auth tuple providing rand, key_seq and autn.
diff --git a/src/libmsc/a_iface.c b/src/libmsc/a_iface.c
index 6f9bdd0..e264aee 100644
--- a/src/libmsc/a_iface.c
+++ b/src/libmsc/a_iface.c
@@ -193,7 +193,7 @@
 	if (include_imeisv)
 		crm_ptr = &crm;
 
-	ei.perm_algo[0] = (uint8_t) (1 << cipher);
+	ei.perm_algo[0] = vlr_ciph_to_gsm0808_alg_id(cipher);
 	ei.perm_algo_len = 1;
 
 	msg_resp = gsm0808_create_cipher(&ei, crm_ptr);

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

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: If75f95e8a5cc8b9979610ce6d746c1f0073ee39a
Gerrit-PatchSet: 2
Gerrit-Project: osmo-msc
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder



More information about the gerrit-log mailing list