blob: b5a55fc98e43ff689a704c7a08d0e5890f7bbca5 [file] [log] [blame]
Neels Hofmeyr6a29d322017-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
Philipp Maierfbf66102017-04-09 12:32:51 +020026#define ASSERT_RELEASE_CLEAR(via_ran) \
27 switch (via_ran) { \
28 case RAN_GERAN_A: \
29 VERBOSE_ASSERT(bssap_clear_sent, == true, "%d"); \
30 break; \
31 case RAN_UTRAN_IU: \
32 VERBOSE_ASSERT(iu_release_sent, == true, "%d"); \
33 break; \
34 default: \
35 OSMO_ASSERT(false); \
36 break; \
37 }
38
Neels Hofmeyrf3d81f62018-03-02 01:05:38 +010039static void _test_umts_authen(enum ran_type via_ran)
Neels Hofmeyr6a29d322017-01-25 15:04:16 +010040{
41 struct vlr_subscr *vsub;
42 const char *imsi = "901700000010650";
Neels Hofmeyr84da6b12016-05-20 21:59:55 +020043 const char *sms =
44 "09" /* SMS messages */
45 "01" /* CP-DATA */
46 "58" /* length */
47 "01" /* Network to MS */
48 "00" /* reference */
49 /* originator (gsm411_send_sms() hardcodes this weird nr) */
50 "0791" "447758100650" /* 447785016005 */
51 "00" /* dest */
52 /* SMS TPDU */
53 "4c" /* len */
54 "00" /* SMS deliver */
55 "05802443f2" /* originating address 42342 */
56 "00" /* TP-PID */
57 "00" /* GSM default alphabet */
58 "071010" /* Y-M-D (from wrapped gsm340_gen_scts())*/
59 "000000" /* H-M-S */
60 "00" /* GMT+0 */
61 "44" /* data length */
62 "5079da1e1ee7416937485e9ea7c965373d1d6683c270383b3d0e"
63 "d3d36ff71c949e83c22072799e9687c5ec32a81d96afcbf4b4fb"
64 "0c7ac3e9e9b7db05";
Neels Hofmeyr6a29d322017-01-25 15:04:16 +010065
66 net->authentication_required = true;
Neels Hofmeyr84da6b12016-05-20 21:59:55 +020067 net->vlr->cfg.assign_tmsi = true;
Neels Hofmeyr6a29d322017-01-25 15:04:16 +010068 rx_from_ran = via_ran;
69
70 btw("Location Update request causes a GSUP Send Auth Info request to HLR");
71 lu_result_sent = RES_NONE;
72 gsup_expect_tx("080108" "09710000000156f0");
73 ms_sends_msg("0508" /* MM LU */
74 "7" /* ciph key seq: no key available */
75 "0" /* LU type: normal */
76 "ffffff" "0000" /* LAI, LAC */
77 "57" /* classmark 1: R99, early classmark, no power lvl */
78 "089910070000106005" /* IMSI */
79 "3303575886" /* classmark 2 */
80 );
81 OSMO_ASSERT(gsup_tx_confirmed);
82 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
83
84 btw("from HLR, rx _SEND_AUTH_INFO_RESULT; VLR sends Auth Req to MS");
85 /* based on auc_3g:
86 * K = 'EB215756028D60E3275E613320AEC880',
87 * OPC = 'FB2A3D1B360F599ABAB99DB8669F8308'
88 * SQN = 0
89 */
90 auth_request_sent = false;
91 auth_request_expect_rand = "39fa2f4e3d523d8619a73b4f65c3e14d";
92 auth_request_expect_autn = "8704f5ba55f30000d2ee44b22c8ea919";
93 gsup_rx("0a"
94 /* imsi */
95 "0108" "09710000000156f0"
96 /* 5 auth vectors... */
97 /* TL TL rand */
98 "0362" "2010" "39fa2f4e3d523d8619a73b4f65c3e14d"
99 /* TL sres TL kc */
100 "2104" "9b36efdf" "2208" "059a4f668f6fbe39"
101 /* TL 3G IK */
102 "2310" "27497388b6cb044648f396aa155b95ef"
103 /* TL 3G CK */
104 "2410" "f64735036e5871319c679f4742a75ea1"
105 /* TL AUTN */
106 "2510" "8704f5ba55f30000d2ee44b22c8ea919"
107 /* TL RES */
108 "2708" "e229c19e791f2e41"
109 /* TL TL rand */
110 "0362" "2010" "c187a53a5e6b9d573cac7c74451fd46d"
111 "2104" "85aa3130" "2208" "d3d50a000bf04f6e"
112 "2310" "1159ec926a50e98c034a6b7d7c9f418d"
113 "2410" "df3a03d9ca5335641efc8e36d76cd20b"
114 "2510" "1843a645b98d00005b2d666af46c45d9"
115 "2708" "7db47cf7f81e4dc7"
116 "0362" "2010" "efa9c29a9742148d5c9070348716e1bb"
117 "2104" "69d5f9fb" "2208" "3df176f0c29f1a3d"
118 "2310" "eb50e770ddcc3060101d2f43b6c2b884"
119 "2410" "76542abce5ff9345b0e8947f4c6e019c"
120 "2510" "f9375e6d41e1000096e7fe4ff1c27e39"
121 "2708" "706f996719ba609c"
122 "0362" "2010" "f023d5a3b24726e0631b64b3840f8253"
123 "2104" "d570c03f" "2208" "ec011be8919883d6"
124 "2310" "c4e58af4ba43f3bcd904e16984f086d7"
125 "2410" "0593f65e752e5cb7f473862bda05aa0a"
126 "2510" "541ff1f077270000c5ea00d658bc7e9a"
127 "2708" "3fd26072eaa2a04d"
128 "0362" "2010" "2f8f90c780d6a9c0c53da7ac57b6707e"
129 "2104" "b072446f220823f39f9f425ad6e6"
130 "2310" "65af0527fda95b0dc5ae4aa515cdf32f"
131 "2410" "537c3b35a3b13b08d08eeb28098f45cc"
132 "2510" "4bf4e564f75300009bc796706bc65744"
133 "2708" "0edb0eadbea94ac2",
134 NULL);
135 VERBOSE_ASSERT(auth_request_sent, == true, "%d");
136 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
137
Neels Hofmeyr84da6b12016-05-20 21:59:55 +0200138 if (via_ran == RAN_GERAN_A) {
139 btw("MS sends Authen Response, VLR accepts and sends GSUP LU Req to HLR");
140 gsup_expect_tx("04010809710000000156f0");
141 ms_sends_msg("0554" "e229c19e" "2104" "791f2e41");
142 VERBOSE_ASSERT(gsup_tx_confirmed, == true, "%d");
143 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
144 } else {
145 /* On UTRAN */
146 btw("MS sends Authen Response, VLR accepts and sends SecurityModeControl");
Neels Hofmeyrdbabfd32018-03-10 02:06:47 +0100147 expect_security_mode_ctrl(NULL, "27497388b6cb044648f396aa155b95ef");
Neels Hofmeyr84da6b12016-05-20 21:59:55 +0200148 ms_sends_msg("0554" "e229c19e" "2104" "791f2e41");
Neels Hofmeyrdbabfd32018-03-10 02:06:47 +0100149 VERBOSE_ASSERT(security_mode_ctrl_sent, == true, "%d");
Neels Hofmeyr84da6b12016-05-20 21:59:55 +0200150 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
151
152 btw("MS sends SecurityModeControl acceptance, VLR accepts and sends GSUP LU Req to HLR");
153 gsup_expect_tx("04010809710000000156f0");
154 ms_sends_security_mode_complete();
155 VERBOSE_ASSERT(gsup_tx_confirmed, == true, "%d");
156 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
157 }
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100158
159 btw("HLR sends _INSERT_DATA_REQUEST, VLR responds with _INSERT_DATA_RESULT");
160 gsup_rx("10010809710000000156f00804032443f2",
161 "12010809710000000156f0");
162 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
163
164 btw("HLR also sends GSUP _UPDATE_LOCATION_RESULT");
165 gsup_rx("06010809710000000156f0", NULL);
166
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100167 VERBOSE_ASSERT(lu_result_sent, == RES_ACCEPT, "%d");
Neels Hofmeyr84da6b12016-05-20 21:59:55 +0200168
169 btw("a LU Accept with a new TMSI was sent, waiting for TMSI Realloc Compl");
170 EXPECT_CONN_COUNT(1);
171 EXPECT_ACCEPTED(false);
172 thwart_rx_non_initial_requests();
173
174 btw("even though the TMSI is not acked, we can already find the subscr with it");
175 vsub = vlr_subscr_find_by_tmsi(net->vlr, 0x03020100);
176 VERBOSE_ASSERT(vsub != NULL, == true, "%d");
177 VERBOSE_ASSERT(strcmp(vsub->imsi, imsi), == 0, "%d");
178 VERBOSE_ASSERT(vsub->tmsi_new, == 0x03020100, "0x%08x");
179 VERBOSE_ASSERT(vsub->tmsi, == GSM_RESERVED_TMSI, "0x%08x");
180 vlr_subscr_put(vsub);
181
182 btw("MS sends TMSI Realloc Complete");
Philipp Maierfbf66102017-04-09 12:32:51 +0200183 expect_release_clear(via_ran);
Neels Hofmeyr84da6b12016-05-20 21:59:55 +0200184 ms_sends_msg("055b");
Philipp Maierfbf66102017-04-09 12:32:51 +0200185 ASSERT_RELEASE_CLEAR(via_ran);
Neels Hofmeyr84da6b12016-05-20 21:59:55 +0200186
187 btw("LU was successful, and the conn has already been closed");
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100188 EXPECT_CONN_COUNT(0);
189
190 BTW("after a while, a new conn sends a CM Service Request. VLR responds with Auth Req, 2nd auth vector");
191 auth_request_sent = false;
192 auth_request_expect_rand = "c187a53a5e6b9d573cac7c74451fd46d";
193 auth_request_expect_autn = "1843a645b98d00005b2d666af46c45d9";
194 cm_service_result_sent = RES_NONE;
195 ms_sends_msg("052478"
196 "03575886" /* classmark 2 */
197 "089910070000106005" /* IMSI */);
198 OSMO_ASSERT(g_conn);
199 OSMO_ASSERT(g_conn->conn_fsm);
200 OSMO_ASSERT(g_conn->vsub);
201 VERBOSE_ASSERT(cm_service_result_sent, == RES_NONE, "%d");
202 VERBOSE_ASSERT(auth_request_sent, == true, "%d");
203
204 btw("needs auth, not yet accepted");
205 EXPECT_ACCEPTED(false);
206 thwart_rx_non_initial_requests();
207
Neels Hofmeyr84da6b12016-05-20 21:59:55 +0200208 if (via_ran == RAN_GERAN_A) {
209 btw("MS sends Authen Response, VLR accepts with a CM Service Accept");
210 gsup_expect_tx(NULL);
211 ms_sends_msg("0554" "7db47cf7" "2104" "f81e4dc7"); /* 2nd vector's res, s.a. */
212 VERBOSE_ASSERT(cm_service_result_sent, == RES_ACCEPT, "%d");
213 } else {
214 /* On UTRAN */
215 btw("MS sends Authen Response, VLR accepts and sends SecurityModeControl");
Neels Hofmeyrdbabfd32018-03-10 02:06:47 +0100216 expect_security_mode_ctrl(NULL, "1159ec926a50e98c034a6b7d7c9f418d");
Neels Hofmeyr84da6b12016-05-20 21:59:55 +0200217 ms_sends_msg("0554" "7db47cf7" "2104" "f81e4dc7"); /* 2nd vector's res, s.a. */
Neels Hofmeyrdbabfd32018-03-10 02:06:47 +0100218 VERBOSE_ASSERT(security_mode_ctrl_sent, == true, "%d");
Neels Hofmeyr84da6b12016-05-20 21:59:55 +0200219 VERBOSE_ASSERT(cm_service_result_sent, == RES_NONE, "%d");
220
221 btw("MS sends SecurityModeControl acceptance, VLR accepts; above Ciphering is an implicit CM Service Accept");
222 ms_sends_security_mode_complete();
223 VERBOSE_ASSERT(cm_service_result_sent, == RES_NONE, "%d");
224 }
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100225
226 btw("a USSD request is serviced");
227 dtap_expect_tx_ussd("Your extension is 42342\r");
Philipp Maierfbf66102017-04-09 12:32:51 +0200228 expect_release_clear(via_ran);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100229 ms_sends_msg("0b3b1c15a11302010002013b300b04010f0406aa510c061b017f0100");
230 OSMO_ASSERT(dtap_tx_confirmed);
Philipp Maierfbf66102017-04-09 12:32:51 +0200231 ASSERT_RELEASE_CLEAR(via_ran);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100232
233 btw("all requests serviced, conn has been released");
234 EXPECT_CONN_COUNT(0);
235
236 BTW("an SMS is sent, MS is paged");
237 paging_expect_imsi(imsi);
238 paging_sent = false;
239 vsub = vlr_subscr_find_by_imsi(net->vlr, imsi);
240 OSMO_ASSERT(vsub);
241 VERBOSE_ASSERT(llist_count(&vsub->cs.requests), == 0, "%d");
242
243 send_sms(vsub, vsub,
244 "Privacy in residential applications is a desirable"
245 " marketing option.");
246
247 VERBOSE_ASSERT(llist_count(&vsub->cs.requests), == 1, "%d");
248 vlr_subscr_put(vsub);
249 vsub = NULL;
250 VERBOSE_ASSERT(paging_sent, == true, "%d");
251 VERBOSE_ASSERT(paging_stopped, == false, "%d");
252
253 btw("the subscriber and its pending request should remain");
254 vsub = vlr_subscr_find_by_imsi(net->vlr, imsi);
255 OSMO_ASSERT(vsub);
256 VERBOSE_ASSERT(llist_count(&vsub->cs.requests), == 1, "%d");
257 vlr_subscr_put(vsub);
258
259 btw("MS replies with Paging Response, and VLR sends Auth Request with third key");
260 auth_request_sent = false;
261 auth_request_expect_rand = "efa9c29a9742148d5c9070348716e1bb";
262 auth_request_expect_autn = "f9375e6d41e1000096e7fe4ff1c27e39";
263 ms_sends_msg("062707"
264 "03575886" /* classmark 2 */
265 "089910070000106005" /* IMSI */);
266 VERBOSE_ASSERT(auth_request_sent, == true, "%d");
267
268 btw("needs auth, not yet accepted");
269 EXPECT_ACCEPTED(false);
270 thwart_rx_non_initial_requests();
271
Neels Hofmeyr84da6b12016-05-20 21:59:55 +0200272 if (via_ran == RAN_GERAN_A) {
273 btw("MS sends Authen Response, VLR accepts and sends pending SMS");
274 dtap_expect_tx(sms);
275 ms_sends_msg("0554" "706f9967" "2104" "19ba609c"); /* 3nd vector's res, s.a. */
276 VERBOSE_ASSERT(dtap_tx_confirmed, == true, "%d");
277 VERBOSE_ASSERT(paging_stopped, == true, "%d");
278 } else {
279 /* On UTRAN */
280 btw("MS sends Authen Response, VLR accepts and sends SecurityModeControl");
Neels Hofmeyrdbabfd32018-03-10 02:06:47 +0100281 expect_security_mode_ctrl(NULL, "eb50e770ddcc3060101d2f43b6c2b884");
Neels Hofmeyr84da6b12016-05-20 21:59:55 +0200282 ms_sends_msg("0554" "706f9967" "2104" "19ba609c"); /* 3nd vector's res, s.a. */
Neels Hofmeyrdbabfd32018-03-10 02:06:47 +0100283 VERBOSE_ASSERT(security_mode_ctrl_sent, == true, "%d");
Neels Hofmeyr84da6b12016-05-20 21:59:55 +0200284 VERBOSE_ASSERT(paging_stopped, == false, "%d");
285
286 btw("MS sends SecurityModeControl acceptance, VLR accepts and sends SMS");
287 dtap_expect_tx(sms);
288 ms_sends_security_mode_complete();
289 VERBOSE_ASSERT(paging_stopped, == true, "%d");
290 }
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100291
292 btw("SMS was delivered, no requests pending for subscr");
293 vsub = vlr_subscr_find_by_imsi(net->vlr, imsi);
294 OSMO_ASSERT(vsub);
295 VERBOSE_ASSERT(llist_count(&vsub->cs.requests), == 0, "%d");
296 vlr_subscr_put(vsub);
297
298 btw("conn is still open to wait for SMS ack dance");
299 EXPECT_CONN_COUNT(1);
300
301 btw("MS replies with CP-ACK for received SMS");
302 ms_sends_msg("8904");
303 EXPECT_CONN_COUNT(1);
304
305 btw("MS also sends RP-ACK, MSC in turn sends CP-ACK for that");
306 dtap_expect_tx("0904");
Philipp Maierfbf66102017-04-09 12:32:51 +0200307 expect_release_clear(via_ran);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100308 ms_sends_msg("890106020041020000");
309 VERBOSE_ASSERT(dtap_tx_confirmed, == true, "%d");
Philipp Maierfbf66102017-04-09 12:32:51 +0200310 ASSERT_RELEASE_CLEAR(via_ran);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100311
312 btw("SMS is done, conn is gone");
313 EXPECT_CONN_COUNT(0);
314
315 BTW("subscriber detaches");
Philipp Maierfbf66102017-04-09 12:32:51 +0200316 expect_release_clear(via_ran);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100317 ms_sends_msg("050130"
318 "089910070000106005" /* IMSI */);
Philipp Maierfbf66102017-04-09 12:32:51 +0200319 ASSERT_RELEASE_CLEAR(via_ran);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100320
321 EXPECT_CONN_COUNT(0);
322 clear_vlr();
323}
324
Neels Hofmeyrf3d81f62018-03-02 01:05:38 +0100325static void test_umts_authen_geran()
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100326{
Neels Hofmeyrdfdc61d2018-03-02 00:40:58 +0100327 comment_start();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100328 _test_umts_authen(RAN_GERAN_A);
Neels Hofmeyrdfdc61d2018-03-02 00:40:58 +0100329 comment_end();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100330}
331
Neels Hofmeyrf3d81f62018-03-02 01:05:38 +0100332static void test_umts_authen_utran()
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100333{
Neels Hofmeyrdfdc61d2018-03-02 00:40:58 +0100334 comment_start();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100335 _test_umts_authen(RAN_UTRAN_IU);
Neels Hofmeyrdfdc61d2018-03-02 00:40:58 +0100336 comment_end();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100337}
338
339#define RECALC_AUTS 0
340
341#if RECALC_AUTS
342typedef uint8_t u8;
343extern int milenage_f2345(const u8 *opc, const u8 *k, const u8 *_rand,
344 u8 *res, u8 *ck, u8 *ik, u8 *ak, u8 *akstar);
345extern int milenage_f1(const u8 *opc, const u8 *k, const u8 *_rand,
346 const u8 *sqn, const u8 *amf, u8 *mac_a, u8 *mac_s);
347#endif
348
Neels Hofmeyrf3d81f62018-03-02 01:05:38 +0100349static void _test_umts_authen_resync(enum ran_type via_ran)
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100350{
Neels Hofmeyr84da6b12016-05-20 21:59:55 +0200351 struct vlr_subscr *vsub;
352 const char *imsi = "901700000010650";
353
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100354 net->authentication_required = true;
Neels Hofmeyr84da6b12016-05-20 21:59:55 +0200355 net->vlr->cfg.assign_tmsi = true;
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100356 rx_from_ran = via_ran;
357
358 btw("Location Update request causes a GSUP Send Auth Info request to HLR");
359 lu_result_sent = RES_NONE;
360 gsup_expect_tx("080108" "09710000000156f0");
361 ms_sends_msg("0508" /* MM LU */
362 "7" /* ciph key seq: no key available */
363 "0" /* LU type: normal */
364 "ffffff" "0000" /* LAI, LAC */
365 "57" /* classmark 1: R99, early classmark, no power lvl */
366 "089910070000106005" /* IMSI */
367 "3303575886" /* classmark 2 */
368 );
369 OSMO_ASSERT(gsup_tx_confirmed);
370 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
371
372 btw("from HLR, rx _SEND_AUTH_INFO_RESULT; VLR sends Auth Req to MS");
373 /* based on auc_3g:
374 * K = 'EB215756028D60E3275E613320AEC880',
375 * OPC = 'FB2A3D1B360F599ABAB99DB8669F8308'
376 * SQN = 0
377 */
378 auth_request_sent = false;
379 auth_request_expect_rand = "39fa2f4e3d523d8619a73b4f65c3e14d";
380 auth_request_expect_autn = "8704f5ba55f30000d2ee44b22c8ea919";
381 gsup_rx("0a"
382 /* imsi */
383 "0108" "09710000000156f0"
384 /* auth vectors... */
385 /* TL TL rand */
386 "0362" "2010" "39fa2f4e3d523d8619a73b4f65c3e14d"
387 /* TL sres TL kc */
388 "2104" "9b36efdf" "2208" "059a4f668f6fbe39"
389 /* TL 3G IK */
390 "2310" "27497388b6cb044648f396aa155b95ef"
391 /* TL 3G CK */
392 "2410" "f64735036e5871319c679f4742a75ea1"
393 /* TL AUTN */
394 "2510" "8704f5ba55f30000d2ee44b22c8ea919"
395 /* TL RES */
396 "2708" "e229c19e791f2e41"
397 ,NULL);
398 VERBOSE_ASSERT(auth_request_sent, == true, "%d");
399 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
400
401 /* The AUTN sent was 8704f5ba55f30000d2ee44b22c8ea919
402 * (see expected error output)
403 * with the first 6 bytes being SQN ^ AK.
404 * K = EB215756028D60E3275E613320AEC880
405 * OPC = FB2A3D1B360F599ABAB99DB8669F8308
406 * RAND = 39fa2f4e3d523d8619a73b4f65c3e14d
407 * --milenage-f5-->
408 * AK = 8704f5ba55f3
409 *
410 * The first six bytes are 8704f5ba55f3,
411 * and 8704f5ba55f3 ^ AK = 0.
412 * --> SQN = 0.
413 *
414 * Say the USIM doesn't like that, let's say it is at SQN 23.
415 * SQN_MS = 000000000017
416 *
417 * AUTS = Conc(SQN_MS) || MAC-S
418 * Conc(SQN_MS) = SQN_MS ⊕ f5*[K](RAND)
419 * MAC-S = f1*[K] (SQN MS || RAND || AMF)
420 *
421 * f5*--> Conc(SQN_MS) = 000000000017 ^ 979498b1f73a
422 * = 979498b1f72d
423 * AMF = 0000 (TS 33.102 v7.0.0, 6.3.3)
424 *
425 * MAC-S = f1*[K] (000000000017 || 39fa2f4e3d523d8619a73b4f65c3e14d || 0000)
426 * = 3e28c59fa2e72f9c
427 *
428 * AUTS = 979498b1f72d || 3e28c59fa2e72f9c
429 */
430#if RECALC_AUTS
431 uint8_t ak[6];
432 uint8_t akstar[6];
433 uint8_t opc[16];
434 uint8_t k[16];
435 uint8_t rand[16];
436 osmo_hexparse("EB215756028D60E3275E613320AEC880", k, sizeof(k));
437 osmo_hexparse("FB2A3D1B360F599ABAB99DB8669F8308", opc, sizeof(opc));
438 osmo_hexparse("39fa2f4e3d523d8619a73b4f65c3e14d", rand, sizeof(rand));
439 milenage_f2345(opc, k, rand, NULL, NULL, NULL, ak, akstar);
440 btw("ak = %s", osmo_hexdump_nospc(ak, sizeof(ak)));
441 btw("akstar = %s", osmo_hexdump_nospc(akstar, sizeof(akstar)));
442
443 uint8_t sqn_ms[6] = { 0, 0, 0, 0, 0, 23 };
444 uint8_t amf[2] = { 0 };
445 uint8_t mac_s[8];
446 milenage_f1(opc, k, rand, sqn_ms, amf, NULL, mac_s);
447 btw("mac_s = %s", osmo_hexdump_nospc(mac_s, sizeof(mac_s)));
448 /* verify valid AUTS resulting in SQN 23 with:
449 osmo-auc-gen -3 -a milenage -k EB215756028D60E3275E613320AEC880 \
450 -o FB2A3D1B360F599ABAB99DB8669F8308 \
451 -r 39fa2f4e3d523d8619a73b4f65c3e14d \
452 -A 979498b1f72d3e28c59fa2e72f9c
453 */
454#endif
455
456 btw("MS sends Authen Failure with Resync cause, VLR sends GSUP to HLR to resync");
457 auth_request_sent = false;
458 gsup_expect_tx("08" /* OSMO_GSUP_MSGT_SEND_AUTH_INFO_REQUEST */
459 "0108" "09710000000156f0" /* IMSI */
460 "260e" "979498b1f72d3e28c59fa2e72f9c" /* AUTS */
461 "2010" "39fa2f4e3d523d8619a73b4f65c3e14d" /* RAND */);
462 ms_sends_msg("051c" /* 05 = MM; 1c = Auth Failure */
463 "15" /* cause = Synch Failure */
464 "220e" "979498b1f72d3e28c59fa2e72f9c" /* AUTS */);
465 VERBOSE_ASSERT(gsup_tx_confirmed, == true, "%d");
466 VERBOSE_ASSERT(auth_request_sent, == false, "%d");
467 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
468
469 btw("HLR replies with new tuples");
470 auth_request_sent = false;
471 auth_request_expect_rand = "0f1feb1623e1bf626334e37ec448ac18";
472 auth_request_expect_autn = "02a83f62e9470000660d51afc75f169d";
473 gsup_rx("0a"
474 /* imsi */
475 "0108" "09710000000156f0"
476 /* 1 auth vector */
477 /* TL TL rand */
478 "0362" "2010" "0f1feb1623e1bf626334e37ec448ac18"
479 /* TL sres TL kc */
480 "2104" "efde99da" "2208" "14778c855c523730"
481 /* TL 3G IK */
482 "2310" "8a90c769b7272f3bb7a1c1fbb1ea9349"
483 /* TL 3G CK */
484 "2410" "43ffc1cf8c89a7fd6ab94bd8d6162cbf"
485 /* TL AUTN */
486 "2510" "02a83f62e9470000660d51afc75f169d"
487 /* TL RES */
488 "2708" "1df5f0b4f22b696e"
489 /* TL TL rand */
490 "0362" "2010" "ac21d34937b4e1142a2c757af2949319"
491 /* TL sres TL kc */
492 "2104" "7818bfdc" "2208" "d175571f41f314a4"
493 /* TL 3G IK */
494 "2310" "ff8edbceb6dd24799c77c3b9a6790c10"
495 /* TL 3G CK */
496 "2410" "157c39022ca9d885a7f0766a7dfee448"
497 /* TL AUTN */
498 "2510" "8a43b91898e500002cf354c6f5d1f8c3"
499 /* TL RES */
500 "2708" "f748a7078f5018db"
501 ,NULL);
502
503 VERBOSE_ASSERT(auth_request_sent, == true, "%d");
504 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
505
Neels Hofmeyr84da6b12016-05-20 21:59:55 +0200506 if (via_ran == RAN_GERAN_A) {
507 btw("MS sends Authen Response, VLR accepts and sends GSUP LU Req to HLR");
508 gsup_expect_tx("04010809710000000156f0");
509 ms_sends_msg("0554" "1df5f0b4" "2104" "f22b696e");
510 VERBOSE_ASSERT(gsup_tx_confirmed, == true, "%d");
511 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
512 } else {
513 /* On UTRAN */
514 btw("MS sends Authen Response, VLR accepts and sends SecurityModeControl");
Neels Hofmeyrdbabfd32018-03-10 02:06:47 +0100515 expect_security_mode_ctrl(NULL, "8a90c769b7272f3bb7a1c1fbb1ea9349");
Neels Hofmeyr84da6b12016-05-20 21:59:55 +0200516 ms_sends_msg("0554" "1df5f0b4" "2104" "f22b696e");
Neels Hofmeyrdbabfd32018-03-10 02:06:47 +0100517 VERBOSE_ASSERT(security_mode_ctrl_sent, == true, "%d");
Neels Hofmeyr84da6b12016-05-20 21:59:55 +0200518 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
519
520 btw("MS sends SecurityModeControl acceptance, VLR accepts and sends GSUP LU Req to HLR");
521 gsup_expect_tx("04010809710000000156f0");
522 ms_sends_security_mode_complete();
523 VERBOSE_ASSERT(gsup_tx_confirmed, == true, "%d");
524 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
525 }
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100526
527 btw("HLR sends _INSERT_DATA_REQUEST, VLR responds with _INSERT_DATA_RESULT");
528 gsup_rx("10010809710000000156f00804032443f2",
529 "12010809710000000156f0");
530 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
531
532 btw("HLR also sends GSUP _UPDATE_LOCATION_RESULT");
533 gsup_rx("06010809710000000156f0", NULL);
534
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100535 VERBOSE_ASSERT(lu_result_sent, == RES_ACCEPT, "%d");
Neels Hofmeyr84da6b12016-05-20 21:59:55 +0200536
537 btw("a LU Accept with a new TMSI was sent, waiting for TMSI Realloc Compl");
538 EXPECT_CONN_COUNT(1);
539 EXPECT_ACCEPTED(false);
540 thwart_rx_non_initial_requests();
541
542 btw("even though the TMSI is not acked, we can already find the subscr with it");
543 vsub = vlr_subscr_find_by_tmsi(net->vlr, 0x03020100);
544 VERBOSE_ASSERT(vsub != NULL, == true, "%d");
545 VERBOSE_ASSERT(strcmp(vsub->imsi, imsi), == 0, "%d");
546 VERBOSE_ASSERT(vsub->tmsi_new, == 0x03020100, "0x%08x");
547 VERBOSE_ASSERT(vsub->tmsi, == GSM_RESERVED_TMSI, "0x%08x");
548 vlr_subscr_put(vsub);
549
550 btw("MS sends TMSI Realloc Complete");
Philipp Maierfbf66102017-04-09 12:32:51 +0200551 expect_release_clear(via_ran);
Neels Hofmeyr84da6b12016-05-20 21:59:55 +0200552 ms_sends_msg("055b");
Philipp Maierfbf66102017-04-09 12:32:51 +0200553 ASSERT_RELEASE_CLEAR(via_ran);
Neels Hofmeyr84da6b12016-05-20 21:59:55 +0200554
555 btw("LU was successful, and the conn has already been closed");
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100556 EXPECT_CONN_COUNT(0);
557
558 clear_vlr();
559}
560
Neels Hofmeyrf3d81f62018-03-02 01:05:38 +0100561static void test_umts_authen_resync_geran()
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100562{
Neels Hofmeyrdfdc61d2018-03-02 00:40:58 +0100563 comment_start();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100564 _test_umts_authen_resync(RAN_GERAN_A);
Neels Hofmeyrdfdc61d2018-03-02 00:40:58 +0100565 comment_end();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100566}
567
Neels Hofmeyrf3d81f62018-03-02 01:05:38 +0100568static void test_umts_authen_resync_utran()
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100569{
Neels Hofmeyrdfdc61d2018-03-02 00:40:58 +0100570 comment_start();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100571 _test_umts_authen_resync(RAN_UTRAN_IU);
Neels Hofmeyrdfdc61d2018-03-02 00:40:58 +0100572 comment_end();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100573}
574
Neels Hofmeyr15ed4262018-03-10 04:02:44 +0100575static void _test_umts_authen_too_short_res(enum ran_type via_ran)
576{
577 net->authentication_required = true;
578 net->vlr->cfg.assign_tmsi = true;
579 rx_from_ran = via_ran;
580
581 btw("Location Update request causes a GSUP Send Auth Info request to HLR");
582 lu_result_sent = RES_NONE;
583 gsup_expect_tx("080108" "09710000000156f0");
584 ms_sends_msg("0508" /* MM LU */
585 "7" /* ciph key seq: no key available */
586 "0" /* LU type: normal */
587 "ffffff" "0000" /* LAI, LAC */
588 "57" /* classmark 1: R99, early classmark, no power lvl */
589 "089910070000106005" /* IMSI */
590 "3303575886" /* classmark 2 */
591 );
592 OSMO_ASSERT(gsup_tx_confirmed);
593 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
594
595 btw("from HLR, rx _SEND_AUTH_INFO_RESULT; VLR sends Auth Req to MS");
596 /* based on auc_3g:
597 * K = 'EB215756028D60E3275E613320AEC880',
598 * OPC = 'FB2A3D1B360F599ABAB99DB8669F8308'
599 * SQN = 0
600 */
601 auth_request_sent = false;
602 auth_request_expect_rand = "39fa2f4e3d523d8619a73b4f65c3e14d";
603 auth_request_expect_autn = "8704f5ba55f30000d2ee44b22c8ea919";
604 gsup_rx("0a"
605 /* imsi */
606 "0108" "09710000000156f0"
607 /* 5 auth vectors... */
608 /* TL TL rand */
609 "0362" "2010" "39fa2f4e3d523d8619a73b4f65c3e14d"
610 /* TL sres TL kc */
611 "2104" "9b36efdf" "2208" "059a4f668f6fbe39"
612 /* TL 3G IK */
613 "2310" "27497388b6cb044648f396aa155b95ef"
614 /* TL 3G CK */
615 "2410" "f64735036e5871319c679f4742a75ea1"
616 /* TL AUTN */
617 "2510" "8704f5ba55f30000d2ee44b22c8ea919"
618 /* TL RES */
619 "2708" "e229c19e791f2e41"
620 /* TL TL rand */
621 "0362" "2010" "c187a53a5e6b9d573cac7c74451fd46d"
622 "2104" "85aa3130" "2208" "d3d50a000bf04f6e"
623 "2310" "1159ec926a50e98c034a6b7d7c9f418d"
624 "2410" "df3a03d9ca5335641efc8e36d76cd20b"
625 "2510" "1843a645b98d00005b2d666af46c45d9"
626 "2708" "7db47cf7f81e4dc7"
627 "0362" "2010" "efa9c29a9742148d5c9070348716e1bb"
628 "2104" "69d5f9fb" "2208" "3df176f0c29f1a3d"
629 "2310" "eb50e770ddcc3060101d2f43b6c2b884"
630 "2410" "76542abce5ff9345b0e8947f4c6e019c"
631 "2510" "f9375e6d41e1000096e7fe4ff1c27e39"
632 "2708" "706f996719ba609c"
633 "0362" "2010" "f023d5a3b24726e0631b64b3840f8253"
634 "2104" "d570c03f" "2208" "ec011be8919883d6"
635 "2310" "c4e58af4ba43f3bcd904e16984f086d7"
636 "2410" "0593f65e752e5cb7f473862bda05aa0a"
637 "2510" "541ff1f077270000c5ea00d658bc7e9a"
638 "2708" "3fd26072eaa2a04d"
639 "0362" "2010" "2f8f90c780d6a9c0c53da7ac57b6707e"
640 "2104" "b072446f220823f39f9f425ad6e6"
641 "2310" "65af0527fda95b0dc5ae4aa515cdf32f"
642 "2410" "537c3b35a3b13b08d08eeb28098f45cc"
643 "2510" "4bf4e564f75300009bc796706bc65744"
644 "2708" "0edb0eadbea94ac2",
645 NULL);
646 VERBOSE_ASSERT(auth_request_sent, == true, "%d");
647 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
648
649 btw("MS sends Authen Response of wrong RES size, VLR thwarts");
650 gsup_expect_tx("0b010809710000000156f0"); /* OSMO_GSUP_MSGT_AUTH_FAIL_REPORT */
651 expect_release_clear(via_ran);
652 ms_sends_msg("0554" "e229c19e" "2103" "791f2e" /* nipped one byte */);
653 VERBOSE_ASSERT(lu_result_sent, == RES_REJECT, "%d");
654 ASSERT_RELEASE_CLEAR(via_ran);
655
656 EXPECT_CONN_COUNT(0);
657 clear_vlr();
658}
659
660static void test_umts_authen_too_short_res_geran()
661{
662 comment_start();
663 _test_umts_authen_too_short_res(RAN_GERAN_A);
664 comment_end();
665}
666
667static void test_umts_authen_too_short_res_utran()
668{
669 comment_start();
670 _test_umts_authen_too_short_res(RAN_UTRAN_IU);
671 comment_end();
672}
673
Neels Hofmeyrc6d20dd2018-03-10 04:03:43 +0100674static void _test_umts_authen_too_long_res(enum ran_type via_ran)
675{
676 net->authentication_required = true;
677 net->vlr->cfg.assign_tmsi = true;
678 rx_from_ran = via_ran;
679
680 btw("Location Update request causes a GSUP Send Auth Info request to HLR");
681 lu_result_sent = RES_NONE;
682 gsup_expect_tx("080108" "09710000000156f0");
683 ms_sends_msg("0508" /* MM LU */
684 "7" /* ciph key seq: no key available */
685 "0" /* LU type: normal */
686 "ffffff" "0000" /* LAI, LAC */
687 "57" /* classmark 1: R99, early classmark, no power lvl */
688 "089910070000106005" /* IMSI */
689 "3303575886" /* classmark 2 */
690 );
691 OSMO_ASSERT(gsup_tx_confirmed);
692 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
693
694 btw("from HLR, rx _SEND_AUTH_INFO_RESULT; VLR sends Auth Req to MS");
695 /* based on auc_3g:
696 * K = 'EB215756028D60E3275E613320AEC880',
697 * OPC = 'FB2A3D1B360F599ABAB99DB8669F8308'
698 * SQN = 0
699 */
700 auth_request_sent = false;
701 auth_request_expect_rand = "39fa2f4e3d523d8619a73b4f65c3e14d";
702 auth_request_expect_autn = "8704f5ba55f30000d2ee44b22c8ea919";
703 gsup_rx("0a"
704 /* imsi */
705 "0108" "09710000000156f0"
706 /* 5 auth vectors... */
707 /* TL TL rand */
708 "0362" "2010" "39fa2f4e3d523d8619a73b4f65c3e14d"
709 /* TL sres TL kc */
710 "2104" "9b36efdf" "2208" "059a4f668f6fbe39"
711 /* TL 3G IK */
712 "2310" "27497388b6cb044648f396aa155b95ef"
713 /* TL 3G CK */
714 "2410" "f64735036e5871319c679f4742a75ea1"
715 /* TL AUTN */
716 "2510" "8704f5ba55f30000d2ee44b22c8ea919"
717 /* TL RES */
718 "2708" "e229c19e791f2e41"
719 /* TL TL rand */
720 "0362" "2010" "c187a53a5e6b9d573cac7c74451fd46d"
721 "2104" "85aa3130" "2208" "d3d50a000bf04f6e"
722 "2310" "1159ec926a50e98c034a6b7d7c9f418d"
723 "2410" "df3a03d9ca5335641efc8e36d76cd20b"
724 "2510" "1843a645b98d00005b2d666af46c45d9"
725 "2708" "7db47cf7f81e4dc7"
726 "0362" "2010" "efa9c29a9742148d5c9070348716e1bb"
727 "2104" "69d5f9fb" "2208" "3df176f0c29f1a3d"
728 "2310" "eb50e770ddcc3060101d2f43b6c2b884"
729 "2410" "76542abce5ff9345b0e8947f4c6e019c"
730 "2510" "f9375e6d41e1000096e7fe4ff1c27e39"
731 "2708" "706f996719ba609c"
732 "0362" "2010" "f023d5a3b24726e0631b64b3840f8253"
733 "2104" "d570c03f" "2208" "ec011be8919883d6"
734 "2310" "c4e58af4ba43f3bcd904e16984f086d7"
735 "2410" "0593f65e752e5cb7f473862bda05aa0a"
736 "2510" "541ff1f077270000c5ea00d658bc7e9a"
737 "2708" "3fd26072eaa2a04d"
738 "0362" "2010" "2f8f90c780d6a9c0c53da7ac57b6707e"
739 "2104" "b072446f220823f39f9f425ad6e6"
740 "2310" "65af0527fda95b0dc5ae4aa515cdf32f"
741 "2410" "537c3b35a3b13b08d08eeb28098f45cc"
742 "2510" "4bf4e564f75300009bc796706bc65744"
743 "2708" "0edb0eadbea94ac2",
744 NULL);
745 VERBOSE_ASSERT(auth_request_sent, == true, "%d");
746 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
747
748 btw("MS sends Authen Response of wrong RES size, VLR thwarts");
749 gsup_expect_tx("0b010809710000000156f0"); /* OSMO_GSUP_MSGT_AUTH_FAIL_REPORT */
750 expect_release_clear(via_ran);
751 ms_sends_msg("0554" "e229c19e" "2105" "791f2e4123" /* added one byte */);
752 VERBOSE_ASSERT(lu_result_sent, == RES_REJECT, "%d");
753 ASSERT_RELEASE_CLEAR(via_ran);
754
755 EXPECT_CONN_COUNT(0);
756 clear_vlr();
757}
758
759static void test_umts_authen_too_long_res_geran()
760{
761 comment_start();
762 _test_umts_authen_too_long_res(RAN_GERAN_A);
763 comment_end();
764}
765
766static void test_umts_authen_too_long_res_utran()
767{
768 comment_start();
769 _test_umts_authen_too_long_res(RAN_UTRAN_IU);
770 comment_end();
771}
772
Neels Hofmeyr31adcae2018-03-10 04:08:45 +0100773static void _test_umts_authen_only_sres(enum ran_type via_ran)
774{
775 net->authentication_required = true;
776 net->vlr->cfg.assign_tmsi = true;
777 rx_from_ran = via_ran;
778
779 btw("Location Update request causes a GSUP Send Auth Info request to HLR");
780 lu_result_sent = RES_NONE;
781 gsup_expect_tx("080108" "09710000000156f0");
782 ms_sends_msg("0508" /* MM LU */
783 "7" /* ciph key seq: no key available */
784 "0" /* LU type: normal */
785 "ffffff" "0000" /* LAI, LAC */
786 "57" /* classmark 1: R99, early classmark, no power lvl */
787 "089910070000106005" /* IMSI */
788 "3303575886" /* classmark 2 */
789 );
790 OSMO_ASSERT(gsup_tx_confirmed);
791 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
792
793 btw("from HLR, rx _SEND_AUTH_INFO_RESULT; VLR sends Auth Req to MS");
794 /* based on auc_3g:
795 * K = 'EB215756028D60E3275E613320AEC880',
796 * OPC = 'FB2A3D1B360F599ABAB99DB8669F8308'
797 * SQN = 0
798 */
799 auth_request_sent = false;
800 auth_request_expect_rand = "39fa2f4e3d523d8619a73b4f65c3e14d";
801 auth_request_expect_autn = "8704f5ba55f30000d2ee44b22c8ea919";
802 gsup_rx("0a"
803 /* imsi */
804 "0108" "09710000000156f0"
805 /* 5 auth vectors... */
806 /* TL TL rand */
807 "0362" "2010" "39fa2f4e3d523d8619a73b4f65c3e14d"
808 /* TL sres TL kc */
809 "2104" "9b36efdf" "2208" "059a4f668f6fbe39"
810 /* TL 3G IK */
811 "2310" "27497388b6cb044648f396aa155b95ef"
812 /* TL 3G CK */
813 "2410" "f64735036e5871319c679f4742a75ea1"
814 /* TL AUTN */
815 "2510" "8704f5ba55f30000d2ee44b22c8ea919"
816 /* TL RES */
817 "2708" "e229c19e791f2e41"
818 /* TL TL rand */
819 "0362" "2010" "c187a53a5e6b9d573cac7c74451fd46d"
820 "2104" "85aa3130" "2208" "d3d50a000bf04f6e"
821 "2310" "1159ec926a50e98c034a6b7d7c9f418d"
822 "2410" "df3a03d9ca5335641efc8e36d76cd20b"
823 "2510" "1843a645b98d00005b2d666af46c45d9"
824 "2708" "7db47cf7f81e4dc7"
825 "0362" "2010" "efa9c29a9742148d5c9070348716e1bb"
826 "2104" "69d5f9fb" "2208" "3df176f0c29f1a3d"
827 "2310" "eb50e770ddcc3060101d2f43b6c2b884"
828 "2410" "76542abce5ff9345b0e8947f4c6e019c"
829 "2510" "f9375e6d41e1000096e7fe4ff1c27e39"
830 "2708" "706f996719ba609c"
831 "0362" "2010" "f023d5a3b24726e0631b64b3840f8253"
832 "2104" "d570c03f" "2208" "ec011be8919883d6"
833 "2310" "c4e58af4ba43f3bcd904e16984f086d7"
834 "2410" "0593f65e752e5cb7f473862bda05aa0a"
835 "2510" "541ff1f077270000c5ea00d658bc7e9a"
836 "2708" "3fd26072eaa2a04d"
837 "0362" "2010" "2f8f90c780d6a9c0c53da7ac57b6707e"
838 "2104" "b072446f220823f39f9f425ad6e6"
839 "2310" "65af0527fda95b0dc5ae4aa515cdf32f"
840 "2410" "537c3b35a3b13b08d08eeb28098f45cc"
841 "2510" "4bf4e564f75300009bc796706bc65744"
842 "2708" "0edb0eadbea94ac2",
843 NULL);
844 VERBOSE_ASSERT(auth_request_sent, == true, "%d");
845 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
846
847 if (via_ran == RAN_GERAN_A)
848 btw("MS sends Authen Response of wrong RES size, VLR thwarts:"
849 " GERAN reports an SRES mismatch");
850 else
851 btw("MS sends Authen Response of wrong RES size, VLR thwarts:"
852 " UTRAN disallows GSM AKA altogether");
853 gsup_expect_tx("0b010809710000000156f0"); /* OSMO_GSUP_MSGT_AUTH_FAIL_REPORT */
854 expect_release_clear(via_ran);
855 ms_sends_msg("0554" "e229c19e" /* Only the SRES half of the RES */);
856 VERBOSE_ASSERT(lu_result_sent, == RES_REJECT, "%d");
857 ASSERT_RELEASE_CLEAR(via_ran);
858
859 EXPECT_CONN_COUNT(0);
860 clear_vlr();
861}
862
863static void test_umts_authen_only_sres_geran()
864{
865 comment_start();
866 _test_umts_authen_only_sres(RAN_GERAN_A);
867 comment_end();
868}
869
870static void test_umts_authen_only_sres_utran()
871{
872 comment_start();
873 _test_umts_authen_only_sres(RAN_UTRAN_IU);
874 comment_end();
875}
876
Neels Hofmeyr15ed4262018-03-10 04:02:44 +0100877
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100878msc_vlr_test_func_t msc_vlr_tests[] = {
879 test_umts_authen_geran,
880 test_umts_authen_utran,
881 test_umts_authen_resync_geran,
882 test_umts_authen_resync_utran,
Neels Hofmeyr15ed4262018-03-10 04:02:44 +0100883 test_umts_authen_too_short_res_geran,
884 test_umts_authen_too_short_res_utran,
Neels Hofmeyrc6d20dd2018-03-10 04:03:43 +0100885 test_umts_authen_too_long_res_geran,
886 test_umts_authen_too_long_res_utran,
Neels Hofmeyr31adcae2018-03-10 04:08:45 +0100887 test_umts_authen_only_sres_geran,
888 test_umts_authen_only_sres_utran,
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100889 NULL
890};