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/.
Max gerrit-no-reply at lists.osmocom.org
Review at https://gerrit.osmocom.org/5788
Generate random IOV-UI and send it via XID
This ensures that encryption is using random IV value as per-spec
instead of hard-coded 0.
Change-Id: I7b6e2268cb28451434116463ecd3ce5f68400832
Fixes: OS#1794
---
M include/osmocom/sgsn/gprs_llc.h
M src/gprs/gprs_llc.c
2 files changed, 27 insertions(+), 12 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-sgsn refs/changes/88/5788/1
diff --git a/include/osmocom/sgsn/gprs_llc.h b/include/osmocom/sgsn/gprs_llc.h
index 376ae9a..f5643da 100644
--- a/include/osmocom/sgsn/gprs_llc.h
+++ b/include/osmocom/sgsn/gprs_llc.h
@@ -238,6 +238,8 @@
int gprs_llgmm_reset_oldmsg(struct msgb* oldmsg, uint8_t sapi,
struct gprs_llc_llme *llme);
+bool gprs_llgmm_gen_iov_ui(struct gprs_llc_llme *llme);
+
/* Set of LL-XID negotiation (See also: TS 101 351, Section 7.2.2.4) */
int gprs_ll_xid_req(struct gprs_llc_lle *lle,
struct gprs_llc_xid_field *l3_xid_field);
diff --git a/src/gprs/gprs_llc.c b/src/gprs/gprs_llc.c
index 6c92f83..11c5cc5 100644
--- a/src/gprs/gprs_llc.c
+++ b/src/gprs/gprs_llc.c
@@ -49,6 +49,19 @@
/* BEGIN XID RELATED */
+bool gprs_llgmm_gen_iov_ui(struct gprs_llc_llme *llme)
+{
+ if (llme->algo != GPRS_ALGO_GEA0) {
+ int rc = osmo_get_rand_id((uint8_t *) &llme->iov_ui, 4);
+ if (rc < 0) {
+ LOGP(DLLC, LOGL_ERROR, "osmo_get_rand_id() failed for LLC XID reset: %s\n", strerror(-rc));
+ return false;
+ }
+ return true;
+ }
+ return false;
+}
+
/* Generate XID message */
static int gprs_llc_generate_xid(uint8_t *bytes, int bytes_len,
struct gprs_llc_xid_field *l3_xid_field,
@@ -58,9 +71,15 @@
LLIST_HEAD(xid_fields);
+ struct gprs_llc_xid_field xid_iov_ui;
struct gprs_llc_xid_field xid_version;
struct gprs_llc_xid_field xid_n201u;
struct gprs_llc_xid_field xid_n201i;
+
+ bool iov = gprs_llgmm_gen_iov_ui(llme);
+ xid_iov_ui.type = GPRS_LLC_XID_T_IOV_UI;
+ xid_iov_ui.data = (uint8_t *) &llme->iov_ui;
+ xid_iov_ui.data_len = 4;
xid_version.type = GPRS_LLC_XID_T_VERSION;
xid_version.data = (uint8_t *) "\x00";
@@ -75,6 +94,10 @@
xid_n201i.data_len = 2;
/* Add locally managed XID Fields */
+ if (iov)
+ llist_add(&xid_iov_ui.list, &xid_fields);
+ LOGP(DLLC, LOGL_NOTICE, "XID gen with iov %d\n", iov);
+
llist_add(&xid_version.list, &xid_fields);
llist_add(&xid_n201u.list, &xid_fields);
llist_add(&xid_n201i.list, &xid_fields);
@@ -1074,12 +1097,7 @@
uint8_t *xid;
LOGP(DLLC, LOGL_NOTICE, "LLGM Reset\n");
-
- rc = osmo_get_rand_id((uint8_t *) &llme->iov_ui, 4);
- if (rc < 0) {
- LOGP(DLLC, LOGL_ERROR, "osmo_get_rand_id() failed for LLC XID reset: %s\n", strerror(-rc));
- return rc;
- }
+ gprs_llgmm_gen_iov_ui(llme);
/* Generate XID message */
xid_bytes_len = gprs_llc_generate_xid_for_gmm_reset(xid_bytes,
@@ -1108,12 +1126,7 @@
uint8_t *xid;
LOGP(DLLC, LOGL_NOTICE, "LLGM Reset\n");
-
- rc = osmo_get_rand_id((uint8_t *) &llme->iov_ui, 4);
- if (rc < 0) {
- LOGP(DLLC, LOGL_ERROR, "osmo_get_rand_id() failed for LLC XID reset: %s\n", strerror(-rc));
- return rc;
- }
+ gprs_llgmm_gen_iov_ui(llme);
/* Generate XID message */
xid_bytes_len = gprs_llc_generate_xid_for_gmm_reset(xid_bytes,
--
To view, visit https://gerrit.osmocom.org/5788
To unsubscribe, visit https://gerrit.osmocom.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I7b6e2268cb28451434116463ecd3ce5f68400832
Gerrit-PatchSet: 1
Gerrit-Project: osmo-sgsn
Gerrit-Branch: master
Gerrit-Owner: Max <msuraev at sysmocom.de>