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
This commit is contained in:
Neels Hofmeyr 2017-01-31 16:40:28 +01:00 committed by Neels Hofmeyr
parent 8cde66242a
commit 6b883f7848
12 changed files with 1609 additions and 14 deletions

3
.gitignore vendored
View File

@ -1,5 +1,6 @@
*.o
*.db
*.pyc
.*.sw?
.version
Makefile
@ -25,3 +26,5 @@ src/db_test
tests/testsuite
tests/auc/auc_3g_test
tests/auc/auc_ts_55_205_test_sets.c
tests/auc/auc_ts_55_205_test_sets

View File

@ -48,4 +48,5 @@ AC_OUTPUT(
sql/Makefile
tests/Makefile
tests/auc/Makefile
tests/auc/gen_ts_55_205_test_sets/Makefile
)

View File

@ -1,3 +1,5 @@
SUBDIRS = gen_ts_55_205_test_sets
AM_CPPFLAGS = \
$(all_includes) \
-I$(top_srcdir)/src \
@ -16,10 +18,14 @@ AM_LDFLAGS = \
EXTRA_DIST = \
auc_3g_test.ok \
auc_3g_test.err \
auc_ts_55_205_test_sets.ok \
auc_ts_55_205_test_sets.err \
$(NULL)
noinst_PROGRAMS = \
auc_3g_test \
auc_ts_55_205_test_sets \
$(NULL)
auc_3g_test_SOURCES = \
@ -32,3 +38,18 @@ auc_3g_test_LDADD = \
$(LIBOSMOCORE_LIBS) \
$(LIBOSMOGSM_LIBS) \
$(NULL)
auc_ts_55_205_test_sets_SOURCES = \
$(builddir)/auc_ts_55_205_test_sets.c \
$(NULL)
auc_ts_55_205_test_sets_LDADD = \
$(top_srcdir)/src/auc.c \
$(top_srcdir)/src/logging.c \
$(LIBOSMOCORE_LIBS) \
$(LIBOSMOGSM_LIBS) \
$(NULL)
auc_ts_55_205_test_sets.c: $(top_srcdir)/tests/auc/gen_ts_55_205_test_sets/*
$(top_srcdir)/tests/auc/gen_ts_55_205_test_sets/pdftxt_2_c.py > $@

View File

@ -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"

View File

@ -0,0 +1,304 @@
===== test_set_1
aud3g.u.umts.sqn == 0
DAUC rand 23553cbe9637a89d218ae64dae47bf35
DAUC compute vector [0]/1: 3G only
rc == 1
auth vector ==
rand: 23553cbe9637a89d218ae64dae47bf35
ck: b40ba9a3c58b2a05bbf0d987b21bf8cb
ik: f769bcd751044604127672711c6d3441
res: a54211d5e3ba50bf0000000000000000
kc: eae4be823af9a08b
sres: 46f8416a
===== test_set_1: SUCCESS
===== test_set_2
aud3g.u.umts.sqn == 0
DAUC rand 9f7c8d021accf4db213ccff0c7f71a6a
DAUC compute vector [0]/1: 3G only
rc == 1
auth vector ==
rand: 9f7c8d021accf4db213ccff0c7f71a6a
ck: 5dbdbb2954e8f3cde665b046179a5098
ik: 59a92d3b476a0443487055cf88b2307b
res: 8011c48c0c214ed20000000000000000
kc: aa01739b8caa976d
sres: 8c308a5e
===== test_set_2: SUCCESS
===== test_set_3
aud3g.u.umts.sqn == 0
DAUC rand ce83dbc54ac0274a157c17f80d017bd6
DAUC compute vector [0]/1: 3G only
rc == 1
auth vector ==
rand: ce83dbc54ac0274a157c17f80d017bd6
ck: e203edb3971574f5a94b0d61b816345d
ik: 0c4524adeac041c4dd830d20854fc46b
res: f365cd683cd92e960000000000000000
kc: 9a8ec95f408cc507
sres: cfbce3fe
===== test_set_3: SUCCESS
===== test_set_4
aud3g.u.umts.sqn == 0
DAUC rand 74b0cd6031a1c8339b2b6ce2b8c4a186
DAUC compute vector [0]/1: 3G only
rc == 1
auth vector ==
rand: 74b0cd6031a1c8339b2b6ce2b8c4a186
ck: 7657766b373d1c2138f307e3de9242f9
ik: 1c42e960d89b8fa99f2744e0708ccb53
res: 5860fc1bce351e7e0000000000000000
kc: cdc1dc0841b81a22
sres: 9655e265
===== test_set_4: SUCCESS
===== test_set_5
aud3g.u.umts.sqn == 0
DAUC rand ee6466bc96202c5a557abbeff8babf63
DAUC compute vector [0]/1: 3G only
rc == 1
auth vector ==
rand: ee6466bc96202c5a557abbeff8babf63
ck: 3f8c7587fe8e4b233af676aede30ba3b
ik: a7466cc1e6b2a1337d49d3b66e95d7b4
res: 16c8233f05a0ac280000000000000000
kc: df75bc5ea899879f
sres: 13688f17
===== test_set_5: SUCCESS
===== test_set_6
aud3g.u.umts.sqn == 0
DAUC rand 194aa756013896b74b4a2a3b0af4539e
DAUC compute vector [0]/1: 3G only
rc == 1
auth vector ==
rand: 194aa756013896b74b4a2a3b0af4539e
ck: 4cd0846020f8fa0731dd47cbdc6be411
ik: 88ab80a415f15c73711254a1d388f696
res: 8c25a16cd918a1df0000000000000000
kc: 84b417ae3aeab4f3
sres: 553d00b3
===== test_set_6: SUCCESS
===== test_set_7
aud3g.u.umts.sqn == 0
DAUC rand 3a4c2b3245c50eb5c71d08639395764d
DAUC compute vector [0]/1: 3G only
rc == 1
auth vector ==
rand: 3a4c2b3245c50eb5c71d08639395764d
ck: 10f05bab75a99a5fbb98a9c287679c3b
ik: f9ec0865eb32f22369cade40c59c3a44
res: a63241e1ffc3e5ab0000000000000000
kc: 3b4e244cdc60ce03
sres: 59f1a44a
===== test_set_7: SUCCESS
===== test_set_8
aud3g.u.umts.sqn == 0
DAUC rand f761e5e93d603feb730e27556cb8a2ca
DAUC compute vector [0]/1: 3G only
rc == 1
auth vector ==
rand: f761e5e93d603feb730e27556cb8a2ca
ck: 71236b7129f9b22ab77ea7a54c96da22
ik: 90527ebaa5588968db41727325a04d9e
res: 4a90b2171ac83a760000000000000000
kc: 8d4ec01de597acfe
sres: 50588861
===== test_set_8: SUCCESS
===== test_set_9
aud3g.u.umts.sqn == 0
DAUC rand 08eff828b13fdb562722c65c7f30a9b2
DAUC compute vector [0]/1: 3G only
rc == 1
auth vector ==
rand: 08eff828b13fdb562722c65c7f30a9b2
ck: 08cef6d004ec61471a3c3cda048137fa
ik: ed0318ca5deb9206272f6e8fa64ba411
res: 4bc2212d8624910a0000000000000000
kc: d8debc4ffbcd60aa
sres: cde6b027
===== test_set_9: SUCCESS
===== test_set_10
aud3g.u.umts.sqn == 0
DAUC rand 679ac4dbacd7d233ff9d6806f4149ce3
DAUC compute vector [0]/1: 3G only
rc == 1
auth vector ==
rand: 679ac4dbacd7d233ff9d6806f4149ce3
ck: 69b1cae7c7429d975e245cacb05a517c
ik: 74f24e8c26df58e1b38d7dcd4f1b7fbd
res: 6fc30fee6d1235230000000000000000
kc: f0eaa50a1edcebb7
sres: 02d13acd
===== test_set_10: SUCCESS
===== test_set_11
aud3g.u.umts.sqn == 0
DAUC rand 4c47eb3076dc55fe5106cb2034b8cd78
DAUC compute vector [0]/1: 3G only
rc == 1
auth vector ==
rand: 4c47eb3076dc55fe5106cb2034b8cd78
ck: 908c43f0569cb8f74bc971e706c36c5f
ik: c251df0d888dd9329bcf46655b226e40
res: aefa357beac2a87a0000000000000000
kc: 82dbab7f83f063da
sres: 44389d01
===== test_set_11: SUCCESS
===== test_set_12
aud3g.u.umts.sqn == 0
DAUC rand 311c4c929744d675b720f3b7e9b1cbd0
DAUC compute vector [0]/1: 3G only
rc == 1
auth vector ==
rand: 311c4c929744d675b720f3b7e9b1cbd0
ck: 44c0f23c5493cfd241e48f197e1d1012
ik: 0c9fb81613884c2535dd0eabf3b440d8
res: 98dbbd099b3b408d0000000000000000
kc: 3c66cb98cab2d33d
sres: 03e0fd84
===== test_set_12: SUCCESS
===== test_set_13
aud3g.u.umts.sqn == 0
DAUC rand cf7d0ab1d94306950bf12018fbd46887
DAUC compute vector [0]/1: 3G only
rc == 1
auth vector ==
rand: cf7d0ab1d94306950bf12018fbd46887
ck: 5af86b80edb70df5292cc1121cbad50c
ik: 7f4d6ae7440e18789a8b75ad3f42f03a
res: af4a411e1139f2c20000000000000000
kc: 9612b5d88a4130bb
sres: be73b3dc
===== test_set_13: SUCCESS
===== test_set_14
aud3g.u.umts.sqn == 0
DAUC rand 1f0f8578464fd59b64bed2d09436b57a
DAUC compute vector [0]/1: 3G only
rc == 1
auth vector ==
rand: 1f0f8578464fd59b64bed2d09436b57a
ck: 3f8c3f3ccf7625bf77fc94bcfd22fd26
ik: abcbae8fd46115e9961a55d0da5f2078
res: 7bffa5c2f41fbc050000000000000000
kc: 75a150df3c6aed08
sres: 8fe019c7
===== test_set_14: SUCCESS
===== test_set_15
aud3g.u.umts.sqn == 0
DAUC rand 59b75f14251c75031d0bcbac1c2c04c7
DAUC compute vector [0]/1: 3G only
rc == 1
auth vector ==
rand: 59b75f14251c75031d0bcbac1c2c04c7
ck: d42b2d615e49a03ac275a5aef97af892
ik: 0b3f8d024fe6bfafaa982b8f82e319c2
res: 7e3f44c7591f6f450000000000000000
kc: b7f92e426a36fec5
sres: 27202b82
===== test_set_15: SUCCESS
===== test_set_16
aud3g.u.umts.sqn == 0
DAUC rand f69b78f300a0568bce9f0cb93c4be4c9
DAUC compute vector [0]/1: 3G only
rc == 1
auth vector ==
rand: f69b78f300a0568bce9f0cb93c4be4c9
ck: 6edaf99e5bd9f85d5f36d91c1272fb4b
ik: d61c853c280dd9c46f297baec386de17
res: 70f6bdb9ad21525f0000000000000000
kc: 88d9de10a22004c5
sres: ddd7efe6
===== test_set_16: SUCCESS
===== test_set_17
aud3g.u.umts.sqn == 0
DAUC rand b120f1c1a0102a2f507dd543de68281f
DAUC compute vector [0]/1: 3G only
rc == 1
auth vector ==
rand: b120f1c1a0102a2f507dd543de68281f
ck: 66195dbed0313274c5ca7766615fa25e
ik: 66bec707eb2afc476d7408a8f2927b36
res: 479dd25c20792d630000000000000000
kc: a819e577a8d6175b
sres: 67e4ff3f
===== test_set_17: SUCCESS
===== test_set_18
aud3g.u.umts.sqn == 0
DAUC rand 81e92b6c0ee0e12ebceba8d92a99dfa5
DAUC compute vector [0]/1: 3G only
rc == 1
auth vector ==
rand: 81e92b6c0ee0e12ebceba8d92a99dfa5
ck: 5349fbe098649f948f5d2e973a81c00f
ik: 9744871ad32bf9bbd1dd5ce54e3e2e5a
res: 28d7b0f2a2ec3de50000000000000000
kc: 9a8d0e883ff0887a
sres: 8a3b8d17
===== test_set_18: SUCCESS
===== test_set_19
aud3g.u.umts.sqn == 0
DAUC rand 9fddc72092c6ad036b6e464789315b78
DAUC compute vector [0]/1: 3G only
rc == 1
auth vector ==
rand: 9fddc72092c6ad036b6e464789315b78
ck: b5f2da03883b69f96bf52e029ed9ac45
ik: b4721368bc16ea67875c5598688bb0ef
res: a95100e2760952cd0000000000000000
kc: ed29b2f1c27f9f34
sres: df58522f
===== test_set_19: SUCCESS

View File

@ -0,0 +1,2 @@
3GPP TS 55.205 Test Sets
Done

View File

@ -0,0 +1,6 @@
EXTRA_DIST = \
func_template.c \
main_template.c \
pdftxt_2_c.py \
ts55_205_test_sets.txt \
$(NULL)

View File

@ -0,0 +1,64 @@
/* gen_ts_55_205_test_sets/func_template.c: Template to generate test code
* from 3GPP TS 55.205 test sets */
/* (C) 2016 by sysmocom s.f.m.c. GmbH <info@sysmocom.de>
*
* All Rights Reserved
*
* Author: Neels Hofmeyr <nhofmeyr@sysmocom.de>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
static void {func_name}(void)
{{
struct osmo_sub_auth_data aud2g;
struct osmo_sub_auth_data aud3g;
struct osmo_auth_vector vec;
int rc;
comment_start();
aud2g = (struct osmo_sub_auth_data){{ 0 }};
aud3g = (struct osmo_sub_auth_data){{
.type = OSMO_AUTH_TYPE_UMTS,
.algo = OSMO_AUTH_ALG_MILENAGE,
}};
osmo_hexparse("{Ki}",
aud3g.u.umts.k, sizeof(aud3g.u.umts.k));
osmo_hexparse("{OPc}",
aud3g.u.umts.opc, sizeof(aud3g.u.umts.opc));
osmo_hexparse("{RAND}",
fake_rand, sizeof(fake_rand));
vec = (struct osmo_auth_vector){{ {{0}} }};
VERBOSE_ASSERT(aud3g.u.umts.sqn, == 0, "%"PRIu64);
rc = auc_compute_vectors(&vec, 1, &aud2g, &aud3g, NULL, NULL);
VERBOSE_ASSERT(rc, == 1, "%d");
VEC_IS(&vec,
" rand: {RAND}\n"
" ck: {MIL3G-CK}\n"
" ik: {MIL3G-IK}\n"
" res: {MIL3G-RES}0000000000000000\n"
" kc: {Kc}\n"
" sres: {SRES#1}\n"
);
comment_end();
}}

View File

@ -0,0 +1,115 @@
/* gen_ts_55_205_test_sets/main_template.c: Template to generate test code
* from 3GPP TS 55.205 test sets */
/* (C) 2016 by sysmocom s.f.m.c. GmbH <info@sysmocom.de>
*
* All Rights Reserved
*
* Author: Neels Hofmeyr <nhofmeyr@sysmocom.de>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include <stdio.h>
#include <string.h>
#include <inttypes.h>
#include <osmocom/core/application.h>
#include <osmocom/core/utils.h>
#include <osmocom/core/logging.h>
#include <osmocom/crypt/auth.h>
#include "logging.h"
#include "auc.h"
#define comment_start() fprintf(stderr, "\n===== %s\n", __func__);
#define comment_end() fprintf(stderr, "===== %s: SUCCESS\n\n", __func__);
#define VERBOSE_ASSERT(val, expect_op, fmt) \
do { \
fprintf(stderr, #val " == " fmt "\n", (val)); \
OSMO_ASSERT((val) expect_op); \
} while (0);
char *vec_str(const struct osmo_auth_vector *vec)
{
static char buf[1024];
char *pos = buf;
char *end = buf + sizeof(buf);
#define append(what) \
if (pos >= end) \
return buf; \
pos += snprintf(pos, sizeof(buf) - (pos - buf), \
" " #what ": %s\n", \
osmo_hexdump_nospc((void*)&vec->what, sizeof(vec->what)))
append(rand);
append(ck);
append(ik);
append(res);
append(kc);
append(sres);
#undef append
return buf;
}
#define VEC_IS(vec, expect) do { \
char *_is = vec_str(vec); \
fprintf(stderr, "auth vector ==\n%s\n", _is); \
if (strcmp(_is, expect)) { \
fprintf(stderr, "MISMATCH! expected ==\n%s\n", \
expect); \
char *a = _is; \
char *b = expect; \
for (; *a && *b; a++, b++) { \
if (*a != *b) { \
while (a > _is && *(a-1) != '\n') a--; \
fprintf(stderr, "mismatch at %d:\n" \
"%s", (int)(a - _is), a); \
break; \
} \
} \
OSMO_ASSERT(false); \
} \
} while (0)
uint8_t fake_rand[16] = { 0 };
int rand_get(uint8_t *rand, unsigned int len)
{
OSMO_ASSERT(len <= sizeof(fake_rand));
memcpy(rand, fake_rand, len);
return len;
}
FUNCTIONS
int main()
{
printf("3GPP TS 55.205 Test Sets\n");
osmo_init_logging(&hlr_log_info);
log_set_print_filename(osmo_stderr_target, 0);
log_set_print_timestamp(osmo_stderr_target, 0);
log_set_use_color(osmo_stderr_target, 0);
log_set_print_category(osmo_stderr_target, 1);
FUNCTION_CALLS
printf("Done\n");
return 0;
}

View File

@ -0,0 +1,99 @@
#!/usr/bin/env python3
# Convert test sets pasted from 3GPP TS 55.205 to C code.
# (C) 2016 by sysmocom s.f.m.c. GmbH <info@sysmocom.de>
#
# All Rights Reserved
#
# Author: Neels Hofmeyr <nhofmeyr@sysmocom.de>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import sys, os
script_dir = sys.path[0]
fields = (
'Ki',
'RAND',
'OP',
'OPc',
'MIL3G-RES',
'SRES#1',
'SRES#2',
'MIL3G-CK',
'MIL3G-IK',
'Kc',
)
test_sets_lines = []
test_set_lines = None
for line in [l.strip() for l in open(os.path.join(script_dir, 'ts55_205_test_sets.txt'), 'r')]:
if line.startswith('Test Set'):
if test_set_lines:
test_sets_lines.append(test_set_lines)
test_set_lines = []
elif len(line) == 8:
try:
is_hex = int(line, 16)
test_set_lines.append(line)
except ValueError:
pass
if test_set_lines:
test_sets_lines.append(test_set_lines)
# Magic fixups for PDF-to-text uselessness
idx = (( 0, 10, 15, 19),
( 1, 11, 16, 20),
( 2, 12, 17, 21),
( 3, 13, 18, 22),
( 4, 14),
( 5, ),
( 6, ),
( 7, 23, 26, 28),
( 8, 24, 27, 29),
( 9, 25 ),
)
test_sets = []
for l in test_sets_lines:
test_sets.append( [ ''.join([l[i] for i in li]) for li in idx ] )
func_templ = open(os.path.join(script_dir, 'func_template.c'), 'r').read()
funcs = []
func_calls = []
nr = 0
for test_set in test_sets:
nr += 1
func_name = 'test_set_%d' % nr
kwargs = dict(zip(fields, test_set))
kwargs['func_name'] = func_name
func_calls.append('\t%s();' % func_name)
funcs.append(func_templ.format(**kwargs))
templ = open(os.path.join(script_dir, 'main_template.c')).read()
code = templ.replace('FUNCTIONS', '\n'.join(funcs)).replace('FUNCTION_CALLS', '\n'.join(func_calls))
print('''
/***** DO NOT EDIT THIS FILE -- THIS CODE IS GENERATED *****
***** by gen_ts_55_205_test_sets/pdftxt_2_c.py *****/
''')
print(code)

View File

@ -0,0 +1,972 @@
Test Set 1
Ki
RAND
OP
OPc
MIL3G-RES
SRES#1
SRES#2
MIL3G-CK
MIL3G-IK
Kc
465b5ce8
23553cbe
cdc202d5
cd63cb71
a54211d5
46f8416a
a54211d5
b40ba9a3
f769bcd7
eae4be82
b199b49f
9637a89d
123e20f6
954a9f4e
e3ba50bf
aa5f0a2e
218ae64d
2b6d676a
48a5994e
e238a6bc
ae47bf35
c72cb318
37a02baf
c58b2a05
51044604
3af9a08b
bbf0d987
12767271
b21bf8cb
1c6d3441
Test Set 2
Ki
RAND
OP
OPc
MIL3G-RES
SRES#1
SRES#2
MIL3G-CK
MIL3G-IK
Kc
fec86ba6
9f7c8d02
dbc59adc
1006020f
8011c48c
8c308a5e
8011c48c
5dbdbb29
59a92d3b
aa01739b
eb707ed0
1accf4db
b6f9a0ef
0a478bf6
0c214ed2
8905757b
213ccff0
735477b7
b699f15c
1bb44b8f
c7f71a6a
fadf8374
062e42b3
54e8f3cd
476a0443
8caa976d
e665b046
487055cf
179a5098
88b2307b
ETSI
3GPP TS 55.205 version 6.2.0 Release 6
10
ETSI TS 155 205 V6.2.0 (2006-03)
Test Set 3
Ki
RAND
OP
OPc
MIL3G-RES
SRES#1
SRES#2
MIL3G-CK
MIL3G-IK
Kc
9e5944ae
ce83dbc5
223014c5
a64a507a
f365cd68
cfbce3fe
f365cd68
e203edb3
0c4524ad
9a8ec95f
a94b8116
4ac0274a
806694c0
e1a2a98b
3cd92e96
5c82fbf9
157c17f8
07ca1eee
b88eb421
f32db751
0d017bd6
f57f004f
0135dc87
971574f5
eac041c4
408cc507
a94b0d61
dd830d20
b816345d
854fc46b
Test Set 4
Ki
RAND
OP
OPc
MIL3G-RES
SRES#1
SRES#2
MIL3G-CK
MIL3G-IK
Kc
4ab1deb0
74b0cd60
2d16c5cd
dcf07cbd
5860fc1b
9655e265
5860fc1b
7657766b
1c42e960
cdc1dc08
5ca6ceb0
31a1c833
1fdf6b22
51855290
ce351e7e
51fc98e7
9b2b6ce2
383584e3
b92a07a9
7d026a84
b8c4a186
bef2a8d8
891e523e
373d1c21
d89b8fa9
41b81a22
38f307e3
9f2744e0
de9242f9
708ccb53
Test Set 5
Ki
RAND
OP
OPc
MIL3G-RES
SRES#1
SRES#2
MIL3G-CK
MIL3G-IK
Kc
6c38a116
ee6466bc
1ba00a1a
3803ef53
16c8233f
13688f17
16c8233f
3f8c7587
a7466cc1
df75bc5e
ac280c45
96202c5a
7c6700ac
63b947c6
05a0ac28
4f59332e
557abbef
8c3ff3e9
aaa225e5
e35c8c4f
f8babf63
6ad08725
8fae3934
fe8e4b23
e6b2a133
a899879f
3af676ae
7d49d3b6
de30ba3b
6e95d7b4
Test Set 6
Ki
RAND
OP
OPc
MIL3G-RES
SRES#1
SRES#2
MIL3G-CK
MIL3G-IK
Kc
2d609d4d
194aa756
460a4838
c35a0ab0
8c25a16c
553d00b3
8c25a16c
4cd08460
88ab80a4
84b417ae
b0ac5bf0
013896b7
5427aa39
bcbfc925
d918a1df
d2c0de26
4b4a2a3b
264aac8e
2caff15f
7014de0d
0af4539e
fc9e73e8
24efbde0
20f8fa07
15f15c73
3aeab4f3
31dd47cb
711254a1
dc6be411
d388f696
ETSI
3GPP TS 55.205 version 6.2.0 Release 6
11
ETSI TS 155 205 V6.2.0 (2006-03)
Test Set 7
Ki
RAND
OP
OPc
MIL3G-RES
SRES#1
SRES#2
MIL3G-CK
MIL3G-IK
Kc
a530a7fe
3a4c2b32
511c6c4e
27953e49
a63241e1
59f1a44a
a63241e1
10f05bab
f9ec0865
3b4e244c
428fad10
45c50eb5
83e38c89
bc8af6dc
ffc3e5ab
82c45edd
c71d0863
b1c5d8dd
c6e730eb
fce13884
9395764d
e62426fa
80286be3
75a99a5f
eb32f223
dc60ce03
bb98a9c2
69cade40
87679c3b
c59c3a44
Test Set 8
Ki
RAND
OP
OPc
MIL3G-RES
SRES#1
SRES#2
MIL3G-CK
MIL3G-IK
Kc
d9151cf0
f761e5e9
75fc2233
c4c93eff
4a90b217
50588861
4a90b217
71236b71
90527eba
8d4ec01d
4896e258
3d603feb
a44294ee
e8a08138
1ac83a76
30bf2e08
730e2755
8e6de25c
c203d4c2
267b8360
6cb8a2ca
4353d26b
7ce4e3d9
29f9b22a
a5588968
e597acfe
b77ea7a5
db417273
4c96da22
25a04d9e
Test Set 9
Ki
RAND
OP
OPc
MIL3G-RES
SRES#1
SRES#2
MIL3G-CK
MIL3G-IK
Kc
a0e2971b
08eff828
323792fa
82a26f22
4bc2212d
cde6b027
4bc2212d
08cef6d0
ed0318ca
d8debc4f
6822e8d3
b13fdb56
ca21fb4d
bba9e948
8624910a
54a18cc2
2722c65c
5d6f13c1
8f949a10
35624ecb
7f30a9b2
45a9d2c1
d98e9cc4
04ec6147
5deb9206
fbcd60aa
1a3c3cda
272f6e8f
048137fa
a64ba411
Test Set 10
Ki
RAND
OP
OPc
MIL3G-RES
SRES#1
SRES#2
MIL3G-CK
MIL3G-IK
Kc
0da6f7ba
679ac4db
4b9a26fa
0db1071f
6fc30fee
02d13acd
6fc30fee
69b1cae7
74f24e8c
f0eaa50a
86d5eac8
acd7d233
459e3acb
8767562c
6d123523
a19cf563
ff9d6806
ff36f401
a43a0a64
ac58642d
f4149ce3
5de3bdc1
c41e8d08
c7429d97
26df58e1
1edcebb7
5e245cac
b38d7dcd
b05a517c
4f1b7fbd
ETSI
3GPP TS 55.205 version 6.2.0 Release 6
12
ETSI TS 155 205 V6.2.0 (2006-03)
Test Set 11
Ki
RAND
OP
OPc
MIL3G-RES
SRES#1
SRES#2
MIL3G-CK
MIL3G-IK
Kc
77b45843
4c47eb30
bf3286c7
d483afae
aefa357b
44389d01
aefa357b
908c43f0
c251df0d
82dbab7f
c88e58c1
76dc55fe
a51409ce
562409a3
eac2a87a
0d202684
5106cb20
95724d50
26b5bb0b
515ed430
34b8cd78
3bfe6e70
20c4d762
569cb8f7
888dd932
83f063da
4bc971e7
9bcf4665
06c36c5f
5b226e40
Test Set 12
Ki
RAND
OP
OPc
MIL3G-RES
SRES#1
SRES#2
MIL3G-CK
MIL3G-IK
Kc
729b1772
311c4c92
d04c9c35
228c2f2f
98dbbd09
03e0fd84
98dbbd09
44c0f23c
0c9fb816
3c66cb98
9270dd87
9744d675
bd2262fa
06ac3268
9b3b408d
ccdf1bfe
b720f3b7
810d2924
a9e616ee
29b4e9bb
e9b1cbd0
d036fd13
16db4ba1
5493cfd2
13884c25
cab2d33d
41e48f19
35dd0eab
7e1d1012
f3b440d8
Test Set 13
Ki
RAND
OP
OPc
MIL3G-RES
SRES#1
SRES#2
MIL3G-CK
MIL3G-IK
Kc
d32dd23e
cf7d0ab1
fe75905b
d22a4b41
af4a411e
be73b3dc
af4a411e
5af86b80
7f4d6ae7
9612b5d8
89dc6623
d9430695
9da47d35
80a53257
1139f2c2
54ca12eb
0bf12018
6236d031
08a5ff70
79dd32fa
fbd46887
4e09c32e
d9f67ec7
edb70df5
440e1878
8a4130bb
292cc112
9a8b75ad
1cbad50c
3f42f03a
Test Set 14
Ki
RAND
OP
OPc
MIL3G-RES
SRES#1
SRES#2
MIL3G-CK
MIL3G-IK
Kc
af7c65e1
1f0f8578
0c7acb8d
a4cf5c81
7bffa5c2
8fe019c7
7bffa5c2
3f8c3f3c
abcbae8f
75a150df
927221de
464fd59b
95b7d4a3
55c08a7e
f41fbc05
591187a2
64bed2d0
1c5aca6d
ff418e54
c5987a53
9436b57a
26345a88
43b98e55
cf7625bf
d46115e9
3c6aed08
77fc94bc
961a55d0
fd22fd26
da5f2078
ETSI
3GPP TS 55.205 version 6.2.0 Release 6
13
ETSI TS 155 205 V6.2.0 (2006-03)
Test Set 15
Ki
RAND
OP
OPc
MIL3G-RES
SRES#1
SRES#2
MIL3G-CK
MIL3G-IK
Kc
5bd7ecd3
59b75f14
f967f760
76089d3c
7e3f44c7
27202b82
7e3f44c7
d42b2d61
0b3f8d02
b7f92e42
d3127a41
251c7503
38b920a9
0ff3efdc
591f6f45
d12539be
1d0bcbac
cd25e10c
6e36721d
d4e7cf71
1c2c04c7
08b49924
4fceb747
5e49a03a
4fe6bfaf
6a36fec5
c275a5ae
aa982b8f
f97af892
82e319c2
Test Set 16
Ki
RAND
OP
OPc
MIL3G-RES
SRES#1
SRES#2
MIL3G-CK
MIL3G-IK
Kc
6cd1c6ce
f69b78f3
078bfca9
a219dc37
70f6bdb9
ddd7efe6
70f6bdb9
6edaf99e
d61c853c
88d9de10
b1e01e14
00a0568b
564659ec
f1dc7d66
ad21525f
f1b82316
ce9f0cb9
d8851e84
738b5843
a90b7f3d
3c4be4c9
e6c59b48
c799f206
5bd9f85d
280dd9c4
a22004c5
5f36d91c
6f297bae
1272fb4b
c386de17
Test Set 17
Ki
RAND
OP
OPc
MIL3G-RES
SRES#1
SRES#2
MIL3G-CK
MIL3G-IK
Kc
b73a90cb
b120f1c1
b672047e
df0c6786
479dd25c
67e4ff3f
479dd25c
66195dbe
66bec707
a819e577
cf3afb62
a0102a2f
003bb952
8fa25f74
20792d63
2dba83c5
507dd543
dca6cb8a
8b7044c6
8a8415df
de68281f
f0e5b779
e7c245b8
d0313274
eb2afc47
a8d6175b
c5ca7766
6d7408a8
615fa25e
f2927b36
Test Set 18
Ki
RAND
OP
OPc
MIL3G-RES
SRES#1
SRES#2
MIL3G-CK
MIL3G-IK
Kc
51222502
81e92b6c
c9e87632
981d464c
28d7b0f2
8a3b8d17
28d7b0f2
5349fbe0
9744871a
9a8d0e88
14c33e72
0ee0e12e
86b5b9ff
7c52eb6e
a2ec3de5
3a5dd523
bceba8d9
bdf56e12
50362349
fc145fc0
2a99dfa5
97d0887b
84ad0bcf
98649f94
d32bf9bb
3ff0887a
8f5d2e97
d1dd5ce5
3a81c00f
4e3e2e5a
ETSI
3GPP TS 55.205 version 6.2.0 Release 6
Test Set 19
Ki
RAND
OP
OPc
MIL3G-RES
SRES#1
SRES#2
MIL3G-CK
MIL3G-IK
Kc
90dca4ed
9fddc720
3ffcfe5b
cb9cccc4
a95100e2
df58522f
a95100e2
b5f2da03
b4721368
ed29b2f1
14
ETSI TS 155 205 V6.2.0 (2006-03)
a45b53cf
92c6ad03
7b111158
b9258e6d
760952cd
0f12d7c9
6b6e4647
9920d352
ca476037
c3bc6a89
89315b78
8e84e655
9fb82581
883b69f9
bc16ea67
c27f9f34
6bf52e02
875c5598
9ed9ac45
688bb0ef

View File

@ -7,3 +7,10 @@ cat $abs_srcdir/auc/auc_3g_test.ok > expout
cat $abs_srcdir/auc/auc_3g_test.err > experr
AT_CHECK([$abs_top_builddir/tests/auc/auc_3g_test], [], [expout], [experr])
AT_CLEANUP
AT_SETUP([auc_ts_55_205_test_sets])
AT_KEYWORDS([auc_ts_55_205_test_sets])
cat $abs_srcdir/auc/auc_ts_55_205_test_sets.ok > expout
cat $abs_srcdir/auc/auc_ts_55_205_test_sets.err > experr
AT_CHECK([$abs_top_builddir/tests/auc/auc_ts_55_205_test_sets], [], [expout], [experr])
AT_CLEANUP