[MERGED] libosmocore[master]: Add function to check GMM encryptability

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

Harald Welte gerrit-no-reply at lists.osmocom.org
Thu Jul 7 12:55:46 UTC 2016


Harald Welte has submitted this change and it was merged.

Change subject: Add function to check GMM encryptability
......................................................................


Add function to check GMM encryptability

Check if particular GMM message can be encrypted according to 3GPP TS
24.008 § 4.7.1.2

Related: OS#1582
Change-Id: I7ad0e03c2c738d174dd6bc3453f332eeb8da1e7d
---
M include/osmocom/gsm/protocol/gsm_04_08.h
M src/gsm/gsm48.c
M src/gsm/libosmogsm.map
3 files changed, 28 insertions(+), 1 deletion(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/include/osmocom/gsm/protocol/gsm_04_08.h b/include/osmocom/gsm/protocol/gsm_04_08.h
index 074c258..e442c7f 100644
--- a/include/osmocom/gsm/protocol/gsm_04_08.h
+++ b/include/osmocom/gsm/protocol/gsm_04_08.h
@@ -6,7 +6,6 @@
 #include <osmocom/core/utils.h>
 #include <osmocom/core/endian.h>
 
-
 /* GSM TS 04.08  definitions */
 struct gsm_lchan;
 
@@ -925,6 +924,8 @@
 #define GSM48_PDISC_MASK	0x0f
 #define GSM48_PDISC_USSD	0x11
 
+bool gsm48_hdr_gmm_cipherable(const struct gsm48_hdr *hdr);
+
 static inline uint8_t gsm48_hdr_pdisc(const struct gsm48_hdr *hdr)
 {
 	/*
diff --git a/src/gsm/gsm48.c b/src/gsm/gsm48.c
index 8a46f76..b4740cf 100644
--- a/src/gsm/gsm48.c
+++ b/src/gsm/gsm48.c
@@ -35,6 +35,7 @@
 #include <osmocom/gsm/gsm_utils.h>
 #include <osmocom/gsm/protocol/gsm_04_08.h>
 #include <osmocom/gsm/protocol/gsm_08_58.h>
+#include <osmocom/gsm/protocol/gsm_04_08_gprs.h>
 
 const struct tlv_definition gsm48_att_tlvdef = {
 	.def = {
@@ -302,6 +303,30 @@
 	val = val / 10;
 }
 
+/*! \brief Checks is particular message is cipherable in A/Gb mode according to
+ *         3GPP TS 24.008 § 4.7.1.2
+ *  \param[in] hdr Message header
+ *  \return true if message can be encrypted, false otherwise
+ */
+bool gsm48_hdr_gmm_cipherable(const struct gsm48_hdr *hdr)
+{
+	switch(hdr->msg_type) {
+	case GSM48_MT_GMM_ATTACH_REQ:
+	case GSM48_MT_GMM_ATTACH_REJ:
+	case GSM48_MT_GMM_AUTH_CIPH_REQ:
+	case GSM48_MT_GMM_AUTH_CIPH_RESP:
+	case GSM48_MT_GMM_AUTH_CIPH_REJ:
+	case GSM48_MT_GMM_AUTH_CIPH_FAIL:
+	case GSM48_MT_GMM_ID_REQ:
+	case GSM48_MT_GMM_ID_RESP:
+	case GSM48_MT_GMM_RA_UPD_REQ:
+	case GSM48_MT_GMM_RA_UPD_REJ:
+		return false;
+	default:
+		return true;
+	}
+}
+
 /* Convert given mcc and mnc to BCD and write to *bcd_dst, which must be an
  * allocated buffer of (at least) 3 bytes length. */
 void gsm48_mcc_mnc_to_bcd(uint8_t *bcd_dst, uint16_t mcc, uint16_t mnc)
diff --git a/src/gsm/libosmogsm.map b/src/gsm/libosmogsm.map
index 19ebb5b..c68cf2a 100644
--- a/src/gsm/libosmogsm.map
+++ b/src/gsm/libosmogsm.map
@@ -124,6 +124,7 @@
 gsm48_cc_msg_name;
 gsm48_cc_state_name;
 gsm48_construct_ra;
+gsm48_hdr_gmm_cipherable;
 gsm48_decode_bcd_number;
 gsm48_decode_bearer_cap;
 gsm48_decode_called;

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I7ad0e03c2c738d174dd6bc3453f332eeb8da1e7d
Gerrit-PatchSet: 4
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Max <msuraev at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder



More information about the gerrit-log mailing list