Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 1 | /* 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 | |
Neels Hofmeyr | f3d81f6 | 2018-03-02 01:05:38 +0100 | [diff] [blame] | 26 | static void test_hlr_rej_auth_info_unknown_imsi() |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 27 | { |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 28 | comment_start(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 29 | |
| 30 | net->authentication_required = true; |
| 31 | |
| 32 | btw("Location Update request causes a GSUP Send Auth Info request to HLR"); |
| 33 | lu_result_sent = RES_NONE; |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 34 | gsup_expect_tx("08010809710000004026f0" VLR_TO_HLR); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 35 | ms_sends_msg("050802008168000130089910070000006402"); |
| 36 | OSMO_ASSERT(gsup_tx_confirmed); |
| 37 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 38 | |
| 39 | btw("HLR sends _SEND_AUTH_INFO_ERROR = unknown IMSI"); |
| 40 | auth_request_sent = false; |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 41 | expect_bssap_clear(); |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 42 | gsup_rx("09" "010809710000004026f0" "020102" HLR_TO_VLR, NULL); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 43 | VERBOSE_ASSERT(auth_request_sent, == false, "%d"); |
| 44 | VERBOSE_ASSERT(lu_result_sent, == RES_REJECT, "%d"); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 45 | VERBOSE_ASSERT(bssap_clear_sent, == true, "%d"); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 46 | |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 47 | ran_sends_clear_complete(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 48 | EXPECT_CONN_COUNT(0); |
| 49 | clear_vlr(); |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 50 | comment_end(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 51 | } |
| 52 | |
Neels Hofmeyr | f3d81f6 | 2018-03-02 01:05:38 +0100 | [diff] [blame] | 53 | static void test_hlr_rej_auth_info_net_fail() |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 54 | { |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 55 | comment_start(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 56 | |
| 57 | net->authentication_required = true; |
| 58 | |
| 59 | btw("Location Update request causes a GSUP Send Auth Info request to HLR"); |
| 60 | lu_result_sent = RES_NONE; |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 61 | gsup_expect_tx("08010809710000004026f0" VLR_TO_HLR); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 62 | ms_sends_msg("050802008168000130089910070000006402"); |
| 63 | OSMO_ASSERT(gsup_tx_confirmed); |
| 64 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 65 | |
| 66 | btw("HLR sends _SEND_AUTH_INFO_ERROR = net fail"); |
| 67 | auth_request_sent = false; |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 68 | expect_bssap_clear(); |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 69 | gsup_rx("09" "010809710000004026f0" "020111" HLR_TO_VLR, NULL); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 70 | VERBOSE_ASSERT(auth_request_sent, == false, "%d"); |
| 71 | VERBOSE_ASSERT(lu_result_sent, == RES_REJECT, "%d"); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 72 | VERBOSE_ASSERT(bssap_clear_sent, == true, "%d"); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 73 | |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 74 | ran_sends_clear_complete(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 75 | EXPECT_CONN_COUNT(0); |
| 76 | clear_vlr(); |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 77 | comment_end(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 78 | } |
| 79 | |
Neels Hofmeyr | f3d81f6 | 2018-03-02 01:05:38 +0100 | [diff] [blame] | 80 | static void test_hlr_rej_auth_info_net_fail_no_reuse_tuples() |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 81 | { |
| 82 | struct vlr_subscr *vsub; |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 83 | const char *imsi = "901700000004620"; |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 84 | |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 85 | comment_start(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 86 | |
| 87 | net->authentication_required = true; |
| 88 | net->vlr->cfg.auth_reuse_old_sets_on_error = false; |
Neels Hofmeyr | 33f5341 | 2017-10-29 02:11:18 +0100 | [diff] [blame] | 89 | net->vlr->cfg.auth_tuple_max_reuse_count = 0; |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 90 | |
| 91 | BTW("Submit a used auth tuple in the VLR"); |
| 92 | btw("Location Update request causes a GSUP Send Auth Info request to HLR"); |
| 93 | lu_result_sent = RES_NONE; |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 94 | gsup_expect_tx("08010809710000004026f0" VLR_TO_HLR); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 95 | ms_sends_msg("050802008168000130089910070000006402"); |
| 96 | OSMO_ASSERT(gsup_tx_confirmed); |
| 97 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 98 | |
| 99 | btw("from HLR, rx _SEND_AUTH_INFO_RESULT; VLR sends Auth Req to MS"); |
| 100 | auth_request_sent = false; |
| 101 | auth_request_expect_rand = "585df1ae287f6e273dce07090d61320b"; |
| 102 | auth_request_expect_autn = NULL; |
| 103 | /* Based on a Ki of 000102030405060708090a0b0c0d0e0f */ |
| 104 | gsup_rx("0a" |
| 105 | /* imsi */ |
| 106 | "0108" "09710000004026f0" |
| 107 | /* auth vectors... */ |
| 108 | /* TL TL rand */ |
| 109 | "0322" "2010" "585df1ae287f6e273dce07090d61320b" |
| 110 | /* TL sres TL kc */ |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 111 | "2104" "2d8b2c3e" "2208" "61855fb81fc2a800" HLR_TO_VLR, |
| 112 | NULL); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 113 | VERBOSE_ASSERT(auth_request_sent, == true, "%d"); |
| 114 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 115 | |
| 116 | btw("MS sends Authen Response, VLR accepts and sends GSUP LU Req to HLR"); |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 117 | gsup_expect_tx("04010809710000004026f0280102" VLR_TO_HLR); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 118 | ms_sends_msg("05542d8b2c3e"); |
| 119 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 120 | |
| 121 | btw("HLR sends _INSERT_DATA_REQUEST, VLR responds with _INSERT_DATA_RESULT"); |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 122 | gsup_rx("10010809710000004026f00804036470f1" HLR_TO_VLR, |
| 123 | "12010809710000004026f0" VLR_TO_HLR); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 124 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 125 | |
| 126 | btw("HLR also sends GSUP _UPDATE_LOCATION_RESULT"); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 127 | expect_bssap_clear(); |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 128 | gsup_rx("06010809710000004026f0" HLR_TO_VLR, NULL); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 129 | VERBOSE_ASSERT(bssap_clear_sent, == true, "%d"); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 130 | |
| 131 | btw("LU was successful, and the conn has already been closed"); |
| 132 | VERBOSE_ASSERT(lu_result_sent, == RES_ACCEPT, "%d"); |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 133 | ran_sends_clear_complete(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 134 | EXPECT_CONN_COUNT(0); |
| 135 | |
| 136 | |
| 137 | BTW("Now one auth tuple is available, but used."); |
Neels Hofmeyr | 7c5346c | 2019-02-19 02:36:35 +0100 | [diff] [blame] | 138 | vsub = vlr_subscr_find_by_imsi(net->vlr, imsi, __func__); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 139 | OSMO_ASSERT(vsub); |
| 140 | OSMO_ASSERT(vsub->last_tuple); |
| 141 | VERBOSE_ASSERT(vsub->last_tuple->use_count, == 1, "%d"); |
| 142 | /* no need to look at all auth tuples, the ongoing test would take an |
| 143 | * unexpected course if there were more. */ |
Neels Hofmeyr | 7c5346c | 2019-02-19 02:36:35 +0100 | [diff] [blame] | 144 | vlr_subscr_put(vsub, __func__); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 145 | |
| 146 | BTW("Another LU wants to get new tuples; HLR sends Network Failure, we reject."); |
| 147 | |
| 148 | btw("Location Update request causes a GSUP Send Auth Info request to HLR"); |
| 149 | lu_result_sent = RES_NONE; |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 150 | gsup_expect_tx("08010809710000004026f0" VLR_TO_HLR); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 151 | ms_sends_msg("050802008168000130089910070000006402"); |
| 152 | OSMO_ASSERT(gsup_tx_confirmed); |
| 153 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 154 | |
| 155 | btw("HLR sends _SEND_AUTH_INFO_ERROR = net fail"); |
| 156 | auth_request_sent = false; |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 157 | expect_bssap_clear(); |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 158 | gsup_rx("09" "010809710000004026f0" "020111" HLR_TO_VLR, NULL); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 159 | VERBOSE_ASSERT(auth_request_sent, == false, "%d"); |
| 160 | VERBOSE_ASSERT(lu_result_sent, == RES_REJECT, "%d"); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 161 | VERBOSE_ASSERT(bssap_clear_sent, == true, "%d"); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 162 | |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 163 | ran_sends_clear_complete(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 164 | EXPECT_CONN_COUNT(0); |
| 165 | clear_vlr(); |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 166 | comment_end(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 167 | } |
| 168 | |
Neels Hofmeyr | f3d81f6 | 2018-03-02 01:05:38 +0100 | [diff] [blame] | 169 | static void test_hlr_rej_auth_info_unkown_imsi_no_reuse_tuples() |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 170 | { |
| 171 | struct vlr_subscr *vsub; |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 172 | const char *imsi = "901700000004620"; |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 173 | |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 174 | comment_start(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 175 | |
| 176 | net->authentication_required = true; |
| 177 | net->vlr->cfg.auth_reuse_old_sets_on_error = true; |
Neels Hofmeyr | 33f5341 | 2017-10-29 02:11:18 +0100 | [diff] [blame] | 178 | net->vlr->cfg.auth_tuple_max_reuse_count = 0; |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 179 | |
| 180 | BTW("Submit a used auth tuple in the VLR"); |
| 181 | btw("Location Update request causes a GSUP Send Auth Info request to HLR"); |
| 182 | lu_result_sent = RES_NONE; |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 183 | gsup_expect_tx("08010809710000004026f0" VLR_TO_HLR); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 184 | ms_sends_msg("050802008168000130089910070000006402"); |
| 185 | OSMO_ASSERT(gsup_tx_confirmed); |
| 186 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 187 | |
| 188 | btw("from HLR, rx _SEND_AUTH_INFO_RESULT; VLR sends Auth Req to MS"); |
| 189 | auth_request_sent = false; |
| 190 | auth_request_expect_rand = "585df1ae287f6e273dce07090d61320b"; |
| 191 | auth_request_expect_autn = NULL; |
| 192 | /* Based on a Ki of 000102030405060708090a0b0c0d0e0f */ |
| 193 | gsup_rx("0a" |
| 194 | /* imsi */ |
| 195 | "0108" "09710000004026f0" |
| 196 | /* auth vectors... */ |
| 197 | /* TL TL rand */ |
| 198 | "0322" "2010" "585df1ae287f6e273dce07090d61320b" |
| 199 | /* TL sres TL kc */ |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 200 | "2104" "2d8b2c3e" "2208" "61855fb81fc2a800" HLR_TO_VLR, |
| 201 | NULL); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 202 | VERBOSE_ASSERT(auth_request_sent, == true, "%d"); |
| 203 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 204 | |
| 205 | btw("MS sends Authen Response, VLR accepts and sends GSUP LU Req to HLR"); |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 206 | gsup_expect_tx("04010809710000004026f0280102" VLR_TO_HLR); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 207 | ms_sends_msg("05542d8b2c3e"); |
| 208 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 209 | |
| 210 | btw("HLR sends _INSERT_DATA_REQUEST, VLR responds with _INSERT_DATA_RESULT"); |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 211 | gsup_rx("10010809710000004026f00804036470f1" HLR_TO_VLR, |
| 212 | "12010809710000004026f0" VLR_TO_HLR); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 213 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 214 | |
| 215 | btw("HLR also sends GSUP _UPDATE_LOCATION_RESULT"); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 216 | expect_bssap_clear(); |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 217 | gsup_rx("06010809710000004026f0" HLR_TO_VLR, NULL); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 218 | VERBOSE_ASSERT(bssap_clear_sent, == true, "%d"); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 219 | |
| 220 | btw("LU was successful, and the conn has already been closed"); |
| 221 | VERBOSE_ASSERT(lu_result_sent, == RES_ACCEPT, "%d"); |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 222 | ran_sends_clear_complete(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 223 | EXPECT_CONN_COUNT(0); |
| 224 | |
| 225 | |
| 226 | BTW("Now one auth tuple is available, but used."); |
Neels Hofmeyr | 7c5346c | 2019-02-19 02:36:35 +0100 | [diff] [blame] | 227 | vsub = vlr_subscr_find_by_imsi(net->vlr, imsi, __func__); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 228 | OSMO_ASSERT(vsub); |
| 229 | OSMO_ASSERT(vsub->last_tuple); |
| 230 | VERBOSE_ASSERT(vsub->last_tuple->use_count, == 1, "%d"); |
| 231 | /* no need to look at all auth tuples, the ongoing test would take an |
| 232 | * unexpected course if there were more. */ |
Neels Hofmeyr | 7c5346c | 2019-02-19 02:36:35 +0100 | [diff] [blame] | 233 | vlr_subscr_put(vsub, __func__); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 234 | |
| 235 | BTW("Another LU wants to get new tuples; HLR sends IMSI Unknown. Even though we would re-use an old tuple, reject the unknown IMSI."); |
| 236 | VERBOSE_ASSERT(net->vlr->cfg.auth_reuse_old_sets_on_error, == true, "%d"); |
| 237 | |
| 238 | btw("Location Update request causes a GSUP Send Auth Info request to HLR"); |
| 239 | lu_result_sent = RES_NONE; |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 240 | gsup_expect_tx("08010809710000004026f0" VLR_TO_HLR); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 241 | ms_sends_msg("050802008168000130089910070000006402"); |
| 242 | OSMO_ASSERT(gsup_tx_confirmed); |
| 243 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 244 | |
| 245 | btw("HLR sends _SEND_AUTH_INFO_ERROR = unknown IMSI"); |
| 246 | auth_request_sent = false; |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 247 | expect_bssap_clear(); |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 248 | gsup_rx("09" "010809710000004026f0" "020102" HLR_TO_VLR, NULL); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 249 | VERBOSE_ASSERT(auth_request_sent, == false, "%d"); |
| 250 | VERBOSE_ASSERT(lu_result_sent, == RES_REJECT, "%d"); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 251 | VERBOSE_ASSERT(bssap_clear_sent, == true, "%d"); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 252 | |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 253 | ran_sends_clear_complete(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 254 | EXPECT_CONN_COUNT(0); |
| 255 | clear_vlr(); |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 256 | comment_end(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 257 | } |
| 258 | |
Neels Hofmeyr | f3d81f6 | 2018-03-02 01:05:38 +0100 | [diff] [blame] | 259 | static void test_hlr_acc_but_no_auth_tuples() |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 260 | { |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 261 | comment_start(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 262 | |
| 263 | net->authentication_required = true; |
| 264 | net->vlr->cfg.auth_reuse_old_sets_on_error = true; |
Neels Hofmeyr | 33f5341 | 2017-10-29 02:11:18 +0100 | [diff] [blame] | 265 | net->vlr->cfg.auth_tuple_max_reuse_count = 0; |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 266 | |
| 267 | btw("Location Update request causes a GSUP Send Auth Info request to HLR"); |
| 268 | lu_result_sent = RES_NONE; |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 269 | gsup_expect_tx("08010809710000004026f0" VLR_TO_HLR); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 270 | ms_sends_msg("050802008168000130089910070000006402"); |
| 271 | OSMO_ASSERT(gsup_tx_confirmed); |
| 272 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 273 | |
| 274 | btw("from HLR, rx _SEND_AUTH_INFO_RESULT but it lacks auth tuples"); |
| 275 | auth_request_sent = false; |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 276 | expect_bssap_clear(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 277 | gsup_rx("0a" |
| 278 | /* imsi */ |
| 279 | "0108" "09710000004026f0" |
| 280 | /* NO auth vectors */ |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 281 | HLR_TO_VLR, |
| 282 | NULL); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 283 | VERBOSE_ASSERT(auth_request_sent, == false, "%d"); |
| 284 | VERBOSE_ASSERT(lu_result_sent, == RES_REJECT, "%d"); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 285 | VERBOSE_ASSERT(bssap_clear_sent, == true, "%d"); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 286 | |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 287 | ran_sends_clear_complete(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 288 | EXPECT_CONN_COUNT(0); |
| 289 | clear_vlr(); |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 290 | comment_end(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 291 | } |
| 292 | |
Neels Hofmeyr | f3d81f6 | 2018-03-02 01:05:38 +0100 | [diff] [blame] | 293 | static void test_hlr_rej_auth_info_net_fail_reuse_tuples() |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 294 | { |
| 295 | struct vlr_subscr *vsub; |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 296 | const char *imsi = "901700000004620"; |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 297 | |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 298 | comment_start(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 299 | |
| 300 | net->authentication_required = true; |
| 301 | net->vlr->cfg.auth_reuse_old_sets_on_error = true; |
Neels Hofmeyr | 33f5341 | 2017-10-29 02:11:18 +0100 | [diff] [blame] | 302 | net->vlr->cfg.auth_tuple_max_reuse_count = 0; |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 303 | |
| 304 | BTW("Submit a used auth tuple in the VLR"); |
| 305 | btw("Location Update request causes a GSUP Send Auth Info request to HLR"); |
| 306 | lu_result_sent = RES_NONE; |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 307 | gsup_expect_tx("08010809710000004026f0" VLR_TO_HLR); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 308 | ms_sends_msg("050802008168000130089910070000006402"); |
| 309 | OSMO_ASSERT(gsup_tx_confirmed); |
| 310 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 311 | |
| 312 | btw("from HLR, rx _SEND_AUTH_INFO_RESULT; VLR sends Auth Req to MS"); |
| 313 | auth_request_sent = false; |
| 314 | auth_request_expect_rand = "585df1ae287f6e273dce07090d61320b"; |
| 315 | auth_request_expect_autn = NULL; |
| 316 | /* Based on a Ki of 000102030405060708090a0b0c0d0e0f */ |
| 317 | gsup_rx("0a" |
| 318 | /* imsi */ |
| 319 | "0108" "09710000004026f0" |
| 320 | /* auth vectors... */ |
| 321 | /* TL TL rand */ |
| 322 | "0322" "2010" "585df1ae287f6e273dce07090d61320b" |
| 323 | /* TL sres TL kc */ |
| 324 | "2104" "2d8b2c3e" "2208" "61855fb81fc2a800" |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 325 | HLR_TO_VLR, |
| 326 | NULL); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 327 | VERBOSE_ASSERT(auth_request_sent, == true, "%d"); |
| 328 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 329 | |
| 330 | btw("MS sends Authen Response, VLR accepts and sends GSUP LU Req to HLR"); |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 331 | gsup_expect_tx("04010809710000004026f0280102" VLR_TO_HLR); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 332 | ms_sends_msg("05542d8b2c3e"); |
| 333 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 334 | |
| 335 | btw("HLR sends _INSERT_DATA_REQUEST, VLR responds with _INSERT_DATA_RESULT"); |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 336 | gsup_rx("10010809710000004026f00804036470f1" HLR_TO_VLR, |
| 337 | "12010809710000004026f0" VLR_TO_HLR); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 338 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 339 | |
| 340 | btw("HLR also sends GSUP _UPDATE_LOCATION_RESULT"); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 341 | expect_bssap_clear(); |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 342 | gsup_rx("06010809710000004026f0" HLR_TO_VLR, NULL); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 343 | VERBOSE_ASSERT(bssap_clear_sent, == true, "%d"); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 344 | |
| 345 | btw("LU was successful, and the conn has already been closed"); |
| 346 | VERBOSE_ASSERT(lu_result_sent, == RES_ACCEPT, "%d"); |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 347 | ran_sends_clear_complete(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 348 | EXPECT_CONN_COUNT(0); |
| 349 | |
| 350 | |
| 351 | BTW("Now one auth tuple is available, but used."); |
Neels Hofmeyr | 7c5346c | 2019-02-19 02:36:35 +0100 | [diff] [blame] | 352 | vsub = vlr_subscr_find_by_imsi(net->vlr, imsi, __func__); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 353 | OSMO_ASSERT(vsub); |
| 354 | OSMO_ASSERT(vsub->last_tuple); |
| 355 | VERBOSE_ASSERT(vsub->last_tuple->use_count, == 1, "%d"); |
| 356 | /* no need to look at all auth tuples, the ongoing test would take an |
| 357 | * unexpected course if there were more. */ |
Neels Hofmeyr | 7c5346c | 2019-02-19 02:36:35 +0100 | [diff] [blame] | 358 | vlr_subscr_put(vsub, __func__); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 359 | |
| 360 | BTW("Another LU wants to get new tuples; even though HLR sends Network Failure, we are reusing the old tuples."); |
| 361 | |
| 362 | btw("Location Update request causes a GSUP Send Auth Info request to HLR"); |
| 363 | lu_result_sent = RES_NONE; |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 364 | gsup_expect_tx("08010809710000004026f0" VLR_TO_HLR); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 365 | ms_sends_msg("050802008168000130089910070000006402"); |
| 366 | OSMO_ASSERT(gsup_tx_confirmed); |
| 367 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 368 | |
| 369 | btw("HLR sends _SEND_AUTH_INFO_ERROR = net fail"); |
| 370 | auth_request_sent = false; |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 371 | gsup_rx("09" "010809710000004026f0" "020111" HLR_TO_VLR, NULL); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 372 | VERBOSE_ASSERT(auth_request_sent, == true, "%d"); |
| 373 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 374 | |
| 375 | btw("MS sends Authen Response, VLR accepts and sends GSUP LU Req to HLR"); |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 376 | gsup_expect_tx("04010809710000004026f0280102" VLR_TO_HLR); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 377 | ms_sends_msg("05542d8b2c3e"); |
| 378 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 379 | |
| 380 | btw("HLR sends _INSERT_DATA_REQUEST, VLR responds with _INSERT_DATA_RESULT"); |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 381 | gsup_rx("10010809710000004026f00804036470f1" HLR_TO_VLR, |
| 382 | "12010809710000004026f0" VLR_TO_HLR); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 383 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 384 | |
| 385 | btw("HLR also sends GSUP _UPDATE_LOCATION_RESULT"); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 386 | expect_bssap_clear(); |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 387 | gsup_rx("06010809710000004026f0" HLR_TO_VLR, NULL); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 388 | VERBOSE_ASSERT(bssap_clear_sent, == true, "%d"); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 389 | |
| 390 | btw("LU was successful, and the conn has already been closed"); |
| 391 | VERBOSE_ASSERT(lu_result_sent, == RES_ACCEPT, "%d"); |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 392 | ran_sends_clear_complete(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 393 | EXPECT_CONN_COUNT(0); |
| 394 | |
| 395 | clear_vlr(); |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 396 | comment_end(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 397 | } |
| 398 | |
Neels Hofmeyr | f3d81f6 | 2018-03-02 01:05:38 +0100 | [diff] [blame] | 399 | static void test_hlr_rej_lu() |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 400 | { |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 401 | comment_start(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 402 | |
| 403 | btw("Location Update request causes a GSUP LU request to HLR"); |
| 404 | lu_result_sent = RES_NONE; |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 405 | gsup_expect_tx("04010809710000004026f0280102" VLR_TO_HLR); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 406 | ms_sends_msg("050802008168000130089910070000006402"); |
| 407 | OSMO_ASSERT(gsup_tx_confirmed); |
| 408 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 409 | |
| 410 | btw("HLR sends UPDATE_LOCATION_ERROR"); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 411 | expect_bssap_clear(); |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 412 | gsup_rx("05" "010809710000004026f0" "020102" HLR_TO_VLR, |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 413 | NULL); |
| 414 | VERBOSE_ASSERT(lu_result_sent, == RES_REJECT, "%d"); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 415 | VERBOSE_ASSERT(bssap_clear_sent, == true, "%d"); |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 416 | ran_sends_clear_complete(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 417 | EXPECT_CONN_COUNT(0); |
| 418 | |
| 419 | clear_vlr(); |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 420 | comment_end(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 421 | } |
| 422 | |
Neels Hofmeyr | f3d81f6 | 2018-03-02 01:05:38 +0100 | [diff] [blame] | 423 | static void test_hlr_no_insert_data() |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 424 | { |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 425 | comment_start(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 426 | |
| 427 | btw("Location Update request causes a GSUP LU request to HLR"); |
| 428 | lu_result_sent = RES_NONE; |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 429 | gsup_expect_tx("04010809710000004026f0280102" VLR_TO_HLR); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 430 | ms_sends_msg("050802008168000130089910070000006402"); |
| 431 | OSMO_ASSERT(gsup_tx_confirmed); |
| 432 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 433 | |
| 434 | btw("HLR sends only _UPDATE_LOCATION_RESULT, no INSERT DATA"); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 435 | expect_bssap_clear(); |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 436 | gsup_rx("06010809710000004026f0" HLR_TO_VLR, NULL); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 437 | VERBOSE_ASSERT(bssap_clear_sent, == true, "%d"); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 438 | |
| 439 | /* TODO should we wait for OSMO_GSUP_MSGT_INSERT_DATA_REQUEST? */ |
| 440 | |
| 441 | btw("LU was successful, and the conn has already been closed"); |
| 442 | VERBOSE_ASSERT(lu_result_sent, == RES_ACCEPT, "%d"); |
| 443 | |
Neels Hofmeyr | c4628a3 | 2018-12-07 14:47:34 +0100 | [diff] [blame] | 444 | ran_sends_clear_complete(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 445 | EXPECT_CONN_COUNT(0); |
| 446 | clear_vlr(); |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 447 | comment_end(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 448 | } |
| 449 | |
| 450 | msc_vlr_test_func_t msc_vlr_tests[] = { |
| 451 | test_hlr_rej_auth_info_unknown_imsi, |
| 452 | test_hlr_rej_auth_info_net_fail, |
| 453 | test_hlr_rej_auth_info_net_fail_reuse_tuples, |
| 454 | test_hlr_rej_auth_info_net_fail_no_reuse_tuples, |
| 455 | test_hlr_rej_auth_info_unkown_imsi_no_reuse_tuples, |
| 456 | test_hlr_acc_but_no_auth_tuples, |
| 457 | test_hlr_rej_lu, |
| 458 | test_hlr_no_insert_data, |
| 459 | NULL |
| 460 | }; |