blob: d026f02295bf4bc71153b4a228230ff49cc74808 [file] [log] [blame]
Neels Hofmeyrf8178142017-01-25 15:04:16 +01001/* Osmocom MSC+VLR end-to-end tests */
2
3/* (C) 2017 by sysmocom s.f.m.c. GmbH <info@sysmocom.de>
4 *
5 * All Rights Reserved
6 *
7 * Author: Neels Hofmeyr <nhofmeyr@sysmocom.de>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU Affero General Public License as published by
11 * the Free Software Foundation; either version 3 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU Affero General Public License for more details.
18 *
19 * You should have received a copy of the GNU Affero General Public License
20 * along with this program. If not, see <http://www.gnu.org/licenses/>.
21 *
22 */
23
24#include "msc_vlr_tests.h"
25
26void _test_umts_authen(enum ran_type via_ran)
27{
28 struct vlr_subscr *vsub;
29 const char *imsi = "901700000010650";
Neels Hofmeyra1756f32016-05-20 21:59:55 +020030 const char *sms =
31 "09" /* SMS messages */
32 "01" /* CP-DATA */
33 "58" /* length */
34 "01" /* Network to MS */
35 "00" /* reference */
36 /* originator (gsm411_send_sms() hardcodes this weird nr) */
37 "0791" "447758100650" /* 447785016005 */
38 "00" /* dest */
39 /* SMS TPDU */
40 "4c" /* len */
41 "00" /* SMS deliver */
42 "05802443f2" /* originating address 42342 */
43 "00" /* TP-PID */
44 "00" /* GSM default alphabet */
45 "071010" /* Y-M-D (from wrapped gsm340_gen_scts())*/
46 "000000" /* H-M-S */
47 "00" /* GMT+0 */
48 "44" /* data length */
49 "5079da1e1ee7416937485e9ea7c965373d1d6683c270383b3d0e"
50 "d3d36ff71c949e83c22072799e9687c5ec32a81d96afcbf4b4fb"
51 "0c7ac3e9e9b7db05";
Neels Hofmeyrf8178142017-01-25 15:04:16 +010052
53 net->authentication_required = true;
Neels Hofmeyra1756f32016-05-20 21:59:55 +020054 net->vlr->cfg.assign_tmsi = true;
Neels Hofmeyrf8178142017-01-25 15:04:16 +010055 rx_from_ran = via_ran;
56
57 btw("Location Update request causes a GSUP Send Auth Info request to HLR");
58 lu_result_sent = RES_NONE;
59 gsup_expect_tx("080108" "09710000000156f0");
60 ms_sends_msg("0508" /* MM LU */
61 "7" /* ciph key seq: no key available */
62 "0" /* LU type: normal */
63 "ffffff" "0000" /* LAI, LAC */
64 "57" /* classmark 1: R99, early classmark, no power lvl */
65 "089910070000106005" /* IMSI */
66 "3303575886" /* classmark 2 */
67 );
68 OSMO_ASSERT(gsup_tx_confirmed);
69 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
70
71 btw("from HLR, rx _SEND_AUTH_INFO_RESULT; VLR sends Auth Req to MS");
72 /* based on auc_3g:
73 * K = 'EB215756028D60E3275E613320AEC880',
74 * OPC = 'FB2A3D1B360F599ABAB99DB8669F8308'
75 * SQN = 0
76 */
77 auth_request_sent = false;
78 auth_request_expect_rand = "39fa2f4e3d523d8619a73b4f65c3e14d";
79 auth_request_expect_autn = "8704f5ba55f30000d2ee44b22c8ea919";
80 gsup_rx("0a"
81 /* imsi */
82 "0108" "09710000000156f0"
83 /* 5 auth vectors... */
84 /* TL TL rand */
85 "0362" "2010" "39fa2f4e3d523d8619a73b4f65c3e14d"
86 /* TL sres TL kc */
87 "2104" "9b36efdf" "2208" "059a4f668f6fbe39"
88 /* TL 3G IK */
89 "2310" "27497388b6cb044648f396aa155b95ef"
90 /* TL 3G CK */
91 "2410" "f64735036e5871319c679f4742a75ea1"
92 /* TL AUTN */
93 "2510" "8704f5ba55f30000d2ee44b22c8ea919"
94 /* TL RES */
95 "2708" "e229c19e791f2e41"
96 /* TL TL rand */
97 "0362" "2010" "c187a53a5e6b9d573cac7c74451fd46d"
98 "2104" "85aa3130" "2208" "d3d50a000bf04f6e"
99 "2310" "1159ec926a50e98c034a6b7d7c9f418d"
100 "2410" "df3a03d9ca5335641efc8e36d76cd20b"
101 "2510" "1843a645b98d00005b2d666af46c45d9"
102 "2708" "7db47cf7f81e4dc7"
103 "0362" "2010" "efa9c29a9742148d5c9070348716e1bb"
104 "2104" "69d5f9fb" "2208" "3df176f0c29f1a3d"
105 "2310" "eb50e770ddcc3060101d2f43b6c2b884"
106 "2410" "76542abce5ff9345b0e8947f4c6e019c"
107 "2510" "f9375e6d41e1000096e7fe4ff1c27e39"
108 "2708" "706f996719ba609c"
109 "0362" "2010" "f023d5a3b24726e0631b64b3840f8253"
110 "2104" "d570c03f" "2208" "ec011be8919883d6"
111 "2310" "c4e58af4ba43f3bcd904e16984f086d7"
112 "2410" "0593f65e752e5cb7f473862bda05aa0a"
113 "2510" "541ff1f077270000c5ea00d658bc7e9a"
114 "2708" "3fd26072eaa2a04d"
115 "0362" "2010" "2f8f90c780d6a9c0c53da7ac57b6707e"
116 "2104" "b072446f220823f39f9f425ad6e6"
117 "2310" "65af0527fda95b0dc5ae4aa515cdf32f"
118 "2410" "537c3b35a3b13b08d08eeb28098f45cc"
119 "2510" "4bf4e564f75300009bc796706bc65744"
120 "2708" "0edb0eadbea94ac2",
121 NULL);
122 VERBOSE_ASSERT(auth_request_sent, == true, "%d");
123 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
124
Neels Hofmeyra1756f32016-05-20 21:59:55 +0200125 if (via_ran == RAN_GERAN_A) {
126 btw("MS sends Authen Response, VLR accepts and sends GSUP LU Req to HLR");
127 gsup_expect_tx("04010809710000000156f0");
128 ms_sends_msg("0554" "e229c19e" "2104" "791f2e41");
129 VERBOSE_ASSERT(gsup_tx_confirmed, == true, "%d");
130 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
131 } else {
132 /* On UTRAN */
133 btw("MS sends Authen Response, VLR accepts and sends SecurityModeControl");
134 cipher_mode_cmd_sent = false;
135 ms_sends_msg("0554" "e229c19e" "2104" "791f2e41");
136 VERBOSE_ASSERT(cipher_mode_cmd_sent, == true, "%d");
137 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
138
139 btw("MS sends SecurityModeControl acceptance, VLR accepts and sends GSUP LU Req to HLR");
140 gsup_expect_tx("04010809710000000156f0");
141 ms_sends_security_mode_complete();
142 VERBOSE_ASSERT(gsup_tx_confirmed, == true, "%d");
143 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
144 }
Neels Hofmeyrf8178142017-01-25 15:04:16 +0100145
146 btw("HLR sends _INSERT_DATA_REQUEST, VLR responds with _INSERT_DATA_RESULT");
147 gsup_rx("10010809710000000156f00804032443f2",
148 "12010809710000000156f0");
149 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
150
151 btw("HLR also sends GSUP _UPDATE_LOCATION_RESULT");
152 gsup_rx("06010809710000000156f0", NULL);
153
Neels Hofmeyrf8178142017-01-25 15:04:16 +0100154 VERBOSE_ASSERT(lu_result_sent, == RES_ACCEPT, "%d");
Neels Hofmeyra1756f32016-05-20 21:59:55 +0200155
156 btw("a LU Accept with a new TMSI was sent, waiting for TMSI Realloc Compl");
157 EXPECT_CONN_COUNT(1);
158 EXPECT_ACCEPTED(false);
159 thwart_rx_non_initial_requests();
160
161 btw("even though the TMSI is not acked, we can already find the subscr with it");
162 vsub = vlr_subscr_find_by_tmsi(net->vlr, 0x03020100);
163 VERBOSE_ASSERT(vsub != NULL, == true, "%d");
164 VERBOSE_ASSERT(strcmp(vsub->imsi, imsi), == 0, "%d");
165 VERBOSE_ASSERT(vsub->tmsi_new, == 0x03020100, "0x%08x");
166 VERBOSE_ASSERT(vsub->tmsi, == GSM_RESERVED_TMSI, "0x%08x");
167 vlr_subscr_put(vsub);
168
169 btw("MS sends TMSI Realloc Complete");
170 ms_sends_msg("055b");
171
172 btw("LU was successful, and the conn has already been closed");
Neels Hofmeyrf8178142017-01-25 15:04:16 +0100173 EXPECT_CONN_COUNT(0);
174
175 BTW("after a while, a new conn sends a CM Service Request. VLR responds with Auth Req, 2nd auth vector");
176 auth_request_sent = false;
177 auth_request_expect_rand = "c187a53a5e6b9d573cac7c74451fd46d";
178 auth_request_expect_autn = "1843a645b98d00005b2d666af46c45d9";
179 cm_service_result_sent = RES_NONE;
180 ms_sends_msg("052478"
181 "03575886" /* classmark 2 */
182 "089910070000106005" /* IMSI */);
183 OSMO_ASSERT(g_conn);
184 OSMO_ASSERT(g_conn->conn_fsm);
185 OSMO_ASSERT(g_conn->vsub);
186 VERBOSE_ASSERT(cm_service_result_sent, == RES_NONE, "%d");
187 VERBOSE_ASSERT(auth_request_sent, == true, "%d");
188
189 btw("needs auth, not yet accepted");
190 EXPECT_ACCEPTED(false);
191 thwart_rx_non_initial_requests();
192
Neels Hofmeyra1756f32016-05-20 21:59:55 +0200193 if (via_ran == RAN_GERAN_A) {
194 btw("MS sends Authen Response, VLR accepts with a CM Service Accept");
195 gsup_expect_tx(NULL);
196 ms_sends_msg("0554" "7db47cf7" "2104" "f81e4dc7"); /* 2nd vector's res, s.a. */
197 VERBOSE_ASSERT(cm_service_result_sent, == RES_ACCEPT, "%d");
198 } else {
199 /* On UTRAN */
200 btw("MS sends Authen Response, VLR accepts and sends SecurityModeControl");
201 cipher_mode_cmd_sent = false;
202 ms_sends_msg("0554" "7db47cf7" "2104" "f81e4dc7"); /* 2nd vector's res, s.a. */
203 VERBOSE_ASSERT(cipher_mode_cmd_sent, == true, "%d");
204 VERBOSE_ASSERT(cm_service_result_sent, == RES_NONE, "%d");
205
206 btw("MS sends SecurityModeControl acceptance, VLR accepts; above Ciphering is an implicit CM Service Accept");
207 ms_sends_security_mode_complete();
208 VERBOSE_ASSERT(cm_service_result_sent, == RES_NONE, "%d");
209 }
Neels Hofmeyrf8178142017-01-25 15:04:16 +0100210
211 btw("a USSD request is serviced");
212 dtap_expect_tx_ussd("Your extension is 42342\r");
213 ms_sends_msg("0b3b1c15a11302010002013b300b04010f0406aa510c061b017f0100");
214 OSMO_ASSERT(dtap_tx_confirmed);
215
216 btw("all requests serviced, conn has been released");
217 EXPECT_CONN_COUNT(0);
218
219 BTW("an SMS is sent, MS is paged");
220 paging_expect_imsi(imsi);
221 paging_sent = false;
222 vsub = vlr_subscr_find_by_imsi(net->vlr, imsi);
223 OSMO_ASSERT(vsub);
224 VERBOSE_ASSERT(llist_count(&vsub->cs.requests), == 0, "%d");
225
226 send_sms(vsub, vsub,
227 "Privacy in residential applications is a desirable"
228 " marketing option.");
229
230 VERBOSE_ASSERT(llist_count(&vsub->cs.requests), == 1, "%d");
231 vlr_subscr_put(vsub);
232 vsub = NULL;
233 VERBOSE_ASSERT(paging_sent, == true, "%d");
234 VERBOSE_ASSERT(paging_stopped, == false, "%d");
235
236 btw("the subscriber and its pending request should remain");
237 vsub = vlr_subscr_find_by_imsi(net->vlr, imsi);
238 OSMO_ASSERT(vsub);
239 VERBOSE_ASSERT(llist_count(&vsub->cs.requests), == 1, "%d");
240 vlr_subscr_put(vsub);
241
242 btw("MS replies with Paging Response, and VLR sends Auth Request with third key");
243 auth_request_sent = false;
244 auth_request_expect_rand = "efa9c29a9742148d5c9070348716e1bb";
245 auth_request_expect_autn = "f9375e6d41e1000096e7fe4ff1c27e39";
246 ms_sends_msg("062707"
247 "03575886" /* classmark 2 */
248 "089910070000106005" /* IMSI */);
249 VERBOSE_ASSERT(auth_request_sent, == true, "%d");
250
251 btw("needs auth, not yet accepted");
252 EXPECT_ACCEPTED(false);
253 thwart_rx_non_initial_requests();
254
Neels Hofmeyra1756f32016-05-20 21:59:55 +0200255 if (via_ran == RAN_GERAN_A) {
256 btw("MS sends Authen Response, VLR accepts and sends pending SMS");
257 dtap_expect_tx(sms);
258 ms_sends_msg("0554" "706f9967" "2104" "19ba609c"); /* 3nd vector's res, s.a. */
259 VERBOSE_ASSERT(dtap_tx_confirmed, == true, "%d");
260 VERBOSE_ASSERT(paging_stopped, == true, "%d");
261 } else {
262 /* On UTRAN */
263 btw("MS sends Authen Response, VLR accepts and sends SecurityModeControl");
264 cipher_mode_cmd_sent = false;
265 ms_sends_msg("0554" "706f9967" "2104" "19ba609c"); /* 3nd vector's res, s.a. */
266 VERBOSE_ASSERT(cipher_mode_cmd_sent, == true, "%d");
267 VERBOSE_ASSERT(paging_stopped, == false, "%d");
268
269 btw("MS sends SecurityModeControl acceptance, VLR accepts and sends SMS");
270 dtap_expect_tx(sms);
271 ms_sends_security_mode_complete();
272 VERBOSE_ASSERT(paging_stopped, == true, "%d");
273 }
Neels Hofmeyrf8178142017-01-25 15:04:16 +0100274
275 btw("SMS was delivered, no requests pending for subscr");
276 vsub = vlr_subscr_find_by_imsi(net->vlr, imsi);
277 OSMO_ASSERT(vsub);
278 VERBOSE_ASSERT(llist_count(&vsub->cs.requests), == 0, "%d");
279 vlr_subscr_put(vsub);
280
281 btw("conn is still open to wait for SMS ack dance");
282 EXPECT_CONN_COUNT(1);
283
284 btw("MS replies with CP-ACK for received SMS");
285 ms_sends_msg("8904");
286 EXPECT_CONN_COUNT(1);
287
288 btw("MS also sends RP-ACK, MSC in turn sends CP-ACK for that");
289 dtap_expect_tx("0904");
290 ms_sends_msg("890106020041020000");
291 VERBOSE_ASSERT(dtap_tx_confirmed, == true, "%d");
292
293 btw("SMS is done, conn is gone");
294 EXPECT_CONN_COUNT(0);
295
296 BTW("subscriber detaches");
297 ms_sends_msg("050130"
298 "089910070000106005" /* IMSI */);
299
300 EXPECT_CONN_COUNT(0);
301 clear_vlr();
302}
303
304void test_umts_authen_geran()
305{
306 comment_start();
307 _test_umts_authen(RAN_GERAN_A);
308 comment_end();
309}
310
311void test_umts_authen_utran()
312{
313 comment_start();
314 _test_umts_authen(RAN_UTRAN_IU);
315 comment_end();
316}
317
318#define RECALC_AUTS 0
319
320#if RECALC_AUTS
321typedef uint8_t u8;
322extern int milenage_f2345(const u8 *opc, const u8 *k, const u8 *_rand,
323 u8 *res, u8 *ck, u8 *ik, u8 *ak, u8 *akstar);
324extern int milenage_f1(const u8 *opc, const u8 *k, const u8 *_rand,
325 const u8 *sqn, const u8 *amf, u8 *mac_a, u8 *mac_s);
326#endif
327
328void _test_umts_authen_resync(enum ran_type via_ran)
329{
Neels Hofmeyra1756f32016-05-20 21:59:55 +0200330 struct vlr_subscr *vsub;
331 const char *imsi = "901700000010650";
332
Neels Hofmeyrf8178142017-01-25 15:04:16 +0100333 net->authentication_required = true;
Neels Hofmeyra1756f32016-05-20 21:59:55 +0200334 net->vlr->cfg.assign_tmsi = true;
Neels Hofmeyrf8178142017-01-25 15:04:16 +0100335 rx_from_ran = via_ran;
336
337 btw("Location Update request causes a GSUP Send Auth Info request to HLR");
338 lu_result_sent = RES_NONE;
339 gsup_expect_tx("080108" "09710000000156f0");
340 ms_sends_msg("0508" /* MM LU */
341 "7" /* ciph key seq: no key available */
342 "0" /* LU type: normal */
343 "ffffff" "0000" /* LAI, LAC */
344 "57" /* classmark 1: R99, early classmark, no power lvl */
345 "089910070000106005" /* IMSI */
346 "3303575886" /* classmark 2 */
347 );
348 OSMO_ASSERT(gsup_tx_confirmed);
349 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
350
351 btw("from HLR, rx _SEND_AUTH_INFO_RESULT; VLR sends Auth Req to MS");
352 /* based on auc_3g:
353 * K = 'EB215756028D60E3275E613320AEC880',
354 * OPC = 'FB2A3D1B360F599ABAB99DB8669F8308'
355 * SQN = 0
356 */
357 auth_request_sent = false;
358 auth_request_expect_rand = "39fa2f4e3d523d8619a73b4f65c3e14d";
359 auth_request_expect_autn = "8704f5ba55f30000d2ee44b22c8ea919";
360 gsup_rx("0a"
361 /* imsi */
362 "0108" "09710000000156f0"
363 /* auth vectors... */
364 /* TL TL rand */
365 "0362" "2010" "39fa2f4e3d523d8619a73b4f65c3e14d"
366 /* TL sres TL kc */
367 "2104" "9b36efdf" "2208" "059a4f668f6fbe39"
368 /* TL 3G IK */
369 "2310" "27497388b6cb044648f396aa155b95ef"
370 /* TL 3G CK */
371 "2410" "f64735036e5871319c679f4742a75ea1"
372 /* TL AUTN */
373 "2510" "8704f5ba55f30000d2ee44b22c8ea919"
374 /* TL RES */
375 "2708" "e229c19e791f2e41"
376 ,NULL);
377 VERBOSE_ASSERT(auth_request_sent, == true, "%d");
378 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
379
380 /* The AUTN sent was 8704f5ba55f30000d2ee44b22c8ea919
381 * (see expected error output)
382 * with the first 6 bytes being SQN ^ AK.
383 * K = EB215756028D60E3275E613320AEC880
384 * OPC = FB2A3D1B360F599ABAB99DB8669F8308
385 * RAND = 39fa2f4e3d523d8619a73b4f65c3e14d
386 * --milenage-f5-->
387 * AK = 8704f5ba55f3
388 *
389 * The first six bytes are 8704f5ba55f3,
390 * and 8704f5ba55f3 ^ AK = 0.
391 * --> SQN = 0.
392 *
393 * Say the USIM doesn't like that, let's say it is at SQN 23.
394 * SQN_MS = 000000000017
395 *
396 * AUTS = Conc(SQN_MS) || MAC-S
397 * Conc(SQN_MS) = SQN_MS ⊕ f5*[K](RAND)
398 * MAC-S = f1*[K] (SQN MS || RAND || AMF)
399 *
400 * f5*--> Conc(SQN_MS) = 000000000017 ^ 979498b1f73a
401 * = 979498b1f72d
402 * AMF = 0000 (TS 33.102 v7.0.0, 6.3.3)
403 *
404 * MAC-S = f1*[K] (000000000017 || 39fa2f4e3d523d8619a73b4f65c3e14d || 0000)
405 * = 3e28c59fa2e72f9c
406 *
407 * AUTS = 979498b1f72d || 3e28c59fa2e72f9c
408 */
409#if RECALC_AUTS
410 uint8_t ak[6];
411 uint8_t akstar[6];
412 uint8_t opc[16];
413 uint8_t k[16];
414 uint8_t rand[16];
415 osmo_hexparse("EB215756028D60E3275E613320AEC880", k, sizeof(k));
416 osmo_hexparse("FB2A3D1B360F599ABAB99DB8669F8308", opc, sizeof(opc));
417 osmo_hexparse("39fa2f4e3d523d8619a73b4f65c3e14d", rand, sizeof(rand));
418 milenage_f2345(opc, k, rand, NULL, NULL, NULL, ak, akstar);
419 btw("ak = %s", osmo_hexdump_nospc(ak, sizeof(ak)));
420 btw("akstar = %s", osmo_hexdump_nospc(akstar, sizeof(akstar)));
421
422 uint8_t sqn_ms[6] = { 0, 0, 0, 0, 0, 23 };
423 uint8_t amf[2] = { 0 };
424 uint8_t mac_s[8];
425 milenage_f1(opc, k, rand, sqn_ms, amf, NULL, mac_s);
426 btw("mac_s = %s", osmo_hexdump_nospc(mac_s, sizeof(mac_s)));
427 /* verify valid AUTS resulting in SQN 23 with:
428 osmo-auc-gen -3 -a milenage -k EB215756028D60E3275E613320AEC880 \
429 -o FB2A3D1B360F599ABAB99DB8669F8308 \
430 -r 39fa2f4e3d523d8619a73b4f65c3e14d \
431 -A 979498b1f72d3e28c59fa2e72f9c
432 */
433#endif
434
435 btw("MS sends Authen Failure with Resync cause, VLR sends GSUP to HLR to resync");
436 auth_request_sent = false;
437 gsup_expect_tx("08" /* OSMO_GSUP_MSGT_SEND_AUTH_INFO_REQUEST */
438 "0108" "09710000000156f0" /* IMSI */
439 "260e" "979498b1f72d3e28c59fa2e72f9c" /* AUTS */
440 "2010" "39fa2f4e3d523d8619a73b4f65c3e14d" /* RAND */);
441 ms_sends_msg("051c" /* 05 = MM; 1c = Auth Failure */
442 "15" /* cause = Synch Failure */
443 "220e" "979498b1f72d3e28c59fa2e72f9c" /* AUTS */);
444 VERBOSE_ASSERT(gsup_tx_confirmed, == true, "%d");
445 VERBOSE_ASSERT(auth_request_sent, == false, "%d");
446 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
447
448 btw("HLR replies with new tuples");
449 auth_request_sent = false;
450 auth_request_expect_rand = "0f1feb1623e1bf626334e37ec448ac18";
451 auth_request_expect_autn = "02a83f62e9470000660d51afc75f169d";
452 gsup_rx("0a"
453 /* imsi */
454 "0108" "09710000000156f0"
455 /* 1 auth vector */
456 /* TL TL rand */
457 "0362" "2010" "0f1feb1623e1bf626334e37ec448ac18"
458 /* TL sres TL kc */
459 "2104" "efde99da" "2208" "14778c855c523730"
460 /* TL 3G IK */
461 "2310" "8a90c769b7272f3bb7a1c1fbb1ea9349"
462 /* TL 3G CK */
463 "2410" "43ffc1cf8c89a7fd6ab94bd8d6162cbf"
464 /* TL AUTN */
465 "2510" "02a83f62e9470000660d51afc75f169d"
466 /* TL RES */
467 "2708" "1df5f0b4f22b696e"
468 /* TL TL rand */
469 "0362" "2010" "ac21d34937b4e1142a2c757af2949319"
470 /* TL sres TL kc */
471 "2104" "7818bfdc" "2208" "d175571f41f314a4"
472 /* TL 3G IK */
473 "2310" "ff8edbceb6dd24799c77c3b9a6790c10"
474 /* TL 3G CK */
475 "2410" "157c39022ca9d885a7f0766a7dfee448"
476 /* TL AUTN */
477 "2510" "8a43b91898e500002cf354c6f5d1f8c3"
478 /* TL RES */
479 "2708" "f748a7078f5018db"
480 ,NULL);
481
482 VERBOSE_ASSERT(auth_request_sent, == true, "%d");
483 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
484
Neels Hofmeyra1756f32016-05-20 21:59:55 +0200485 if (via_ran == RAN_GERAN_A) {
486 btw("MS sends Authen Response, VLR accepts and sends GSUP LU Req to HLR");
487 gsup_expect_tx("04010809710000000156f0");
488 ms_sends_msg("0554" "1df5f0b4" "2104" "f22b696e");
489 VERBOSE_ASSERT(gsup_tx_confirmed, == true, "%d");
490 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
491 } else {
492 /* On UTRAN */
493 btw("MS sends Authen Response, VLR accepts and sends SecurityModeControl");
494 cipher_mode_cmd_sent = false;
495 ms_sends_msg("0554" "1df5f0b4" "2104" "f22b696e");
496 VERBOSE_ASSERT(cipher_mode_cmd_sent, == true, "%d");
497 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
498
499 btw("MS sends SecurityModeControl acceptance, VLR accepts and sends GSUP LU Req to HLR");
500 gsup_expect_tx("04010809710000000156f0");
501 ms_sends_security_mode_complete();
502 VERBOSE_ASSERT(gsup_tx_confirmed, == true, "%d");
503 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
504 }
Neels Hofmeyrf8178142017-01-25 15:04:16 +0100505
506 btw("HLR sends _INSERT_DATA_REQUEST, VLR responds with _INSERT_DATA_RESULT");
507 gsup_rx("10010809710000000156f00804032443f2",
508 "12010809710000000156f0");
509 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
510
511 btw("HLR also sends GSUP _UPDATE_LOCATION_RESULT");
512 gsup_rx("06010809710000000156f0", NULL);
513
Neels Hofmeyrf8178142017-01-25 15:04:16 +0100514 VERBOSE_ASSERT(lu_result_sent, == RES_ACCEPT, "%d");
Neels Hofmeyra1756f32016-05-20 21:59:55 +0200515
516 btw("a LU Accept with a new TMSI was sent, waiting for TMSI Realloc Compl");
517 EXPECT_CONN_COUNT(1);
518 EXPECT_ACCEPTED(false);
519 thwart_rx_non_initial_requests();
520
521 btw("even though the TMSI is not acked, we can already find the subscr with it");
522 vsub = vlr_subscr_find_by_tmsi(net->vlr, 0x03020100);
523 VERBOSE_ASSERT(vsub != NULL, == true, "%d");
524 VERBOSE_ASSERT(strcmp(vsub->imsi, imsi), == 0, "%d");
525 VERBOSE_ASSERT(vsub->tmsi_new, == 0x03020100, "0x%08x");
526 VERBOSE_ASSERT(vsub->tmsi, == GSM_RESERVED_TMSI, "0x%08x");
527 vlr_subscr_put(vsub);
528
529 btw("MS sends TMSI Realloc Complete");
530 ms_sends_msg("055b");
531
532 btw("LU was successful, and the conn has already been closed");
Neels Hofmeyrf8178142017-01-25 15:04:16 +0100533 EXPECT_CONN_COUNT(0);
534
535 clear_vlr();
536}
537
538void test_umts_authen_resync_geran()
539{
540 comment_start();
541 _test_umts_authen_resync(RAN_GERAN_A);
542 comment_end();
543}
544
545void test_umts_authen_resync_utran()
546{
547 comment_start();
548 _test_umts_authen_resync(RAN_UTRAN_IU);
549 comment_end();
550}
551
552msc_vlr_test_func_t msc_vlr_tests[] = {
553 test_umts_authen_geran,
554 test_umts_authen_utran,
555 test_umts_authen_resync_geran,
556 test_umts_authen_resync_utran,
557 NULL
558};