lynxis lazus has uploaded this change for review.

View Change

SGSN: BSSGP_ConnHdlr: GMM Service Request: optional expect an authentication

On a Service Request, the authentication is optional.
Either an authentication can happen or the key material from the previous authentication
has to be used. Extend the test case to allow both cases
to succeed.

Change-Id: I9ed08160bf5413e3a30d6e90eb947d4d799e1058
---
M sgsn/BSSGP_ConnHdlr.ttcn
1 file changed, 68 insertions(+), 0 deletions(-)

git pull ssh://gerrit.osmocom.org:29418/osmo-ttcn3-hacks refs/changes/96/38396/1
diff --git a/sgsn/BSSGP_ConnHdlr.ttcn b/sgsn/BSSGP_ConnHdlr.ttcn
index 055902a..db09a5c 100644
--- a/sgsn/BSSGP_ConnHdlr.ttcn
+++ b/sgsn/BSSGP_ConnHdlr.ttcn
@@ -294,6 +294,73 @@
}
}

+/* expect a GSUP Send Auth Information */
+altstep as_gsup_sai(boolean umts_aka_challenge := false) runs on BSSGP_ConnHdlr
+{
+ [g_pars.net.expect_auth] GSUP.receive(tr_GSUP_SAI_REQ(g_pars.imsi)) {
+ var GSUP_IE auth_tuple;
+
+ if (umts_aka_challenge) {
+ g_pars.vec := f_gen_auth_vec_3g();
+ auth_tuple := valueof(ts_GSUP_IE_AuthTuple2G3G(g_pars.vec.rand,
+ g_pars.vec.sres,
+ g_pars.vec.kc,
+ g_pars.vec.ik,
+ g_pars.vec.ck,
+ g_pars.vec.autn,
+ g_pars.vec.res));
+ } else {
+ g_pars.vec := f_gen_auth_vec_2g();
+ auth_tuple := valueof(ts_GSUP_IE_AuthTuple2G(g_pars.vec.rand,
+ g_pars.vec.sres,
+ g_pars.vec.kc));
+ }
+
+ GSUP.send(ts_GSUP_SAI_RES(g_pars.imsi, auth_tuple));
+ }
+}
+
+private function f_gmm_auth_as(PDU_L3_SGSN_MS l3_mt, boolean umts_aka_challenge := true, boolean force_gsm_sres := false, integer ran_index := 0) runs on BSSGP_ConnHdlr {
+ var PDU_L3_MS_SGSN l3_mo;
+ var BIT4 ac_ref := l3_mt.msgs.gprs_mm.authenticationAndCipheringRequest.acReferenceNumber.valueField;
+ var template (value) PDU_L3_MS_SGSN auth_ciph_resp := ts_GMM_AUTH_RESP_2G(ac_ref, g_pars.vec.sres);
+
+ if (umts_aka_challenge and not force_gsm_sres) {
+ /* set UMTS response instead */
+ auth_ciph_resp.msgs.gprs_mm.authenticationAndCipheringResponse.authenticationParResp := {
+ valueField := substr(g_pars.vec.res, 0, 4)
+ };
+ auth_ciph_resp.msgs.gprs_mm.authenticationAndCipheringResponse.authenticationRespParExt := {
+ elementIdentifier := '21'O,
+ lengthIndicator := lengthof(g_pars.vec.res) - 4,
+ valueField := substr(g_pars.vec.res, 4, lengthof(g_pars.vec.res) - 4)
+ };
+ }
+
+ l3_mo := valueof(auth_ciph_resp);
+ if (ispresent(l3_mt.msgs.gprs_mm.authenticationAndCipheringRequest.imeisvRequest) and
+ l3_mt.msgs.gprs_mm.authenticationAndCipheringRequest.imeisvRequest.valueField == '001'B) {
+ l3_mo.msgs.gprs_mm.authenticationAndCipheringResponse.imeisv :=
+ valueof(ts_MI_IMEISV_TLV(g_pars.imei & '0'H));
+ }
+ f_send_l3(l3_mo, ran_index);
+}
+
+altstep as_gmm_auth(boolean umts_aka_challenge := false, boolean force_gsm_sres := false, integer ran_index := 0) runs on BSSGP_ConnHdlr {
+ var PDU_DTAP_PS_MT mt;
+ var PDU_L3_SGSN_MS l3_mt;
+
+ /* Ignoring autn for now */
+ [is_gb(ran_index)] BSSGP[ran_index].receive(tr_GMM_AUTH_REQ(g_pars.vec.rand)) -> value l3_mt {
+ f_gmm_auth_as(l3_mt, umts_aka_challenge, force_gsm_sres, ran_index);
+ }
+ [is_iu(ran_index)] BSSAP.receive(tr_PDU_DTAP_PS_MT(tr_GMM_AUTH_REQ(g_pars.vec.rand))) -> value mt {
+ l3_mt := mt.dtap;
+ f_gmm_auth_as(l3_mt, umts_aka_challenge, force_gsm_sres, ran_index);
+ }
+ [] as_gsup_sai(umts_aka_challenge := umts_aka_challenge);
+}
+
/* perform GMM authentication (if expected).
* Note, for umts_aka_challenge to work, the revisionLevelIndicatior needs to
* be 1 to mark R99 capability, in the GMM Attach Request, see f_gmm_attach(). */
@@ -663,6 +730,7 @@

alt {
[] as_service_request(ran_index) { setverdict(pass); }
+ [] as_gmm_auth(umts_aka_challenge := true, ran_index := ran_index) { repeat; }
[] BSSAP.receive { repeat; }
[] T.timeout {
Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,

To view, visit change 38396. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-MessageType: newchange
Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-Change-Id: I9ed08160bf5413e3a30d6e90eb947d4d799e1058
Gerrit-Change-Number: 38396
Gerrit-PatchSet: 1
Gerrit-Owner: lynxis lazus <lynxis@fe80.eu>