aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auc/gen_ts_55_205_test_sets/func_template.c
blob: f8b4097096c623e3f9d44a731bb2c6334e40720d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/* 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_data2 aud2g;
	struct osmo_sub_auth_data2 aud3g;
	struct osmo_auth_vector vec;
	int rc;

	comment_start();

	aud2g = (struct osmo_sub_auth_data2){{ 0 }};

	aud3g = (struct osmo_sub_auth_data2){{
		.type = OSMO_AUTH_TYPE_UMTS,
		.algo = OSMO_AUTH_ALG_MILENAGE,
		.u.umts.k_len = 16,
		.u.umts.opc_len = 16,
		.u.umts.sqn = 31,
	}};

	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}} }};
	vec.res_len = 8;
	VERBOSE_ASSERT(aud3g.u.umts.sqn, == 31, "%"PRIu64);
	rc = auc_compute_vectors(&vec, 1, &aud2g, &aud3g, NULL, NULL);
	VERBOSE_ASSERT(rc, == 1, "%d");
	VERBOSE_ASSERT(aud3g.u.umts.sqn, == 32, "%"PRIu64);

	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();
}}