blob: 8528b98b9ddcf9961d284b30f07395856c8e7c00 [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"
Harald Welte0df904d2018-12-03 11:00:04 +010025#include "stubs.h"
Neels Hofmeyr6a29d322017-01-25 15:04:16 +010026
Neels Hofmeyr7814a832018-12-26 00:40:18 +010027static void _test_umts_authen(enum osmo_rat_type via_ran)
Neels Hofmeyr6a29d322017-01-25 15:04:16 +010028{
29 struct vlr_subscr *vsub;
30 const char *imsi = "901700000010650";
Neels Hofmeyr84da6b12016-05-20 21:59:55 +020031 const char *sms =
32 "09" /* SMS messages */
33 "01" /* CP-DATA */
34 "58" /* length */
35 "01" /* Network to MS */
36 "00" /* reference */
37 /* originator (gsm411_send_sms() hardcodes this weird nr) */
38 "0791" "447758100650" /* 447785016005 */
39 "00" /* dest */
40 /* SMS TPDU */
41 "4c" /* len */
42 "00" /* SMS deliver */
43 "05802443f2" /* originating address 42342 */
44 "00" /* TP-PID */
45 "00" /* GSM default alphabet */
46 "071010" /* Y-M-D (from wrapped gsm340_gen_scts())*/
47 "000000" /* H-M-S */
48 "00" /* GMT+0 */
49 "44" /* data length */
50 "5079da1e1ee7416937485e9ea7c965373d1d6683c270383b3d0e"
51 "d3d36ff71c949e83c22072799e9687c5ec32a81d96afcbf4b4fb"
52 "0c7ac3e9e9b7db05";
Neels Hofmeyr6a29d322017-01-25 15:04:16 +010053
54 net->authentication_required = true;
Neels Hofmeyr84da6b12016-05-20 21:59:55 +020055 net->vlr->cfg.assign_tmsi = true;
Neels Hofmeyr6a29d322017-01-25 15:04:16 +010056 rx_from_ran = via_ran;
57
58 btw("Location Update request causes a GSUP Send Auth Info request to HLR");
59 lu_result_sent = RES_NONE;
60 gsup_expect_tx("080108" "09710000000156f0");
61 ms_sends_msg("0508" /* MM LU */
62 "7" /* ciph key seq: no key available */
63 "0" /* LU type: normal */
64 "ffffff" "0000" /* LAI, LAC */
65 "57" /* classmark 1: R99, early classmark, no power lvl */
66 "089910070000106005" /* IMSI */
67 "3303575886" /* classmark 2 */
68 );
69 OSMO_ASSERT(gsup_tx_confirmed);
70 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
71
72 btw("from HLR, rx _SEND_AUTH_INFO_RESULT; VLR sends Auth Req to MS");
73 /* based on auc_3g:
74 * K = 'EB215756028D60E3275E613320AEC880',
75 * OPC = 'FB2A3D1B360F599ABAB99DB8669F8308'
76 * SQN = 0
77 */
78 auth_request_sent = false;
79 auth_request_expect_rand = "39fa2f4e3d523d8619a73b4f65c3e14d";
80 auth_request_expect_autn = "8704f5ba55f30000d2ee44b22c8ea919";
81 gsup_rx("0a"
82 /* imsi */
83 "0108" "09710000000156f0"
84 /* 5 auth vectors... */
85 /* TL TL rand */
86 "0362" "2010" "39fa2f4e3d523d8619a73b4f65c3e14d"
87 /* TL sres TL kc */
88 "2104" "9b36efdf" "2208" "059a4f668f6fbe39"
89 /* TL 3G IK */
90 "2310" "27497388b6cb044648f396aa155b95ef"
91 /* TL 3G CK */
92 "2410" "f64735036e5871319c679f4742a75ea1"
93 /* TL AUTN */
94 "2510" "8704f5ba55f30000d2ee44b22c8ea919"
95 /* TL RES */
96 "2708" "e229c19e791f2e41"
97 /* TL TL rand */
98 "0362" "2010" "c187a53a5e6b9d573cac7c74451fd46d"
99 "2104" "85aa3130" "2208" "d3d50a000bf04f6e"
100 "2310" "1159ec926a50e98c034a6b7d7c9f418d"
101 "2410" "df3a03d9ca5335641efc8e36d76cd20b"
102 "2510" "1843a645b98d00005b2d666af46c45d9"
103 "2708" "7db47cf7f81e4dc7"
104 "0362" "2010" "efa9c29a9742148d5c9070348716e1bb"
105 "2104" "69d5f9fb" "2208" "3df176f0c29f1a3d"
106 "2310" "eb50e770ddcc3060101d2f43b6c2b884"
107 "2410" "76542abce5ff9345b0e8947f4c6e019c"
108 "2510" "f9375e6d41e1000096e7fe4ff1c27e39"
109 "2708" "706f996719ba609c"
110 "0362" "2010" "f023d5a3b24726e0631b64b3840f8253"
111 "2104" "d570c03f" "2208" "ec011be8919883d6"
112 "2310" "c4e58af4ba43f3bcd904e16984f086d7"
113 "2410" "0593f65e752e5cb7f473862bda05aa0a"
114 "2510" "541ff1f077270000c5ea00d658bc7e9a"
115 "2708" "3fd26072eaa2a04d"
116 "0362" "2010" "2f8f90c780d6a9c0c53da7ac57b6707e"
117 "2104" "b072446f220823f39f9f425ad6e6"
118 "2310" "65af0527fda95b0dc5ae4aa515cdf32f"
119 "2410" "537c3b35a3b13b08d08eeb28098f45cc"
120 "2510" "4bf4e564f75300009bc796706bc65744"
121 "2708" "0edb0eadbea94ac2",
122 NULL);
123 VERBOSE_ASSERT(auth_request_sent, == true, "%d");
124 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
125
Neels Hofmeyr7814a832018-12-26 00:40:18 +0100126 if (via_ran == OSMO_RAT_GERAN_A) {
Neels Hofmeyr84da6b12016-05-20 21:59:55 +0200127 btw("MS sends Authen Response, VLR accepts and sends GSUP LU Req to HLR");
Neels Hofmeyrd0756b12018-09-28 02:41:39 +0200128 gsup_expect_tx("04010809710000000156f0280102");
Neels Hofmeyr84da6b12016-05-20 21:59:55 +0200129 ms_sends_msg("0554" "e229c19e" "2104" "791f2e41");
130 VERBOSE_ASSERT(gsup_tx_confirmed, == true, "%d");
131 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
132 } else {
133 /* On UTRAN */
134 btw("MS sends Authen Response, VLR accepts and sends SecurityModeControl");
Neels Hofmeyrdbabfd32018-03-10 02:06:47 +0100135 expect_security_mode_ctrl(NULL, "27497388b6cb044648f396aa155b95ef");
Neels Hofmeyr84da6b12016-05-20 21:59:55 +0200136 ms_sends_msg("0554" "e229c19e" "2104" "791f2e41");
Neels Hofmeyrdbabfd32018-03-10 02:06:47 +0100137 VERBOSE_ASSERT(security_mode_ctrl_sent, == true, "%d");
Neels Hofmeyr84da6b12016-05-20 21:59:55 +0200138 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
139
140 btw("MS sends SecurityModeControl acceptance, VLR accepts and sends GSUP LU Req to HLR");
Neels Hofmeyrd0756b12018-09-28 02:41:39 +0200141 gsup_expect_tx("04010809710000000156f0280102");
Neels Hofmeyr84da6b12016-05-20 21:59:55 +0200142 ms_sends_security_mode_complete();
143 VERBOSE_ASSERT(gsup_tx_confirmed, == true, "%d");
144 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
145 }
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100146
147 btw("HLR sends _INSERT_DATA_REQUEST, VLR responds with _INSERT_DATA_RESULT");
148 gsup_rx("10010809710000000156f00804032443f2",
149 "12010809710000000156f0");
150 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
151
152 btw("HLR also sends GSUP _UPDATE_LOCATION_RESULT");
153 gsup_rx("06010809710000000156f0", NULL);
154
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100155 VERBOSE_ASSERT(lu_result_sent, == RES_ACCEPT, "%d");
Neels Hofmeyr84da6b12016-05-20 21:59:55 +0200156
157 btw("a LU Accept with a new TMSI was sent, waiting for TMSI Realloc Compl");
158 EXPECT_CONN_COUNT(1);
159 EXPECT_ACCEPTED(false);
160 thwart_rx_non_initial_requests();
161
162 btw("even though the TMSI is not acked, we can already find the subscr with it");
163 vsub = vlr_subscr_find_by_tmsi(net->vlr, 0x03020100);
164 VERBOSE_ASSERT(vsub != NULL, == true, "%d");
165 VERBOSE_ASSERT(strcmp(vsub->imsi, imsi), == 0, "%d");
166 VERBOSE_ASSERT(vsub->tmsi_new, == 0x03020100, "0x%08x");
167 VERBOSE_ASSERT(vsub->tmsi, == GSM_RESERVED_TMSI, "0x%08x");
168 vlr_subscr_put(vsub);
169
170 btw("MS sends TMSI Realloc Complete");
Philipp Maierfbf66102017-04-09 12:32:51 +0200171 expect_release_clear(via_ran);
Neels Hofmeyr84da6b12016-05-20 21:59:55 +0200172 ms_sends_msg("055b");
Philipp Maierfbf66102017-04-09 12:32:51 +0200173 ASSERT_RELEASE_CLEAR(via_ran);
Neels Hofmeyr4068ab22018-04-01 20:55:54 +0200174 bss_rnc_sends_release_clear_complete(via_ran);
Neels Hofmeyr84da6b12016-05-20 21:59:55 +0200175
176 btw("LU was successful, and the conn has already been closed");
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100177 EXPECT_CONN_COUNT(0);
178
179 BTW("after a while, a new conn sends a CM Service Request. VLR responds with Auth Req, 2nd auth vector");
180 auth_request_sent = false;
181 auth_request_expect_rand = "c187a53a5e6b9d573cac7c74451fd46d";
182 auth_request_expect_autn = "1843a645b98d00005b2d666af46c45d9";
183 cm_service_result_sent = RES_NONE;
184 ms_sends_msg("052478"
185 "03575886" /* classmark 2 */
186 "089910070000106005" /* IMSI */);
187 OSMO_ASSERT(g_conn);
Neels Hofmeyr4d3a66b2018-03-31 18:45:59 +0200188 OSMO_ASSERT(g_conn->fi);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100189 OSMO_ASSERT(g_conn->vsub);
190 VERBOSE_ASSERT(cm_service_result_sent, == RES_NONE, "%d");
191 VERBOSE_ASSERT(auth_request_sent, == true, "%d");
192
193 btw("needs auth, not yet accepted");
194 EXPECT_ACCEPTED(false);
195 thwart_rx_non_initial_requests();
196
Neels Hofmeyr7814a832018-12-26 00:40:18 +0100197 if (via_ran == OSMO_RAT_GERAN_A) {
Neels Hofmeyr84da6b12016-05-20 21:59:55 +0200198 btw("MS sends Authen Response, VLR accepts with a CM Service Accept");
199 gsup_expect_tx(NULL);
200 ms_sends_msg("0554" "7db47cf7" "2104" "f81e4dc7"); /* 2nd vector's res, s.a. */
201 VERBOSE_ASSERT(cm_service_result_sent, == RES_ACCEPT, "%d");
202 } else {
203 /* On UTRAN */
204 btw("MS sends Authen Response, VLR accepts and sends SecurityModeControl");
Neels Hofmeyrdbabfd32018-03-10 02:06:47 +0100205 expect_security_mode_ctrl(NULL, "1159ec926a50e98c034a6b7d7c9f418d");
Neels Hofmeyr84da6b12016-05-20 21:59:55 +0200206 ms_sends_msg("0554" "7db47cf7" "2104" "f81e4dc7"); /* 2nd vector's res, s.a. */
Neels Hofmeyrdbabfd32018-03-10 02:06:47 +0100207 VERBOSE_ASSERT(security_mode_ctrl_sent, == true, "%d");
Neels Hofmeyr84da6b12016-05-20 21:59:55 +0200208 VERBOSE_ASSERT(cm_service_result_sent, == RES_NONE, "%d");
209
210 btw("MS sends SecurityModeControl acceptance, VLR accepts; above Ciphering is an implicit CM Service Accept");
211 ms_sends_security_mode_complete();
212 VERBOSE_ASSERT(cm_service_result_sent, == RES_NONE, "%d");
213 }
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100214
Vadim Yanitskiy27605852018-06-15 23:57:30 +0700215 /* Release connection */
Philipp Maierfbf66102017-04-09 12:32:51 +0200216 expect_release_clear(via_ran);
Vadim Yanitskiy27605852018-06-15 23:57:30 +0700217 conn_conclude_cm_service_req(g_conn, via_ran);
Neels Hofmeyr4068ab22018-04-01 20:55:54 +0200218 bss_rnc_sends_release_clear_complete(via_ran);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100219
220 btw("all requests serviced, conn has been released");
221 EXPECT_CONN_COUNT(0);
222
223 BTW("an SMS is sent, MS is paged");
224 paging_expect_imsi(imsi);
225 paging_sent = false;
226 vsub = vlr_subscr_find_by_imsi(net->vlr, imsi);
227 OSMO_ASSERT(vsub);
228 VERBOSE_ASSERT(llist_count(&vsub->cs.requests), == 0, "%d");
229
230 send_sms(vsub, vsub,
231 "Privacy in residential applications is a desirable"
232 " marketing option.");
233
234 VERBOSE_ASSERT(llist_count(&vsub->cs.requests), == 1, "%d");
235 vlr_subscr_put(vsub);
236 vsub = NULL;
237 VERBOSE_ASSERT(paging_sent, == true, "%d");
238 VERBOSE_ASSERT(paging_stopped, == false, "%d");
239
240 btw("the subscriber and its pending request should remain");
241 vsub = vlr_subscr_find_by_imsi(net->vlr, imsi);
242 OSMO_ASSERT(vsub);
243 VERBOSE_ASSERT(llist_count(&vsub->cs.requests), == 1, "%d");
244 vlr_subscr_put(vsub);
245
246 btw("MS replies with Paging Response, and VLR sends Auth Request with third key");
247 auth_request_sent = false;
248 auth_request_expect_rand = "efa9c29a9742148d5c9070348716e1bb";
249 auth_request_expect_autn = "f9375e6d41e1000096e7fe4ff1c27e39";
250 ms_sends_msg("062707"
251 "03575886" /* classmark 2 */
252 "089910070000106005" /* IMSI */);
253 VERBOSE_ASSERT(auth_request_sent, == true, "%d");
254
255 btw("needs auth, not yet accepted");
256 EXPECT_ACCEPTED(false);
257 thwart_rx_non_initial_requests();
258
Neels Hofmeyr7814a832018-12-26 00:40:18 +0100259 if (via_ran == OSMO_RAT_GERAN_A) {
Neels Hofmeyr84da6b12016-05-20 21:59:55 +0200260 btw("MS sends Authen Response, VLR accepts and sends pending SMS");
261 dtap_expect_tx(sms);
262 ms_sends_msg("0554" "706f9967" "2104" "19ba609c"); /* 3nd vector's res, s.a. */
263 VERBOSE_ASSERT(dtap_tx_confirmed, == true, "%d");
264 VERBOSE_ASSERT(paging_stopped, == true, "%d");
265 } else {
266 /* On UTRAN */
267 btw("MS sends Authen Response, VLR accepts and sends SecurityModeControl");
Neels Hofmeyrdbabfd32018-03-10 02:06:47 +0100268 expect_security_mode_ctrl(NULL, "eb50e770ddcc3060101d2f43b6c2b884");
Neels Hofmeyr84da6b12016-05-20 21:59:55 +0200269 ms_sends_msg("0554" "706f9967" "2104" "19ba609c"); /* 3nd vector's res, s.a. */
Neels Hofmeyrdbabfd32018-03-10 02:06:47 +0100270 VERBOSE_ASSERT(security_mode_ctrl_sent, == true, "%d");
Neels Hofmeyr84da6b12016-05-20 21:59:55 +0200271 VERBOSE_ASSERT(paging_stopped, == false, "%d");
272
273 btw("MS sends SecurityModeControl acceptance, VLR accepts and sends SMS");
274 dtap_expect_tx(sms);
275 ms_sends_security_mode_complete();
276 VERBOSE_ASSERT(paging_stopped, == true, "%d");
277 }
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100278
279 btw("SMS was delivered, no requests pending for subscr");
280 vsub = vlr_subscr_find_by_imsi(net->vlr, imsi);
281 OSMO_ASSERT(vsub);
282 VERBOSE_ASSERT(llist_count(&vsub->cs.requests), == 0, "%d");
283 vlr_subscr_put(vsub);
284
285 btw("conn is still open to wait for SMS ack dance");
286 EXPECT_CONN_COUNT(1);
287
288 btw("MS replies with CP-ACK for received SMS");
289 ms_sends_msg("8904");
290 EXPECT_CONN_COUNT(1);
291
292 btw("MS also sends RP-ACK, MSC in turn sends CP-ACK for that");
293 dtap_expect_tx("0904");
Philipp Maierfbf66102017-04-09 12:32:51 +0200294 expect_release_clear(via_ran);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100295 ms_sends_msg("890106020041020000");
296 VERBOSE_ASSERT(dtap_tx_confirmed, == true, "%d");
Philipp Maierfbf66102017-04-09 12:32:51 +0200297 ASSERT_RELEASE_CLEAR(via_ran);
Neels Hofmeyr4068ab22018-04-01 20:55:54 +0200298 bss_rnc_sends_release_clear_complete(via_ran);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100299
300 btw("SMS is done, conn is gone");
301 EXPECT_CONN_COUNT(0);
302
303 BTW("subscriber detaches");
Philipp Maierfbf66102017-04-09 12:32:51 +0200304 expect_release_clear(via_ran);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100305 ms_sends_msg("050130"
306 "089910070000106005" /* IMSI */);
Philipp Maierfbf66102017-04-09 12:32:51 +0200307 ASSERT_RELEASE_CLEAR(via_ran);
Neels Hofmeyr4068ab22018-04-01 20:55:54 +0200308 bss_rnc_sends_release_clear_complete(via_ran);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100309
310 EXPECT_CONN_COUNT(0);
311 clear_vlr();
312}
313
Neels Hofmeyrf3d81f62018-03-02 01:05:38 +0100314static void test_umts_authen_geran()
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100315{
Neels Hofmeyrdfdc61d2018-03-02 00:40:58 +0100316 comment_start();
Neels Hofmeyr7814a832018-12-26 00:40:18 +0100317 _test_umts_authen(OSMO_RAT_GERAN_A);
Neels Hofmeyrdfdc61d2018-03-02 00:40:58 +0100318 comment_end();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100319}
320
Neels Hofmeyrf3d81f62018-03-02 01:05:38 +0100321static void test_umts_authen_utran()
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100322{
Neels Hofmeyrdfdc61d2018-03-02 00:40:58 +0100323 comment_start();
Neels Hofmeyr7814a832018-12-26 00:40:18 +0100324 _test_umts_authen(OSMO_RAT_UTRAN_IU);
Neels Hofmeyrdfdc61d2018-03-02 00:40:58 +0100325 comment_end();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100326}
327
328#define RECALC_AUTS 0
329
330#if RECALC_AUTS
331typedef uint8_t u8;
332extern int milenage_f2345(const u8 *opc, const u8 *k, const u8 *_rand,
333 u8 *res, u8 *ck, u8 *ik, u8 *ak, u8 *akstar);
334extern int milenage_f1(const u8 *opc, const u8 *k, const u8 *_rand,
335 const u8 *sqn, const u8 *amf, u8 *mac_a, u8 *mac_s);
336#endif
337
Neels Hofmeyr7814a832018-12-26 00:40:18 +0100338static void _test_umts_authen_resync(enum osmo_rat_type via_ran)
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100339{
Neels Hofmeyr84da6b12016-05-20 21:59:55 +0200340 struct vlr_subscr *vsub;
341 const char *imsi = "901700000010650";
342
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100343 net->authentication_required = true;
Neels Hofmeyr84da6b12016-05-20 21:59:55 +0200344 net->vlr->cfg.assign_tmsi = true;
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100345 rx_from_ran = via_ran;
346
347 btw("Location Update request causes a GSUP Send Auth Info request to HLR");
348 lu_result_sent = RES_NONE;
349 gsup_expect_tx("080108" "09710000000156f0");
350 ms_sends_msg("0508" /* MM LU */
351 "7" /* ciph key seq: no key available */
352 "0" /* LU type: normal */
353 "ffffff" "0000" /* LAI, LAC */
354 "57" /* classmark 1: R99, early classmark, no power lvl */
355 "089910070000106005" /* IMSI */
356 "3303575886" /* classmark 2 */
357 );
358 OSMO_ASSERT(gsup_tx_confirmed);
359 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
360
361 btw("from HLR, rx _SEND_AUTH_INFO_RESULT; VLR sends Auth Req to MS");
362 /* based on auc_3g:
363 * K = 'EB215756028D60E3275E613320AEC880',
364 * OPC = 'FB2A3D1B360F599ABAB99DB8669F8308'
365 * SQN = 0
366 */
367 auth_request_sent = false;
368 auth_request_expect_rand = "39fa2f4e3d523d8619a73b4f65c3e14d";
369 auth_request_expect_autn = "8704f5ba55f30000d2ee44b22c8ea919";
370 gsup_rx("0a"
371 /* imsi */
372 "0108" "09710000000156f0"
373 /* auth vectors... */
374 /* TL TL rand */
375 "0362" "2010" "39fa2f4e3d523d8619a73b4f65c3e14d"
376 /* TL sres TL kc */
377 "2104" "9b36efdf" "2208" "059a4f668f6fbe39"
378 /* TL 3G IK */
379 "2310" "27497388b6cb044648f396aa155b95ef"
380 /* TL 3G CK */
381 "2410" "f64735036e5871319c679f4742a75ea1"
382 /* TL AUTN */
383 "2510" "8704f5ba55f30000d2ee44b22c8ea919"
384 /* TL RES */
385 "2708" "e229c19e791f2e41"
386 ,NULL);
387 VERBOSE_ASSERT(auth_request_sent, == true, "%d");
388 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
389
390 /* The AUTN sent was 8704f5ba55f30000d2ee44b22c8ea919
391 * (see expected error output)
392 * with the first 6 bytes being SQN ^ AK.
393 * K = EB215756028D60E3275E613320AEC880
394 * OPC = FB2A3D1B360F599ABAB99DB8669F8308
395 * RAND = 39fa2f4e3d523d8619a73b4f65c3e14d
396 * --milenage-f5-->
397 * AK = 8704f5ba55f3
398 *
399 * The first six bytes are 8704f5ba55f3,
400 * and 8704f5ba55f3 ^ AK = 0.
401 * --> SQN = 0.
402 *
403 * Say the USIM doesn't like that, let's say it is at SQN 23.
404 * SQN_MS = 000000000017
405 *
406 * AUTS = Conc(SQN_MS) || MAC-S
407 * Conc(SQN_MS) = SQN_MS ⊕ f5*[K](RAND)
408 * MAC-S = f1*[K] (SQN MS || RAND || AMF)
409 *
410 * f5*--> Conc(SQN_MS) = 000000000017 ^ 979498b1f73a
411 * = 979498b1f72d
412 * AMF = 0000 (TS 33.102 v7.0.0, 6.3.3)
413 *
414 * MAC-S = f1*[K] (000000000017 || 39fa2f4e3d523d8619a73b4f65c3e14d || 0000)
415 * = 3e28c59fa2e72f9c
416 *
417 * AUTS = 979498b1f72d || 3e28c59fa2e72f9c
418 */
419#if RECALC_AUTS
420 uint8_t ak[6];
421 uint8_t akstar[6];
422 uint8_t opc[16];
423 uint8_t k[16];
424 uint8_t rand[16];
425 osmo_hexparse("EB215756028D60E3275E613320AEC880", k, sizeof(k));
426 osmo_hexparse("FB2A3D1B360F599ABAB99DB8669F8308", opc, sizeof(opc));
427 osmo_hexparse("39fa2f4e3d523d8619a73b4f65c3e14d", rand, sizeof(rand));
428 milenage_f2345(opc, k, rand, NULL, NULL, NULL, ak, akstar);
429 btw("ak = %s", osmo_hexdump_nospc(ak, sizeof(ak)));
430 btw("akstar = %s", osmo_hexdump_nospc(akstar, sizeof(akstar)));
431
432 uint8_t sqn_ms[6] = { 0, 0, 0, 0, 0, 23 };
433 uint8_t amf[2] = { 0 };
434 uint8_t mac_s[8];
435 milenage_f1(opc, k, rand, sqn_ms, amf, NULL, mac_s);
436 btw("mac_s = %s", osmo_hexdump_nospc(mac_s, sizeof(mac_s)));
437 /* verify valid AUTS resulting in SQN 23 with:
438 osmo-auc-gen -3 -a milenage -k EB215756028D60E3275E613320AEC880 \
439 -o FB2A3D1B360F599ABAB99DB8669F8308 \
440 -r 39fa2f4e3d523d8619a73b4f65c3e14d \
441 -A 979498b1f72d3e28c59fa2e72f9c
442 */
443#endif
444
445 btw("MS sends Authen Failure with Resync cause, VLR sends GSUP to HLR to resync");
446 auth_request_sent = false;
447 gsup_expect_tx("08" /* OSMO_GSUP_MSGT_SEND_AUTH_INFO_REQUEST */
448 "0108" "09710000000156f0" /* IMSI */
449 "260e" "979498b1f72d3e28c59fa2e72f9c" /* AUTS */
450 "2010" "39fa2f4e3d523d8619a73b4f65c3e14d" /* RAND */);
451 ms_sends_msg("051c" /* 05 = MM; 1c = Auth Failure */
452 "15" /* cause = Synch Failure */
453 "220e" "979498b1f72d3e28c59fa2e72f9c" /* AUTS */);
454 VERBOSE_ASSERT(gsup_tx_confirmed, == true, "%d");
455 VERBOSE_ASSERT(auth_request_sent, == false, "%d");
456 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
457
458 btw("HLR replies with new tuples");
459 auth_request_sent = false;
460 auth_request_expect_rand = "0f1feb1623e1bf626334e37ec448ac18";
461 auth_request_expect_autn = "02a83f62e9470000660d51afc75f169d";
462 gsup_rx("0a"
463 /* imsi */
464 "0108" "09710000000156f0"
465 /* 1 auth vector */
466 /* TL TL rand */
467 "0362" "2010" "0f1feb1623e1bf626334e37ec448ac18"
468 /* TL sres TL kc */
469 "2104" "efde99da" "2208" "14778c855c523730"
470 /* TL 3G IK */
471 "2310" "8a90c769b7272f3bb7a1c1fbb1ea9349"
472 /* TL 3G CK */
473 "2410" "43ffc1cf8c89a7fd6ab94bd8d6162cbf"
474 /* TL AUTN */
475 "2510" "02a83f62e9470000660d51afc75f169d"
476 /* TL RES */
477 "2708" "1df5f0b4f22b696e"
478 /* TL TL rand */
479 "0362" "2010" "ac21d34937b4e1142a2c757af2949319"
480 /* TL sres TL kc */
481 "2104" "7818bfdc" "2208" "d175571f41f314a4"
482 /* TL 3G IK */
483 "2310" "ff8edbceb6dd24799c77c3b9a6790c10"
484 /* TL 3G CK */
485 "2410" "157c39022ca9d885a7f0766a7dfee448"
486 /* TL AUTN */
487 "2510" "8a43b91898e500002cf354c6f5d1f8c3"
488 /* TL RES */
489 "2708" "f748a7078f5018db"
490 ,NULL);
491
492 VERBOSE_ASSERT(auth_request_sent, == true, "%d");
493 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
494
Neels Hofmeyr7814a832018-12-26 00:40:18 +0100495 if (via_ran == OSMO_RAT_GERAN_A) {
Neels Hofmeyr84da6b12016-05-20 21:59:55 +0200496 btw("MS sends Authen Response, VLR accepts and sends GSUP LU Req to HLR");
Neels Hofmeyrd0756b12018-09-28 02:41:39 +0200497 gsup_expect_tx("04010809710000000156f0280102");
Neels Hofmeyr84da6b12016-05-20 21:59:55 +0200498 ms_sends_msg("0554" "1df5f0b4" "2104" "f22b696e");
499 VERBOSE_ASSERT(gsup_tx_confirmed, == true, "%d");
500 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
501 } else {
502 /* On UTRAN */
503 btw("MS sends Authen Response, VLR accepts and sends SecurityModeControl");
Neels Hofmeyrdbabfd32018-03-10 02:06:47 +0100504 expect_security_mode_ctrl(NULL, "8a90c769b7272f3bb7a1c1fbb1ea9349");
Neels Hofmeyr84da6b12016-05-20 21:59:55 +0200505 ms_sends_msg("0554" "1df5f0b4" "2104" "f22b696e");
Neels Hofmeyrdbabfd32018-03-10 02:06:47 +0100506 VERBOSE_ASSERT(security_mode_ctrl_sent, == true, "%d");
Neels Hofmeyr84da6b12016-05-20 21:59:55 +0200507 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
508
509 btw("MS sends SecurityModeControl acceptance, VLR accepts and sends GSUP LU Req to HLR");
Neels Hofmeyrd0756b12018-09-28 02:41:39 +0200510 gsup_expect_tx("04010809710000000156f0280102");
Neels Hofmeyr84da6b12016-05-20 21:59:55 +0200511 ms_sends_security_mode_complete();
512 VERBOSE_ASSERT(gsup_tx_confirmed, == true, "%d");
513 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
514 }
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100515
516 btw("HLR sends _INSERT_DATA_REQUEST, VLR responds with _INSERT_DATA_RESULT");
517 gsup_rx("10010809710000000156f00804032443f2",
518 "12010809710000000156f0");
519 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
520
521 btw("HLR also sends GSUP _UPDATE_LOCATION_RESULT");
522 gsup_rx("06010809710000000156f0", NULL);
523
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100524 VERBOSE_ASSERT(lu_result_sent, == RES_ACCEPT, "%d");
Neels Hofmeyr84da6b12016-05-20 21:59:55 +0200525
526 btw("a LU Accept with a new TMSI was sent, waiting for TMSI Realloc Compl");
527 EXPECT_CONN_COUNT(1);
528 EXPECT_ACCEPTED(false);
529 thwart_rx_non_initial_requests();
530
531 btw("even though the TMSI is not acked, we can already find the subscr with it");
532 vsub = vlr_subscr_find_by_tmsi(net->vlr, 0x03020100);
533 VERBOSE_ASSERT(vsub != NULL, == true, "%d");
534 VERBOSE_ASSERT(strcmp(vsub->imsi, imsi), == 0, "%d");
535 VERBOSE_ASSERT(vsub->tmsi_new, == 0x03020100, "0x%08x");
536 VERBOSE_ASSERT(vsub->tmsi, == GSM_RESERVED_TMSI, "0x%08x");
537 vlr_subscr_put(vsub);
538
539 btw("MS sends TMSI Realloc Complete");
Philipp Maierfbf66102017-04-09 12:32:51 +0200540 expect_release_clear(via_ran);
Neels Hofmeyr84da6b12016-05-20 21:59:55 +0200541 ms_sends_msg("055b");
Philipp Maierfbf66102017-04-09 12:32:51 +0200542 ASSERT_RELEASE_CLEAR(via_ran);
Neels Hofmeyr4068ab22018-04-01 20:55:54 +0200543 bss_rnc_sends_release_clear_complete(via_ran);
Neels Hofmeyr84da6b12016-05-20 21:59:55 +0200544
545 btw("LU was successful, and the conn has already been closed");
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100546 EXPECT_CONN_COUNT(0);
547
548 clear_vlr();
549}
550
Neels Hofmeyrf3d81f62018-03-02 01:05:38 +0100551static void test_umts_authen_resync_geran()
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100552{
Neels Hofmeyrdfdc61d2018-03-02 00:40:58 +0100553 comment_start();
Neels Hofmeyr7814a832018-12-26 00:40:18 +0100554 _test_umts_authen_resync(OSMO_RAT_GERAN_A);
Neels Hofmeyrdfdc61d2018-03-02 00:40:58 +0100555 comment_end();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100556}
557
Neels Hofmeyrf3d81f62018-03-02 01:05:38 +0100558static void test_umts_authen_resync_utran()
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100559{
Neels Hofmeyrdfdc61d2018-03-02 00:40:58 +0100560 comment_start();
Neels Hofmeyr7814a832018-12-26 00:40:18 +0100561 _test_umts_authen_resync(OSMO_RAT_UTRAN_IU);
Neels Hofmeyrdfdc61d2018-03-02 00:40:58 +0100562 comment_end();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100563}
564
Neels Hofmeyr7814a832018-12-26 00:40:18 +0100565static void _test_umts_authen_too_short_res(enum osmo_rat_type via_ran)
Neels Hofmeyr15ed4262018-03-10 04:02:44 +0100566{
567 net->authentication_required = true;
568 net->vlr->cfg.assign_tmsi = true;
569 rx_from_ran = via_ran;
570
571 btw("Location Update request causes a GSUP Send Auth Info request to HLR");
572 lu_result_sent = RES_NONE;
573 gsup_expect_tx("080108" "09710000000156f0");
574 ms_sends_msg("0508" /* MM LU */
575 "7" /* ciph key seq: no key available */
576 "0" /* LU type: normal */
577 "ffffff" "0000" /* LAI, LAC */
578 "57" /* classmark 1: R99, early classmark, no power lvl */
579 "089910070000106005" /* IMSI */
580 "3303575886" /* classmark 2 */
581 );
582 OSMO_ASSERT(gsup_tx_confirmed);
583 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
584
585 btw("from HLR, rx _SEND_AUTH_INFO_RESULT; VLR sends Auth Req to MS");
586 /* based on auc_3g:
587 * K = 'EB215756028D60E3275E613320AEC880',
588 * OPC = 'FB2A3D1B360F599ABAB99DB8669F8308'
589 * SQN = 0
590 */
591 auth_request_sent = false;
592 auth_request_expect_rand = "39fa2f4e3d523d8619a73b4f65c3e14d";
593 auth_request_expect_autn = "8704f5ba55f30000d2ee44b22c8ea919";
594 gsup_rx("0a"
595 /* imsi */
596 "0108" "09710000000156f0"
597 /* 5 auth vectors... */
598 /* TL TL rand */
599 "0362" "2010" "39fa2f4e3d523d8619a73b4f65c3e14d"
600 /* TL sres TL kc */
601 "2104" "9b36efdf" "2208" "059a4f668f6fbe39"
602 /* TL 3G IK */
603 "2310" "27497388b6cb044648f396aa155b95ef"
604 /* TL 3G CK */
605 "2410" "f64735036e5871319c679f4742a75ea1"
606 /* TL AUTN */
607 "2510" "8704f5ba55f30000d2ee44b22c8ea919"
608 /* TL RES */
609 "2708" "e229c19e791f2e41"
610 /* TL TL rand */
611 "0362" "2010" "c187a53a5e6b9d573cac7c74451fd46d"
612 "2104" "85aa3130" "2208" "d3d50a000bf04f6e"
613 "2310" "1159ec926a50e98c034a6b7d7c9f418d"
614 "2410" "df3a03d9ca5335641efc8e36d76cd20b"
615 "2510" "1843a645b98d00005b2d666af46c45d9"
616 "2708" "7db47cf7f81e4dc7"
617 "0362" "2010" "efa9c29a9742148d5c9070348716e1bb"
618 "2104" "69d5f9fb" "2208" "3df176f0c29f1a3d"
619 "2310" "eb50e770ddcc3060101d2f43b6c2b884"
620 "2410" "76542abce5ff9345b0e8947f4c6e019c"
621 "2510" "f9375e6d41e1000096e7fe4ff1c27e39"
622 "2708" "706f996719ba609c"
623 "0362" "2010" "f023d5a3b24726e0631b64b3840f8253"
624 "2104" "d570c03f" "2208" "ec011be8919883d6"
625 "2310" "c4e58af4ba43f3bcd904e16984f086d7"
626 "2410" "0593f65e752e5cb7f473862bda05aa0a"
627 "2510" "541ff1f077270000c5ea00d658bc7e9a"
628 "2708" "3fd26072eaa2a04d"
629 "0362" "2010" "2f8f90c780d6a9c0c53da7ac57b6707e"
630 "2104" "b072446f220823f39f9f425ad6e6"
631 "2310" "65af0527fda95b0dc5ae4aa515cdf32f"
632 "2410" "537c3b35a3b13b08d08eeb28098f45cc"
633 "2510" "4bf4e564f75300009bc796706bc65744"
634 "2708" "0edb0eadbea94ac2",
635 NULL);
636 VERBOSE_ASSERT(auth_request_sent, == true, "%d");
637 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
638
639 btw("MS sends Authen Response of wrong RES size, VLR thwarts");
640 gsup_expect_tx("0b010809710000000156f0"); /* OSMO_GSUP_MSGT_AUTH_FAIL_REPORT */
641 expect_release_clear(via_ran);
642 ms_sends_msg("0554" "e229c19e" "2103" "791f2e" /* nipped one byte */);
643 VERBOSE_ASSERT(lu_result_sent, == RES_REJECT, "%d");
644 ASSERT_RELEASE_CLEAR(via_ran);
Neels Hofmeyr4068ab22018-04-01 20:55:54 +0200645 bss_rnc_sends_release_clear_complete(via_ran);
Neels Hofmeyr15ed4262018-03-10 04:02:44 +0100646
647 EXPECT_CONN_COUNT(0);
648 clear_vlr();
649}
650
651static void test_umts_authen_too_short_res_geran()
652{
653 comment_start();
Neels Hofmeyr7814a832018-12-26 00:40:18 +0100654 _test_umts_authen_too_short_res(OSMO_RAT_GERAN_A);
Neels Hofmeyr15ed4262018-03-10 04:02:44 +0100655 comment_end();
656}
657
658static void test_umts_authen_too_short_res_utran()
659{
660 comment_start();
Neels Hofmeyr7814a832018-12-26 00:40:18 +0100661 _test_umts_authen_too_short_res(OSMO_RAT_UTRAN_IU);
Neels Hofmeyr15ed4262018-03-10 04:02:44 +0100662 comment_end();
663}
664
Neels Hofmeyr7814a832018-12-26 00:40:18 +0100665static void _test_umts_authen_too_long_res(enum osmo_rat_type via_ran)
Neels Hofmeyrc6d20dd2018-03-10 04:03:43 +0100666{
667 net->authentication_required = true;
668 net->vlr->cfg.assign_tmsi = true;
669 rx_from_ran = via_ran;
670
671 btw("Location Update request causes a GSUP Send Auth Info request to HLR");
672 lu_result_sent = RES_NONE;
673 gsup_expect_tx("080108" "09710000000156f0");
674 ms_sends_msg("0508" /* MM LU */
675 "7" /* ciph key seq: no key available */
676 "0" /* LU type: normal */
677 "ffffff" "0000" /* LAI, LAC */
678 "57" /* classmark 1: R99, early classmark, no power lvl */
679 "089910070000106005" /* IMSI */
680 "3303575886" /* classmark 2 */
681 );
682 OSMO_ASSERT(gsup_tx_confirmed);
683 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
684
685 btw("from HLR, rx _SEND_AUTH_INFO_RESULT; VLR sends Auth Req to MS");
686 /* based on auc_3g:
687 * K = 'EB215756028D60E3275E613320AEC880',
688 * OPC = 'FB2A3D1B360F599ABAB99DB8669F8308'
689 * SQN = 0
690 */
691 auth_request_sent = false;
692 auth_request_expect_rand = "39fa2f4e3d523d8619a73b4f65c3e14d";
693 auth_request_expect_autn = "8704f5ba55f30000d2ee44b22c8ea919";
694 gsup_rx("0a"
695 /* imsi */
696 "0108" "09710000000156f0"
697 /* 5 auth vectors... */
698 /* TL TL rand */
699 "0362" "2010" "39fa2f4e3d523d8619a73b4f65c3e14d"
700 /* TL sres TL kc */
701 "2104" "9b36efdf" "2208" "059a4f668f6fbe39"
702 /* TL 3G IK */
703 "2310" "27497388b6cb044648f396aa155b95ef"
704 /* TL 3G CK */
705 "2410" "f64735036e5871319c679f4742a75ea1"
706 /* TL AUTN */
707 "2510" "8704f5ba55f30000d2ee44b22c8ea919"
708 /* TL RES */
709 "2708" "e229c19e791f2e41"
710 /* TL TL rand */
711 "0362" "2010" "c187a53a5e6b9d573cac7c74451fd46d"
712 "2104" "85aa3130" "2208" "d3d50a000bf04f6e"
713 "2310" "1159ec926a50e98c034a6b7d7c9f418d"
714 "2410" "df3a03d9ca5335641efc8e36d76cd20b"
715 "2510" "1843a645b98d00005b2d666af46c45d9"
716 "2708" "7db47cf7f81e4dc7"
717 "0362" "2010" "efa9c29a9742148d5c9070348716e1bb"
718 "2104" "69d5f9fb" "2208" "3df176f0c29f1a3d"
719 "2310" "eb50e770ddcc3060101d2f43b6c2b884"
720 "2410" "76542abce5ff9345b0e8947f4c6e019c"
721 "2510" "f9375e6d41e1000096e7fe4ff1c27e39"
722 "2708" "706f996719ba609c"
723 "0362" "2010" "f023d5a3b24726e0631b64b3840f8253"
724 "2104" "d570c03f" "2208" "ec011be8919883d6"
725 "2310" "c4e58af4ba43f3bcd904e16984f086d7"
726 "2410" "0593f65e752e5cb7f473862bda05aa0a"
727 "2510" "541ff1f077270000c5ea00d658bc7e9a"
728 "2708" "3fd26072eaa2a04d"
729 "0362" "2010" "2f8f90c780d6a9c0c53da7ac57b6707e"
730 "2104" "b072446f220823f39f9f425ad6e6"
731 "2310" "65af0527fda95b0dc5ae4aa515cdf32f"
732 "2410" "537c3b35a3b13b08d08eeb28098f45cc"
733 "2510" "4bf4e564f75300009bc796706bc65744"
734 "2708" "0edb0eadbea94ac2",
735 NULL);
736 VERBOSE_ASSERT(auth_request_sent, == true, "%d");
737 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
738
739 btw("MS sends Authen Response of wrong RES size, VLR thwarts");
740 gsup_expect_tx("0b010809710000000156f0"); /* OSMO_GSUP_MSGT_AUTH_FAIL_REPORT */
741 expect_release_clear(via_ran);
742 ms_sends_msg("0554" "e229c19e" "2105" "791f2e4123" /* added one byte */);
743 VERBOSE_ASSERT(lu_result_sent, == RES_REJECT, "%d");
744 ASSERT_RELEASE_CLEAR(via_ran);
Neels Hofmeyr4068ab22018-04-01 20:55:54 +0200745 bss_rnc_sends_release_clear_complete(via_ran);
Neels Hofmeyrc6d20dd2018-03-10 04:03:43 +0100746
747 EXPECT_CONN_COUNT(0);
748 clear_vlr();
749}
750
751static void test_umts_authen_too_long_res_geran()
752{
753 comment_start();
Neels Hofmeyr7814a832018-12-26 00:40:18 +0100754 _test_umts_authen_too_long_res(OSMO_RAT_GERAN_A);
Neels Hofmeyrc6d20dd2018-03-10 04:03:43 +0100755 comment_end();
756}
757
758static void test_umts_authen_too_long_res_utran()
759{
760 comment_start();
Neels Hofmeyr7814a832018-12-26 00:40:18 +0100761 _test_umts_authen_too_long_res(OSMO_RAT_UTRAN_IU);
Neels Hofmeyrc6d20dd2018-03-10 04:03:43 +0100762 comment_end();
763}
764
Neels Hofmeyr7814a832018-12-26 00:40:18 +0100765static void _test_umts_authen_only_sres(enum osmo_rat_type via_ran)
Neels Hofmeyr31adcae2018-03-10 04:08:45 +0100766{
767 net->authentication_required = true;
768 net->vlr->cfg.assign_tmsi = true;
769 rx_from_ran = via_ran;
770
771 btw("Location Update request causes a GSUP Send Auth Info request to HLR");
772 lu_result_sent = RES_NONE;
773 gsup_expect_tx("080108" "09710000000156f0");
774 ms_sends_msg("0508" /* MM LU */
775 "7" /* ciph key seq: no key available */
776 "0" /* LU type: normal */
777 "ffffff" "0000" /* LAI, LAC */
778 "57" /* classmark 1: R99, early classmark, no power lvl */
779 "089910070000106005" /* IMSI */
780 "3303575886" /* classmark 2 */
781 );
782 OSMO_ASSERT(gsup_tx_confirmed);
783 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
784
785 btw("from HLR, rx _SEND_AUTH_INFO_RESULT; VLR sends Auth Req to MS");
786 /* based on auc_3g:
787 * K = 'EB215756028D60E3275E613320AEC880',
788 * OPC = 'FB2A3D1B360F599ABAB99DB8669F8308'
789 * SQN = 0
790 */
791 auth_request_sent = false;
792 auth_request_expect_rand = "39fa2f4e3d523d8619a73b4f65c3e14d";
793 auth_request_expect_autn = "8704f5ba55f30000d2ee44b22c8ea919";
794 gsup_rx("0a"
795 /* imsi */
796 "0108" "09710000000156f0"
797 /* 5 auth vectors... */
798 /* TL TL rand */
799 "0362" "2010" "39fa2f4e3d523d8619a73b4f65c3e14d"
800 /* TL sres TL kc */
801 "2104" "9b36efdf" "2208" "059a4f668f6fbe39"
802 /* TL 3G IK */
803 "2310" "27497388b6cb044648f396aa155b95ef"
804 /* TL 3G CK */
805 "2410" "f64735036e5871319c679f4742a75ea1"
806 /* TL AUTN */
807 "2510" "8704f5ba55f30000d2ee44b22c8ea919"
808 /* TL RES */
809 "2708" "e229c19e791f2e41"
810 /* TL TL rand */
811 "0362" "2010" "c187a53a5e6b9d573cac7c74451fd46d"
812 "2104" "85aa3130" "2208" "d3d50a000bf04f6e"
813 "2310" "1159ec926a50e98c034a6b7d7c9f418d"
814 "2410" "df3a03d9ca5335641efc8e36d76cd20b"
815 "2510" "1843a645b98d00005b2d666af46c45d9"
816 "2708" "7db47cf7f81e4dc7"
817 "0362" "2010" "efa9c29a9742148d5c9070348716e1bb"
818 "2104" "69d5f9fb" "2208" "3df176f0c29f1a3d"
819 "2310" "eb50e770ddcc3060101d2f43b6c2b884"
820 "2410" "76542abce5ff9345b0e8947f4c6e019c"
821 "2510" "f9375e6d41e1000096e7fe4ff1c27e39"
822 "2708" "706f996719ba609c"
823 "0362" "2010" "f023d5a3b24726e0631b64b3840f8253"
824 "2104" "d570c03f" "2208" "ec011be8919883d6"
825 "2310" "c4e58af4ba43f3bcd904e16984f086d7"
826 "2410" "0593f65e752e5cb7f473862bda05aa0a"
827 "2510" "541ff1f077270000c5ea00d658bc7e9a"
828 "2708" "3fd26072eaa2a04d"
829 "0362" "2010" "2f8f90c780d6a9c0c53da7ac57b6707e"
830 "2104" "b072446f220823f39f9f425ad6e6"
831 "2310" "65af0527fda95b0dc5ae4aa515cdf32f"
832 "2410" "537c3b35a3b13b08d08eeb28098f45cc"
833 "2510" "4bf4e564f75300009bc796706bc65744"
834 "2708" "0edb0eadbea94ac2",
835 NULL);
836 VERBOSE_ASSERT(auth_request_sent, == true, "%d");
837 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
838
Neels Hofmeyr7814a832018-12-26 00:40:18 +0100839 if (via_ran == OSMO_RAT_GERAN_A)
Neels Hofmeyr31adcae2018-03-10 04:08:45 +0100840 btw("MS sends Authen Response of wrong RES size, VLR thwarts:"
841 " GERAN reports an SRES mismatch");
842 else
843 btw("MS sends Authen Response of wrong RES size, VLR thwarts:"
844 " UTRAN disallows GSM AKA altogether");
845 gsup_expect_tx("0b010809710000000156f0"); /* OSMO_GSUP_MSGT_AUTH_FAIL_REPORT */
846 expect_release_clear(via_ran);
847 ms_sends_msg("0554" "e229c19e" /* Only the SRES half of the RES */);
848 VERBOSE_ASSERT(lu_result_sent, == RES_REJECT, "%d");
849 ASSERT_RELEASE_CLEAR(via_ran);
Neels Hofmeyr4068ab22018-04-01 20:55:54 +0200850 bss_rnc_sends_release_clear_complete(via_ran);
Neels Hofmeyr31adcae2018-03-10 04:08:45 +0100851
852 EXPECT_CONN_COUNT(0);
853 clear_vlr();
854}
855
856static void test_umts_authen_only_sres_geran()
857{
858 comment_start();
Neels Hofmeyr7814a832018-12-26 00:40:18 +0100859 _test_umts_authen_only_sres(OSMO_RAT_GERAN_A);
Neels Hofmeyr31adcae2018-03-10 04:08:45 +0100860 comment_end();
861}
862
863static void test_umts_authen_only_sres_utran()
864{
865 comment_start();
Neels Hofmeyr7814a832018-12-26 00:40:18 +0100866 _test_umts_authen_only_sres(OSMO_RAT_UTRAN_IU);
Neels Hofmeyr31adcae2018-03-10 04:08:45 +0100867 comment_end();
868}
869
Neels Hofmeyr15ed4262018-03-10 04:02:44 +0100870
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100871msc_vlr_test_func_t msc_vlr_tests[] = {
872 test_umts_authen_geran,
873 test_umts_authen_utran,
874 test_umts_authen_resync_geran,
875 test_umts_authen_resync_utran,
Neels Hofmeyr15ed4262018-03-10 04:02:44 +0100876 test_umts_authen_too_short_res_geran,
877 test_umts_authen_too_short_res_utran,
Neels Hofmeyrc6d20dd2018-03-10 04:03:43 +0100878 test_umts_authen_too_long_res_geran,
879 test_umts_authen_too_long_res_utran,
Neels Hofmeyr31adcae2018-03-10 04:08:45 +0100880 test_umts_authen_only_sres_geran,
881 test_umts_authen_only_sres_utran,
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100882 NULL
883};