summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tests/osmo-auc-gen/osmo-auc-gen_test.err9
-rw-r--r--tests/osmo-auc-gen/osmo-auc-gen_test.ok63
-rwxr-xr-xtests/osmo-auc-gen/osmo-auc-gen_test.sh20
-rw-r--r--utils/osmo-auc-gen.c30
4 files changed, 120 insertions, 2 deletions
diff --git a/tests/osmo-auc-gen/osmo-auc-gen_test.err b/tests/osmo-auc-gen/osmo-auc-gen_test.err
index e69de29b..46ecf2ef 100644
--- a/tests/osmo-auc-gen/osmo-auc-gen_test.err
+++ b/tests/osmo-auc-gen/osmo-auc-gen_test.err
@@ -0,0 +1,9 @@
+expecting error:
+> osmo-auc-gen -3 -a milenage -r 39fa2f4e3d523d8619a73b4f65c3e14d -k EB215756028D60E3275E613320AEC880 -o FB2A3D1B360F599ABAB99DB8669F8308 -A 979498b1f72d3e28c59fa2e72f9c --ind -1
+Requested --ind 4294967295 is too large for IND bitlen of 5
+expecting error:
+> osmo-auc-gen -3 -a milenage -r 39fa2f4e3d523d8619a73b4f65c3e14d -k EB215756028D60E3275E613320AEC880 -o FB2A3D1B360F599ABAB99DB8669F8308 -A 979498b1f72d3e28c59fa2e72f9c --ind 32
+Requested --ind 32 is too large for IND bitlen of 5
+expecting error:
+> osmo-auc-gen -3 -a milenage -r 39fa2f4e3d523d8619a73b4f65c3e14d -k EB215756028D60E3275E613320AEC880 -o FB2A3D1B360F599ABAB99DB8669F8308 -A 979498b1f72d3e28c59fa2e72f9c --ind 42
+Requested --ind 42 is too large for IND bitlen of 5
diff --git a/tests/osmo-auc-gen/osmo-auc-gen_test.ok b/tests/osmo-auc-gen/osmo-auc-gen_test.ok
index a1d06f0c..278c88f4 100644
--- a/tests/osmo-auc-gen/osmo-auc-gen_test.ok
+++ b/tests/osmo-auc-gen/osmo-auc-gen_test.ok
@@ -96,3 +96,66 @@ RES: e229c19e791f2e41
SRES: 9b36efdf
Kc: 059a4f668f6fbe39
SQN: 32
+
+
+> osmo-auc-gen -3 -a milenage -r 39fa2f4e3d523d8619a73b4f65c3e14d -k EB215756028D60E3275E613320AEC880 -o FB2A3D1B360F599ABAB99DB8669F8308 -A 979498b1f72d3e28c59fa2e72f9c --ind 5
+osmo-auc-gen (C) 2011-2012 by Harald Welte
+This is FREE SOFTWARE with ABSOLUTELY NO WARRANTY
+
+RAND: 39fa2f4e3d523d8619a73b4f65c3e14d
+AUTN: 8704f5ba55d6000079267a4b347ad890
+IK: 27497388b6cb044648f396aa155b95ef
+CK: f64735036e5871319c679f4742a75ea1
+RES: e229c19e791f2e41
+SRES: 9b36efdf
+Kc: 059a4f668f6fbe39
+SQN: 37
+
+
+> osmo-auc-gen -3 -a milenage -r 39fa2f4e3d523d8619a73b4f65c3e14d -k EB215756028D60E3275E613320AEC880 -o FB2A3D1B360F599ABAB99DB8669F8308 -A 979498b1f72d3e28c59fa2e72f9c --ind 23
+osmo-auc-gen (C) 2011-2012 by Harald Welte
+This is FREE SOFTWARE with ABSOLUTELY NO WARRANTY
+
+RAND: 39fa2f4e3d523d8619a73b4f65c3e14d
+AUTN: 8704f5ba55c40000129ddaa4f5016e25
+IK: 27497388b6cb044648f396aa155b95ef
+CK: f64735036e5871319c679f4742a75ea1
+RES: e229c19e791f2e41
+SRES: 9b36efdf
+Kc: 059a4f668f6fbe39
+SQN: 55
+
+
+> osmo-auc-gen -3 -a milenage -r 39fa2f4e3d523d8619a73b4f65c3e14d -k EB215756028D60E3275E613320AEC880 -o FB2A3D1B360F599ABAB99DB8669F8308 -A 979498b1f72d3e28c59fa2e72f9c --ind 31
+osmo-auc-gen (C) 2011-2012 by Harald Welte
+This is FREE SOFTWARE with ABSOLUTELY NO WARRANTY
+
+RAND: 39fa2f4e3d523d8619a73b4f65c3e14d
+AUTN: 8704f5ba55cc00009d169f5ff89f6087
+IK: 27497388b6cb044648f396aa155b95ef
+CK: f64735036e5871319c679f4742a75ea1
+RES: e229c19e791f2e41
+SRES: 9b36efdf
+Kc: 059a4f668f6fbe39
+SQN: 63
+
+
+expecting error:
+> osmo-auc-gen -3 -a milenage -r 39fa2f4e3d523d8619a73b4f65c3e14d -k EB215756028D60E3275E613320AEC880 -o FB2A3D1B360F599ABAB99DB8669F8308 -A 979498b1f72d3e28c59fa2e72f9c --ind -1
+osmo-auc-gen (C) 2011-2012 by Harald Welte
+This is FREE SOFTWARE with ABSOLUTELY NO WARRANTY
+
+
+
+expecting error:
+> osmo-auc-gen -3 -a milenage -r 39fa2f4e3d523d8619a73b4f65c3e14d -k EB215756028D60E3275E613320AEC880 -o FB2A3D1B360F599ABAB99DB8669F8308 -A 979498b1f72d3e28c59fa2e72f9c --ind 32
+osmo-auc-gen (C) 2011-2012 by Harald Welte
+This is FREE SOFTWARE with ABSOLUTELY NO WARRANTY
+
+
+
+expecting error:
+> osmo-auc-gen -3 -a milenage -r 39fa2f4e3d523d8619a73b4f65c3e14d -k EB215756028D60E3275E613320AEC880 -o FB2A3D1B360F599ABAB99DB8669F8308 -A 979498b1f72d3e28c59fa2e72f9c --ind 42
+osmo-auc-gen (C) 2011-2012 by Harald Welte
+This is FREE SOFTWARE with ABSOLUTELY NO WARRANTY
+
diff --git a/tests/osmo-auc-gen/osmo-auc-gen_test.sh b/tests/osmo-auc-gen/osmo-auc-gen_test.sh
index 132d9c39..f7fc87da 100755
--- a/tests/osmo-auc-gen/osmo-auc-gen_test.sh
+++ b/tests/osmo-auc-gen/osmo-auc-gen_test.sh
@@ -18,6 +18,16 @@ invoke() {
$osmo_auc_gen $@
}
+invoke_err() {
+ echo
+ echo
+ echo expecting error:
+ echo '>' osmo-auc-gen $@
+ echo expecting error: >&2
+ echo '>' osmo-auc-gen $@ >&2
+ $osmo_auc_gen $@ && exit 1 || true
+}
+
bytes1="6a61050765caa32c90371370e5d6dc2d"
bytes2="1dc4f974325cce611e54f516dc1fec56"
bytes3="2a48162ff3edca4adf0b7b5e527d6c16"
@@ -32,5 +42,13 @@ invoke -3 -a milenage -r $bytes1 -k $bytes3 -o $bytes2 -s 281474976710655
k="EB215756028D60E3275E613320AEC880"
opc="FB2A3D1B360F599ABAB99DB8669F8308"
rand="39fa2f4e3d523d8619a73b4f65c3e14d"
-auts="979498b1f72d3e28c59fa2e72f9c"
+auts="979498b1f72d3e28c59fa2e72f9c" # --> SQN.MS = 23
invoke -3 -a milenage -r $rand -k $k -o $opc -A $auts
+invoke -3 -a milenage -r $rand -k $k -o $opc -A $auts --ind 5
+invoke -3 -a milenage -r $rand -k $k -o $opc -A $auts --ind 23
+invoke -3 -a milenage -r $rand -k $k -o $opc -A $auts --ind 31
+
+# expect error: IND is too large for IND-bitlen of 5 (max 31)
+invoke_err -3 -a milenage -r $rand -k $k -o $opc -A $auts --ind -1
+invoke_err -3 -a milenage -r $rand -k $k -o $opc -A $auts --ind 32
+invoke_err -3 -a milenage -r $rand -k $k -o $opc -A $auts --ind 42
diff --git a/utils/osmo-auc-gen.c b/utils/osmo-auc-gen.c
index 4e07fa74..4f36dee5 100644
--- a/utils/osmo-auc-gen.c
+++ b/utils/osmo-auc-gen.c
@@ -80,6 +80,7 @@ static void help()
"-O --op\tSpecify OP (only for 3G)\n"
"-f --amf\tSpecify AMF (only for 3G)\n"
"-s --sqn\tSpecify SQN (only for 3G)\n"
+ "-i --ind\tSpecify IND slot for new SQN after AUTS (only for 3G)\n"
"-A --auts\tSpecify AUTS (only for 3G)\n"
"-r --rand\tSpecify random value\n"
"-I --ipsec\tOutput in triplets.dat format for strongswan\n");
@@ -96,10 +97,12 @@ int main(int argc, char **argv)
struct osmo_auth_vector *vec = &_vec;
uint8_t _rand[16], _auts[14];
uint64_t sqn;
+ unsigned int ind;
int rc, option_index;
int rand_is_set = 0;
int auts_is_set = 0;
int sqn_is_set = 0;
+ int ind_is_set = 0;
int fmt_triplets_dat = 0;
printf("osmo-auc-gen (C) 2011-2012 by Harald Welte\n");
@@ -118,6 +121,7 @@ int main(int argc, char **argv)
{ "op", 1, 0, 'O' },
{ "amf", 1, 0, 'f' },
{ "sqn", 1, 0, 's' },
+ { "ind", 1, 0, 'i' },
{ "rand", 1, 0, 'r' },
{ "auts", 1, 0, 'A' },
{ "help", 0, 0, 'h' },
@@ -126,7 +130,7 @@ int main(int argc, char **argv)
rc = 0;
- c = getopt_long(argc, argv, "23a:k:o:f:s:r:hO:A:I", long_options,
+ c = getopt_long(argc, argv, "23a:k:o:f:s:i:r:hO:A:I", long_options,
&option_index);
if (c == -1)
@@ -202,6 +206,14 @@ int main(int argc, char **argv)
sqn = strtoull(optarg, 0, 10);
sqn_is_set = 1;
break;
+ case 'i':
+ if (test_aud.type != OSMO_AUTH_TYPE_UMTS) {
+ fprintf(stderr, "Only UMTS has IND\n");
+ exit(2);
+ }
+ ind = atoi(optarg);
+ ind_is_set = 1;
+ break;
case 'r':
rc = osmo_hexparse(optarg, _rand, sizeof(_rand));
rand_is_set = 1;
@@ -257,6 +269,22 @@ int main(int argc, char **argv)
test_aud.u.umts.sqn = sqn - seq_1;
test_aud.u.umts.ind = sqn & ind_mask;
}
+
+ if (sqn_is_set && ind_is_set) {
+ fprintf(stderr, "Requesting --sqn %"PRIu64" implies IND=%u,"
+ " so no further --ind argument is allowed.\n",
+ sqn, test_aud.u.umts.ind);
+ exit(2);
+ }
+
+ if (ind_is_set) {
+ if (ind >= (1 << test_aud.u.umts.ind_bitlen)) {
+ fprintf(stderr, "Requested --ind %u is too large for IND bitlen of %u\n",
+ ind, test_aud.u.umts.ind_bitlen);
+ exit(2);
+ }
+ test_aud.u.umts.ind = ind;
+ }
}
if (!auts_is_set)