blob: 493ebfd0b3a79e1dd245684337f87dff1a382b01 [file] [log] [blame]
Neels Hofmeyr17518fe2017-06-20 04:35:06 +02001/*! \file auth_comp128v1.c
2 * GSM/GPRS/3G authentication core infrastructure */
3/*
4 * (C) 2010-2011 by Harald Welte <laforge@gnumonks.org>
Harald Welted82e0eb2011-12-06 21:53:42 +01005 *
6 * All Rights Reserved
7 *
Harald Weltee08da972017-11-13 01:00:26 +09008 * SPDX-License-Identifier: GPL-2.0+
9 *
Harald Welted82e0eb2011-12-06 21:53:42 +010010 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License along
21 * with this program; if not, write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 *
24 */
25
26#include <osmocom/crypt/auth.h>
27#include <osmocom/gsm/comp128.h>
28
Harald Welte96e2a002017-06-12 21:44:18 +020029/*! \addtogroup auth
30 * @{
31 */
32
Harald Welted82e0eb2011-12-06 21:53:42 +010033static int c128v1_gen_vec(struct osmo_auth_vector *vec,
34 struct osmo_sub_auth_data *aud,
35 const uint8_t *_rand)
36{
Max1f9d8182016-04-21 17:12:40 +020037 comp128v1(aud->u.gsm.ki, _rand, vec->sres, vec->kc);
Harald Welted82e0eb2011-12-06 21:53:42 +010038 vec->auth_types = OSMO_AUTH_TYPE_GSM;
39
40 return 0;
41}
42
43static struct osmo_auth_impl c128v1_alg = {
44 .algo = OSMO_AUTH_ALG_COMP128v1,
45 .name = "COMP128v1 (libosmogsm built-in)",
46 .priority = 1000,
47 .gen_vec = &c128v1_gen_vec,
48};
49
50static __attribute__((constructor)) void on_dso_load_c128(void)
51{
52 osmo_auth_register(&c128v1_alg);
53}
Harald Welte96e2a002017-06-12 21:44:18 +020054
55/*! @} */