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