aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auc/auc_3g_test.c
diff options
context:
space:
mode:
authorNeels Hofmeyr <neels@hofmeyr.de>2017-01-31 16:40:28 +0100
committerNeels Hofmeyr <nhofmeyr@sysmocom.de>2017-02-01 14:22:40 +0100
commit6b883f784835943e1b3dbcf816dd2a949dd6805d (patch)
tree249aa4d95494bcf330bc179a0d22ae8b00b34a3e /tests/auc/auc_3g_test.c
parent8cde66242a6223d0f84b89ece0ec933d6f0cd8e5 (diff)
auth: verify test sets from 3GPP TS 55.205
Put to-text conversion of the 3GPP TS 55.205 PDF's section defining the test vectors in tests/auc/gen_ts_55_205_test_sets/ts55_205_test_sets.txt and add python script to generate auc_ts_55_205_test_sets.c from that at build time. The generated auc_ts_55_205_test_sets.c runs through all 19 test sets, verifying that our gsm_milenage() matches the reference data. Change-Id: Idff9d757ab956179aa41ada2a223fd9f439aafbd
Diffstat (limited to 'tests/auc/auc_3g_test.c')
-rw-r--r--tests/auc/auc_3g_test.c29
1 files changed, 15 insertions, 14 deletions
diff --git a/tests/auc/auc_3g_test.c b/tests/auc/auc_3g_test.c
index bfca39f..0923a27 100644
--- a/tests/auc/auc_3g_test.c
+++ b/tests/auc/auc_3g_test.c
@@ -20,6 +20,7 @@
#include <stdio.h>
#include <string.h>
+#include <inttypes.h>
#include <osmocom/core/application.h>
#include <osmocom/core/utils.h>
@@ -39,7 +40,7 @@
OSMO_ASSERT((val) expect_op); \
} while (0);
-const char *vec_str(const struct osmo_auth_vector *vec)
+char *vec_str(const struct osmo_auth_vector *vec)
{
static char buf[1024];
char *pos = buf;
@@ -67,7 +68,7 @@ const char *vec_str(const struct osmo_auth_vector *vec)
}
#define VEC_IS(vec, expect) do { \
- const char *_is = vec_str(vec); \
+ char *_is = vec_str(vec); \
fprintf(stderr, "auth vector ==\n%s\n", _is); \
if (strcmp(_is, expect)) { \
fprintf(stderr, "MISMATCH! expected ==\n%s\n", \
@@ -78,7 +79,7 @@ const char *vec_str(const struct osmo_auth_vector *vec)
if (*a != *b) { \
while (a > _is && *(a-1) != '\n') a--; \
fprintf(stderr, "mismatch at %d:\n" \
- "%s", a - _is, a); \
+ "%s", (int)(a - _is), a); \
break; \
} \
} \
@@ -112,13 +113,13 @@ static void test_gen_vectors_2g_only(void)
osmo_hexparse("EB215756028D60E3275E613320AEC880",
aud2g.u.gsm.ki, sizeof(aud2g.u.gsm.ki));
- aud3g = (struct osmo_sub_auth_data){ {0} };
+ aud3g = (struct osmo_sub_auth_data){ 0 };
osmo_hexparse("39fa2f4e3d523d8619a73b4f65c3e14d",
fake_rand, sizeof(fake_rand));
vec = (struct osmo_auth_vector){ {0} };
- VERBOSE_ASSERT(aud3g.u.umts.sqn, == 0, "%d");
+ VERBOSE_ASSERT(aud3g.u.umts.sqn, == 0, "%"PRIu64);
rc = auc_compute_vectors(&vec, 1, &aud2g, &aud3g, NULL, NULL);
VERBOSE_ASSERT(rc, == 1, "%d");
@@ -134,7 +135,7 @@ static void test_gen_vectors_2g_only(void)
" auth_types: 01000000\n"
);
- VERBOSE_ASSERT(aud3g.u.umts.sqn, == 0, "%d");
+ VERBOSE_ASSERT(aud3g.u.umts.sqn, == 0, "%"PRIu64);
/* even though vec is not zero-initialized, it should produce the same
* result (regardless of the umts sequence nr) */
@@ -188,7 +189,7 @@ static void test_gen_vectors_2g_plus_3g(void)
fake_rand, sizeof(fake_rand));
vec = (struct osmo_auth_vector){ {0} };
- VERBOSE_ASSERT(aud3g.u.umts.sqn, == 0, "%d");
+ VERBOSE_ASSERT(aud3g.u.umts.sqn, == 0, "%"PRIu64);
rc = auc_compute_vectors(&vec, 1, &aud2g, &aud3g, NULL, NULL);
VERBOSE_ASSERT(rc, == 1, "%d");
@@ -204,15 +205,15 @@ static void test_gen_vectors_2g_plus_3g(void)
" auth_types: 03000000\n"
);
- VERBOSE_ASSERT(aud3g.u.umts.sqn, == 1, "%d");
+ VERBOSE_ASSERT(aud3g.u.umts.sqn, == 1, "%"PRIu64);
/* even though vec is not zero-initialized, it should produce the same
* result with the same sequence nr */
aud3g.u.umts.sqn = 0;
- VERBOSE_ASSERT(aud3g.u.umts.sqn, == 0, "%d");
+ VERBOSE_ASSERT(aud3g.u.umts.sqn, == 0, "%"PRIu64);
rc = auc_compute_vectors(&vec, 1, &aud2g, &aud3g, NULL, NULL);
VERBOSE_ASSERT(rc, == 1, "%d");
- VERBOSE_ASSERT(aud3g.u.umts.sqn, == 1, "%d");
+ VERBOSE_ASSERT(aud3g.u.umts.sqn, == 1, "%"PRIu64);
VEC_IS(&vec,
" rand: 39fa2f4e3d523d8619a73b4f65c3e14d\n"
@@ -254,7 +255,7 @@ static void test_gen_vectors_3g_only(void)
fake_rand, sizeof(fake_rand));
vec = (struct osmo_auth_vector){ {0} };
- VERBOSE_ASSERT(aud3g.u.umts.sqn, == 0, "%d");
+ VERBOSE_ASSERT(aud3g.u.umts.sqn, == 0, "%"PRIu64);
rc = auc_compute_vectors(&vec, 1, &aud2g, &aud3g, NULL, NULL);
VERBOSE_ASSERT(rc, == 1, "%d");
@@ -280,15 +281,15 @@ static void test_gen_vectors_3g_only(void)
* hence expecting kc: 059a4f668f6fbe39
*/
- VERBOSE_ASSERT(aud3g.u.umts.sqn, == 1, "%d");
+ VERBOSE_ASSERT(aud3g.u.umts.sqn, == 1, "%"PRIu64);
/* even though vec is not zero-initialized, it should produce the same
* result with the same sequence nr */
aud3g.u.umts.sqn = 0;
- VERBOSE_ASSERT(aud3g.u.umts.sqn, == 0, "%d");
+ VERBOSE_ASSERT(aud3g.u.umts.sqn, == 0, "%"PRIu64);
rc = auc_compute_vectors(&vec, 1, &aud2g, &aud3g, NULL, NULL);
VERBOSE_ASSERT(rc, == 1, "%d");
- VERBOSE_ASSERT(aud3g.u.umts.sqn, == 1, "%d");
+ VERBOSE_ASSERT(aud3g.u.umts.sqn, == 1, "%"PRIu64);
VEC_IS(&vec,
" rand: 39fa2f4e3d523d8619a73b4f65c3e14d\n"