fixeria has uploaded this change for review.
gprs_gmm: reset new_key after sending Security Mode Command
The ctx->iu.new_key flag indicates whether the keys sent in a RANAP
Security Mode Command are new (just obtained by AKA) or old. It is
set on MM context allocation and on successful authentication, and
used to be cleared right after sending the Security Mode Command.
The reset got lost in commit 0b2ad7bdb, which moved sending of the
Security Mode Command into vlr_set_ciph_mode_cb(). As a result, a
Security Mode Command sent on Service Request (no AKA, stored keys)
indicates KeyStatus "new". This [mis]leads the RNC to assume START=0,
while the UE continues to use its stored START value, so the integrity
check fails and the UE silently discards the RRC Security Mode Command.
The Service Request times out and PS services are unusable after
the first Iu release.
Change-Id: I30fdec14f08d26aef7e6fc2ec4f7c887d8ca0866
Fixes: 0b2ad7bdb ("Rework SGSN code to use new libvlr code")
---
M src/sgsn/gprs_gmm.c
1 file changed, 4 insertions(+), 0 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-sgsn refs/changes/41/44241/1
diff --git a/src/sgsn/gprs_gmm.c b/src/sgsn/gprs_gmm.c
index 2399516..8e2440a 100644
--- a/src/sgsn/gprs_gmm.c
+++ b/src/sgsn/gprs_gmm.c
@@ -2547,6 +2547,10 @@
send_ck = sgsn->cfg.uea_encryption_mask > (1 << OSMO_UTRAN_UEA0);
sgsn_ranap_iu_tx_sec_mode_cmd(ctx->iu.ue_ctx, &ctx->auth_triplet.vec, send_ck, ctx->iu.new_key);
+ /* The keys have been taken into use: any subsequent Security Mode
+ * Command without a new AKA (e.g. on Service Request) must indicate
+ * KeyStatus "old", so that the RNC keeps the UE's START value. */
+ ctx->iu.new_key = 0;
return 0;
#else
To view, visit change 44241. To unsubscribe, or for help writing mail filters, visit settings.