Neels Hofmeyr | 17518fe | 2017-06-20 04:35:06 +0200 | [diff] [blame] | 1 | /*! \file osmo-auc-gen.c |
| 2 | * GSM/GPRS/3G authentication testing tool. */ |
| 3 | /* |
| 4 | * (C) 2010-2012 by Harald Welte <laforge@gnumonks.org> |
Harald Welte | 915e0ef | 2011-12-07 02:38:42 +0100 | [diff] [blame] | 5 | * |
| 6 | * All Rights Reserved |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify |
| 9 | * it under the terms of the GNU General Public License as published by |
| 10 | * the Free Software Foundation; either version 2 of the License, or |
| 11 | * (at your option) any later version. |
| 12 | * |
| 13 | * This program is distributed in the hope that it will be useful, |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | * GNU General Public License for more details. |
| 17 | * |
| 18 | * You should have received a copy of the GNU General Public License along |
| 19 | * with this program; if not, write to the Free Software Foundation, Inc., |
| 20 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 21 | * |
| 22 | */ |
| 23 | |
| 24 | |
| 25 | #include <stdlib.h> |
| 26 | #include <stdio.h> |
| 27 | #include <errno.h> |
| 28 | #include <string.h> |
Jan Engelhardt | a6d8393 | 2013-06-03 01:38:57 +0200 | [diff] [blame] | 29 | #include <time.h> |
Harald Welte | 915e0ef | 2011-12-07 02:38:42 +0100 | [diff] [blame] | 30 | #include <getopt.h> |
Harald Welte | b53717f | 2012-08-02 08:42:59 +0200 | [diff] [blame] | 31 | #include <unistd.h> |
Holger Hans Peter Freyther | a652abc | 2013-07-14 09:11:47 +0200 | [diff] [blame] | 32 | #include <inttypes.h> |
| 33 | #include <time.h> |
Harald Welte | 915e0ef | 2011-12-07 02:38:42 +0100 | [diff] [blame] | 34 | |
| 35 | #include <osmocom/crypt/auth.h> |
| 36 | #include <osmocom/core/utils.h> |
| 37 | |
Harald Welte | 57799ed | 2012-06-27 15:06:19 +0200 | [diff] [blame] | 38 | static void dump_triplets_dat(struct osmo_auth_vector *vec) |
| 39 | { |
| 40 | if (vec->auth_types & OSMO_AUTH_TYPE_UMTS) { |
| 41 | fprintf(stderr, "triplets.dat doesn't support UMTS!\n"); |
| 42 | return; |
| 43 | } |
| 44 | printf("imsi,"); |
| 45 | printf("%s,", osmo_hexdump_nospc(vec->rand, sizeof(vec->rand))); |
| 46 | printf("%s,", osmo_hexdump_nospc(vec->sres, sizeof(vec->sres))); |
| 47 | printf("%s\n", osmo_hexdump_nospc(vec->kc, sizeof(vec->kc))); |
| 48 | } |
| 49 | |
Harald Welte | 915e0ef | 2011-12-07 02:38:42 +0100 | [diff] [blame] | 50 | static void dump_auth_vec(struct osmo_auth_vector *vec) |
| 51 | { |
Harald Welte | 4f511b6 | 2016-05-18 19:36:42 +0200 | [diff] [blame] | 52 | printf("RAND:\t%s\n", osmo_hexdump_nospc(vec->rand, sizeof(vec->rand))); |
Harald Welte | 915e0ef | 2011-12-07 02:38:42 +0100 | [diff] [blame] | 53 | |
| 54 | if (vec->auth_types & OSMO_AUTH_TYPE_UMTS) { |
Harald Welte | 4f511b6 | 2016-05-18 19:36:42 +0200 | [diff] [blame] | 55 | printf("AUTN:\t%s\n", osmo_hexdump_nospc(vec->autn, sizeof(vec->autn))); |
| 56 | printf("IK:\t%s\n", osmo_hexdump_nospc(vec->ik, sizeof(vec->ik))); |
| 57 | printf("CK:\t%s\n", osmo_hexdump_nospc(vec->ck, sizeof(vec->ck))); |
| 58 | printf("RES:\t%s\n", osmo_hexdump_nospc(vec->res, vec->res_len)); |
Harald Welte | 915e0ef | 2011-12-07 02:38:42 +0100 | [diff] [blame] | 59 | } |
| 60 | |
| 61 | if (vec->auth_types & OSMO_AUTH_TYPE_GSM) { |
Harald Welte | 4f511b6 | 2016-05-18 19:36:42 +0200 | [diff] [blame] | 62 | printf("SRES:\t%s\n", osmo_hexdump_nospc(vec->sres, sizeof(vec->sres))); |
| 63 | printf("Kc:\t%s\n", osmo_hexdump_nospc(vec->kc, sizeof(vec->kc))); |
Harald Welte | 915e0ef | 2011-12-07 02:38:42 +0100 | [diff] [blame] | 64 | } |
| 65 | } |
| 66 | |
| 67 | static struct osmo_sub_auth_data test_aud = { |
| 68 | .type = OSMO_AUTH_TYPE_NONE, |
| 69 | .algo = OSMO_AUTH_ALG_NONE, |
| 70 | }; |
| 71 | |
Harald Welte | 5fb795e | 2012-03-21 08:51:48 +0100 | [diff] [blame] | 72 | static void help() |
| 73 | { |
Neels Hofmeyr | 18d65be | 2017-02-03 18:36:32 +0100 | [diff] [blame] | 74 | int alg; |
Harald Welte | 5fb795e | 2012-03-21 08:51:48 +0100 | [diff] [blame] | 75 | printf( "-2 --2g\tUse 2G (GSM) authentication\n" |
| 76 | "-3 --3g\tUse 3G (UMTS) authentication\n" |
| 77 | "-a --algorithm\tSpecify name of the algorithm\n" |
| 78 | "-k --key\tSpecify Ki / K\n" |
| 79 | "-o --opc\tSpecify OPC (only for 3G)\n" |
Harald Welte | a72e47b | 2012-03-21 09:03:16 +0100 | [diff] [blame] | 80 | "-O --op\tSpecify OP (only for 3G)\n" |
Holger Hans Peter Freyther | 91ff17c | 2015-05-26 00:11:37 +0800 | [diff] [blame] | 81 | "-f --amf\tSpecify AMF (only for 3G)\n" |
Harald Welte | 5fb795e | 2012-03-21 08:51:48 +0100 | [diff] [blame] | 82 | "-s --sqn\tSpecify SQN (only for 3G)\n" |
Neels Hofmeyr | 3cb0827 | 2017-08-26 21:45:33 +0200 | [diff] [blame] | 83 | "-i --ind\tSpecify IND slot for new SQN after AUTS (only for 3G)\n" |
Neels Hofmeyr | b1af6ef | 2017-08-26 21:38:51 +0200 | [diff] [blame] | 84 | "-l --ind-len\tSpecify IND bit length (default=5) (only for 3G)\n" |
Harald Welte | cebf3f0 | 2012-03-22 16:45:23 +0100 | [diff] [blame] | 85 | "-A --auts\tSpecify AUTS (only for 3G)\n" |
Harald Welte | 57799ed | 2012-06-27 15:06:19 +0200 | [diff] [blame] | 86 | "-r --rand\tSpecify random value\n" |
| 87 | "-I --ipsec\tOutput in triplets.dat format for strongswan\n"); |
Neels Hofmeyr | 18d65be | 2017-02-03 18:36:32 +0100 | [diff] [blame] | 88 | |
| 89 | fprintf(stderr, "\nAvailable algorithms for option -a:\n"); |
| 90 | for (alg = 1; alg < _OSMO_AUTH_ALG_NUM; alg++) |
| 91 | fprintf(stderr, " %s\n", |
| 92 | osmo_auth_alg_name(alg)); |
Harald Welte | 5fb795e | 2012-03-21 08:51:48 +0100 | [diff] [blame] | 93 | } |
| 94 | |
Harald Welte | 915e0ef | 2011-12-07 02:38:42 +0100 | [diff] [blame] | 95 | int main(int argc, char **argv) |
| 96 | { |
| 97 | struct osmo_auth_vector _vec; |
| 98 | struct osmo_auth_vector *vec = &_vec; |
Neels Hofmeyr | 8352d31 | 2017-02-02 20:05:14 +0100 | [diff] [blame] | 99 | uint8_t _rand[16], _auts[14]; |
Neels Hofmeyr | d157bbb | 2017-08-26 22:08:36 +0200 | [diff] [blame] | 100 | uint64_t sqn; |
Neels Hofmeyr | b2e41cc | 2017-09-12 03:25:43 +0200 | [diff] [blame] | 101 | unsigned int ind = 0; |
Harald Welte | 915e0ef | 2011-12-07 02:38:42 +0100 | [diff] [blame] | 102 | int rc, option_index; |
| 103 | int rand_is_set = 0; |
Harald Welte | cebf3f0 | 2012-03-22 16:45:23 +0100 | [diff] [blame] | 104 | int auts_is_set = 0; |
Neels Hofmeyr | d157bbb | 2017-08-26 22:08:36 +0200 | [diff] [blame] | 105 | int sqn_is_set = 0; |
Neels Hofmeyr | 3cb0827 | 2017-08-26 21:45:33 +0200 | [diff] [blame] | 106 | int ind_is_set = 0; |
Harald Welte | 57799ed | 2012-06-27 15:06:19 +0200 | [diff] [blame] | 107 | int fmt_triplets_dat = 0; |
Neels Hofmeyr | b2e41cc | 2017-09-12 03:25:43 +0200 | [diff] [blame] | 108 | uint64_t ind_mask = 0; |
Harald Welte | 915e0ef | 2011-12-07 02:38:42 +0100 | [diff] [blame] | 109 | |
Harald Welte | bc6f56c | 2012-03-21 17:37:53 +0100 | [diff] [blame] | 110 | printf("osmo-auc-gen (C) 2011-2012 by Harald Welte\n"); |
Harald Welte | 915e0ef | 2011-12-07 02:38:42 +0100 | [diff] [blame] | 111 | printf("This is FREE SOFTWARE with ABSOLUTELY NO WARRANTY\n\n"); |
| 112 | |
Harald Welte | cebf3f0 | 2012-03-22 16:45:23 +0100 | [diff] [blame] | 113 | memset(_auts, 0, sizeof(_auts)); |
| 114 | |
Harald Welte | 915e0ef | 2011-12-07 02:38:42 +0100 | [diff] [blame] | 115 | while (1) { |
| 116 | int c; |
Harald Welte | 915e0ef | 2011-12-07 02:38:42 +0100 | [diff] [blame] | 117 | static struct option long_options[] = { |
| 118 | { "2g", 0, 0, '2' }, |
| 119 | { "3g", 0, 0, '3' }, |
| 120 | { "algorithm", 1, 0, 'a' }, |
| 121 | { "key", 1, 0, 'k' }, |
| 122 | { "opc", 1, 0, 'o' }, |
Harald Welte | a72e47b | 2012-03-21 09:03:16 +0100 | [diff] [blame] | 123 | { "op", 1, 0, 'O' }, |
Harald Welte | 915e0ef | 2011-12-07 02:38:42 +0100 | [diff] [blame] | 124 | { "amf", 1, 0, 'f' }, |
| 125 | { "sqn", 1, 0, 's' }, |
Neels Hofmeyr | 3cb0827 | 2017-08-26 21:45:33 +0200 | [diff] [blame] | 126 | { "ind", 1, 0, 'i' }, |
Neels Hofmeyr | b1af6ef | 2017-08-26 21:38:51 +0200 | [diff] [blame] | 127 | { "ind-len", 1, 0, 'l' }, |
Harald Welte | 915e0ef | 2011-12-07 02:38:42 +0100 | [diff] [blame] | 128 | { "rand", 1, 0, 'r' }, |
Harald Welte | cebf3f0 | 2012-03-22 16:45:23 +0100 | [diff] [blame] | 129 | { "auts", 1, 0, 'A' }, |
Harald Welte | 5fb795e | 2012-03-21 08:51:48 +0100 | [diff] [blame] | 130 | { "help", 0, 0, 'h' }, |
Harald Welte | 915e0ef | 2011-12-07 02:38:42 +0100 | [diff] [blame] | 131 | { 0, 0, 0, 0 } |
| 132 | }; |
| 133 | |
| 134 | rc = 0; |
| 135 | |
Neels Hofmeyr | b1af6ef | 2017-08-26 21:38:51 +0200 | [diff] [blame] | 136 | c = getopt_long(argc, argv, "23a:k:o:f:s:i:l:r:hO:A:I", long_options, |
Harald Welte | 915e0ef | 2011-12-07 02:38:42 +0100 | [diff] [blame] | 137 | &option_index); |
| 138 | |
| 139 | if (c == -1) |
| 140 | break; |
| 141 | |
| 142 | switch (c) { |
| 143 | case '2': |
| 144 | test_aud.type = OSMO_AUTH_TYPE_GSM; |
| 145 | break; |
| 146 | case '3': |
| 147 | test_aud.type = OSMO_AUTH_TYPE_UMTS; |
Neels Hofmeyr | 4315e01 | 2017-08-26 21:40:11 +0200 | [diff] [blame] | 148 | test_aud.u.umts.ind_bitlen = 5; |
Harald Welte | 915e0ef | 2011-12-07 02:38:42 +0100 | [diff] [blame] | 149 | break; |
| 150 | case 'a': |
| 151 | rc = osmo_auth_alg_parse(optarg); |
| 152 | if (rc < 0) |
| 153 | break; |
| 154 | test_aud.algo = rc; |
| 155 | break; |
| 156 | case 'k': |
| 157 | switch (test_aud.type) { |
| 158 | case OSMO_AUTH_TYPE_GSM: |
Harald Welte | aae2362 | 2011-12-07 11:35:02 +0100 | [diff] [blame] | 159 | rc = osmo_hexparse(optarg, test_aud.u.gsm.ki, |
| 160 | sizeof(test_aud.u.gsm.ki)); |
Harald Welte | 915e0ef | 2011-12-07 02:38:42 +0100 | [diff] [blame] | 161 | break; |
| 162 | case OSMO_AUTH_TYPE_UMTS: |
Harald Welte | aae2362 | 2011-12-07 11:35:02 +0100 | [diff] [blame] | 163 | rc = osmo_hexparse(optarg, test_aud.u.umts.k, |
| 164 | sizeof(test_aud.u.umts.k)); |
Harald Welte | 915e0ef | 2011-12-07 02:38:42 +0100 | [diff] [blame] | 165 | break; |
| 166 | default: |
| 167 | fprintf(stderr, "please specify 2g/3g first!\n"); |
| 168 | } |
| 169 | break; |
| 170 | case 'o': |
| 171 | if (test_aud.type != OSMO_AUTH_TYPE_UMTS) { |
| 172 | fprintf(stderr, "Only UMTS has OPC\n"); |
| 173 | exit(2); |
| 174 | } |
Harald Welte | aae2362 | 2011-12-07 11:35:02 +0100 | [diff] [blame] | 175 | rc = osmo_hexparse(optarg, test_aud.u.umts.opc, |
| 176 | sizeof(test_aud.u.umts.opc)); |
Harald Welte | a72e47b | 2012-03-21 09:03:16 +0100 | [diff] [blame] | 177 | test_aud.u.umts.opc_is_op = 0; |
| 178 | break; |
| 179 | case 'O': |
| 180 | if (test_aud.type != OSMO_AUTH_TYPE_UMTS) { |
| 181 | fprintf(stderr, "Only UMTS has OP\n"); |
| 182 | exit(2); |
| 183 | } |
| 184 | rc = osmo_hexparse(optarg, test_aud.u.umts.opc, |
| 185 | sizeof(test_aud.u.umts.opc)); |
| 186 | test_aud.u.umts.opc_is_op = 1; |
Harald Welte | 915e0ef | 2011-12-07 02:38:42 +0100 | [diff] [blame] | 187 | break; |
Harald Welte | cebf3f0 | 2012-03-22 16:45:23 +0100 | [diff] [blame] | 188 | case 'A': |
| 189 | if (test_aud.type != OSMO_AUTH_TYPE_UMTS) { |
| 190 | fprintf(stderr, "Only UMTS has AUTS\n"); |
| 191 | exit(2); |
| 192 | } |
| 193 | rc = osmo_hexparse(optarg, _auts, sizeof(_auts)); |
| 194 | auts_is_set = 1; |
| 195 | break; |
Harald Welte | 915e0ef | 2011-12-07 02:38:42 +0100 | [diff] [blame] | 196 | case 'f': |
| 197 | if (test_aud.type != OSMO_AUTH_TYPE_UMTS) { |
| 198 | fprintf(stderr, "Only UMTS has AMF\n"); |
| 199 | exit(2); |
| 200 | } |
Harald Welte | aae2362 | 2011-12-07 11:35:02 +0100 | [diff] [blame] | 201 | rc = osmo_hexparse(optarg, test_aud.u.umts.amf, |
| 202 | sizeof(test_aud.u.umts.amf)); |
Harald Welte | 915e0ef | 2011-12-07 02:38:42 +0100 | [diff] [blame] | 203 | break; |
| 204 | case 's': |
| 205 | if (test_aud.type != OSMO_AUTH_TYPE_UMTS) { |
| 206 | fprintf(stderr, "Only UMTS has SQN\n"); |
| 207 | exit(2); |
| 208 | } |
Neels Hofmeyr | d157bbb | 2017-08-26 22:08:36 +0200 | [diff] [blame] | 209 | sqn = strtoull(optarg, 0, 10); |
| 210 | sqn_is_set = 1; |
Harald Welte | 915e0ef | 2011-12-07 02:38:42 +0100 | [diff] [blame] | 211 | break; |
Neels Hofmeyr | 3cb0827 | 2017-08-26 21:45:33 +0200 | [diff] [blame] | 212 | case 'i': |
| 213 | if (test_aud.type != OSMO_AUTH_TYPE_UMTS) { |
| 214 | fprintf(stderr, "Only UMTS has IND\n"); |
| 215 | exit(2); |
| 216 | } |
| 217 | ind = atoi(optarg); |
| 218 | ind_is_set = 1; |
| 219 | break; |
Neels Hofmeyr | b1af6ef | 2017-08-26 21:38:51 +0200 | [diff] [blame] | 220 | case 'l': |
| 221 | if (test_aud.type != OSMO_AUTH_TYPE_UMTS) { |
| 222 | fprintf(stderr, "Only UMTS has IND bitlen\n"); |
| 223 | exit(2); |
| 224 | } |
| 225 | test_aud.u.umts.ind_bitlen = atoi(optarg); |
| 226 | break; |
Harald Welte | 915e0ef | 2011-12-07 02:38:42 +0100 | [diff] [blame] | 227 | case 'r': |
| 228 | rc = osmo_hexparse(optarg, _rand, sizeof(_rand)); |
| 229 | rand_is_set = 1; |
| 230 | break; |
Harald Welte | 57799ed | 2012-06-27 15:06:19 +0200 | [diff] [blame] | 231 | case 'I': |
| 232 | fmt_triplets_dat = 1; |
| 233 | break; |
Harald Welte | 5fb795e | 2012-03-21 08:51:48 +0100 | [diff] [blame] | 234 | case 'h': |
| 235 | help(); |
| 236 | exit(0); |
| 237 | default: |
| 238 | help(); |
| 239 | exit(1); |
Harald Welte | 915e0ef | 2011-12-07 02:38:42 +0100 | [diff] [blame] | 240 | } |
| 241 | |
| 242 | if (rc < 0) { |
Neels Hofmeyr | 18d65be | 2017-02-03 18:36:32 +0100 | [diff] [blame] | 243 | help(); |
| 244 | fprintf(stderr, "\nError parsing argument of option `%c'\n", c); |
Harald Welte | 915e0ef | 2011-12-07 02:38:42 +0100 | [diff] [blame] | 245 | exit(2); |
| 246 | } |
| 247 | } |
| 248 | |
| 249 | if (!rand_is_set) { |
Holger Hans Peter Freyther | 17aa6b2 | 2014-06-22 16:53:55 +0200 | [diff] [blame] | 250 | int i; |
Harald Welte | 915e0ef | 2011-12-07 02:38:42 +0100 | [diff] [blame] | 251 | printf("WARNING: We're using really weak random numbers!\n\n"); |
| 252 | srand(time(NULL)); |
Holger Hans Peter Freyther | 17aa6b2 | 2014-06-22 16:53:55 +0200 | [diff] [blame] | 253 | |
| 254 | for (i = 0; i < 4; ++i) { |
| 255 | uint32_t r; |
| 256 | r = rand(); |
| 257 | memcpy(&_rand[i*4], &r, 4); |
| 258 | } |
Harald Welte | 915e0ef | 2011-12-07 02:38:42 +0100 | [diff] [blame] | 259 | } |
| 260 | |
Harald Welte | 5fb795e | 2012-03-21 08:51:48 +0100 | [diff] [blame] | 261 | if (test_aud.type == OSMO_AUTH_TYPE_NONE || |
| 262 | test_aud.algo == OSMO_AUTH_ALG_NONE) { |
| 263 | help(); |
Neels Hofmeyr | 18d65be | 2017-02-03 18:36:32 +0100 | [diff] [blame] | 264 | fprintf(stderr, "\nError: you need to pass at least" |
| 265 | " -2 or -3, as well as an algorithm to use.\n"); |
Harald Welte | 5fb795e | 2012-03-21 08:51:48 +0100 | [diff] [blame] | 266 | exit(2); |
| 267 | } |
| 268 | |
Harald Welte | 915e0ef | 2011-12-07 02:38:42 +0100 | [diff] [blame] | 269 | memset(vec, 0, sizeof(*vec)); |
| 270 | |
Neels Hofmeyr | d157bbb | 2017-08-26 22:08:36 +0200 | [diff] [blame] | 271 | if (test_aud.type == OSMO_AUTH_TYPE_UMTS) { |
Neels Hofmeyr | b2e41cc | 2017-09-12 03:25:43 +0200 | [diff] [blame] | 272 | uint64_t seq_1 = 1LL << test_aud.u.umts.ind_bitlen; |
Neels Hofmeyr | e6e6446 | 2017-08-26 22:29:51 +0200 | [diff] [blame] | 273 | ind_mask = seq_1 - 1; |
Neels Hofmeyr | d157bbb | 2017-08-26 22:08:36 +0200 | [diff] [blame] | 274 | |
| 275 | if (sqn_is_set) { |
| 276 | /* Before calculating the UMTS auth vector, osmo_auth_gen_vec() increments SEQ. |
| 277 | * To end up with the SQN passed in by the user, we need to pass in SEQ-1, and |
| 278 | * indicate which IND slot to target. */ |
| 279 | test_aud.u.umts.sqn = sqn - seq_1; |
| 280 | test_aud.u.umts.ind = sqn & ind_mask; |
| 281 | } |
Neels Hofmeyr | 3cb0827 | 2017-08-26 21:45:33 +0200 | [diff] [blame] | 282 | |
| 283 | if (sqn_is_set && ind_is_set) { |
| 284 | fprintf(stderr, "Requesting --sqn %"PRIu64" implies IND=%u," |
| 285 | " so no further --ind argument is allowed.\n", |
| 286 | sqn, test_aud.u.umts.ind); |
| 287 | exit(2); |
| 288 | } |
| 289 | |
| 290 | if (ind_is_set) { |
| 291 | if (ind >= (1 << test_aud.u.umts.ind_bitlen)) { |
| 292 | fprintf(stderr, "Requested --ind %u is too large for IND bitlen of %u\n", |
| 293 | ind, test_aud.u.umts.ind_bitlen); |
| 294 | exit(2); |
| 295 | } |
| 296 | test_aud.u.umts.ind = ind; |
| 297 | } |
Neels Hofmeyr | d157bbb | 2017-08-26 22:08:36 +0200 | [diff] [blame] | 298 | } |
| 299 | |
Harald Welte | cebf3f0 | 2012-03-22 16:45:23 +0100 | [diff] [blame] | 300 | if (!auts_is_set) |
| 301 | rc = osmo_auth_gen_vec(vec, &test_aud, _rand); |
| 302 | else |
| 303 | rc = osmo_auth_gen_vec_auts(vec, &test_aud, _auts, _rand, _rand); |
Harald Welte | 915e0ef | 2011-12-07 02:38:42 +0100 | [diff] [blame] | 304 | if (rc < 0) { |
Harald Welte | cebf3f0 | 2012-03-22 16:45:23 +0100 | [diff] [blame] | 305 | if (!auts_is_set) |
| 306 | fprintf(stderr, "error generating auth vector\n"); |
| 307 | else |
| 308 | fprintf(stderr, "AUTS from MS seems incorrect\n"); |
Harald Welte | 915e0ef | 2011-12-07 02:38:42 +0100 | [diff] [blame] | 309 | exit(1); |
| 310 | } |
| 311 | |
Harald Welte | 57799ed | 2012-06-27 15:06:19 +0200 | [diff] [blame] | 312 | if (fmt_triplets_dat) |
| 313 | dump_triplets_dat(vec); |
Neels Hofmeyr | 5fe3d1b | 2017-03-15 01:16:43 +0100 | [diff] [blame] | 314 | else { |
Harald Welte | 57799ed | 2012-06-27 15:06:19 +0200 | [diff] [blame] | 315 | dump_auth_vec(vec); |
Neels Hofmeyr | e6e6446 | 2017-08-26 22:29:51 +0200 | [diff] [blame] | 316 | if (test_aud.type == OSMO_AUTH_TYPE_UMTS) { |
Neels Hofmeyr | 82c9a0e | 2017-03-13 17:36:17 +0100 | [diff] [blame] | 317 | printf("SQN:\t%" PRIu64 "\n", test_aud.u.umts.sqn); |
Neels Hofmeyr | e6e6446 | 2017-08-26 22:29:51 +0200 | [diff] [blame] | 318 | printf("IND:\t%u\n", (unsigned int)(test_aud.u.umts.sqn & ind_mask)); |
Neels Hofmeyr | 2066a42 | 2017-08-26 22:43:50 +0200 | [diff] [blame] | 319 | if (auts_is_set) |
| 320 | printf("SQN.MS:\t%" PRIu64 "\n", test_aud.u.umts.sqn_ms); |
Neels Hofmeyr | e6e6446 | 2017-08-26 22:29:51 +0200 | [diff] [blame] | 321 | } |
Neels Hofmeyr | 5fe3d1b | 2017-03-15 01:16:43 +0100 | [diff] [blame] | 322 | } |
Harald Welte | 915e0ef | 2011-12-07 02:38:42 +0100 | [diff] [blame] | 323 | |
Harald Welte | cebf3f0 | 2012-03-22 16:45:23 +0100 | [diff] [blame] | 324 | exit(0); |
Harald Welte | 915e0ef | 2011-12-07 02:38:42 +0100 | [diff] [blame] | 325 | } |