blob: 1dddef316b3786d752331a0cbc8dc8b8818bd169 [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 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License along
19 * with this program; if not, write to the Free Software Foundation, Inc.,
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 *
22 */
23
24#include <osmocom/crypt/auth.h>
25#include <osmocom/gsm/comp128.h>
26
Harald Welte96e2a002017-06-12 21:44:18 +020027/*! \addtogroup auth
28 * @{
29 */
30
Harald Welted82e0eb2011-12-06 21:53:42 +010031static int c128v1_gen_vec(struct osmo_auth_vector *vec,
32 struct osmo_sub_auth_data *aud,
33 const uint8_t *_rand)
34{
Max1f9d8182016-04-21 17:12:40 +020035 comp128v1(aud->u.gsm.ki, _rand, vec->sres, vec->kc);
Harald Welted82e0eb2011-12-06 21:53:42 +010036 vec->auth_types = OSMO_AUTH_TYPE_GSM;
37
38 return 0;
39}
40
41static struct osmo_auth_impl c128v1_alg = {
42 .algo = OSMO_AUTH_ALG_COMP128v1,
43 .name = "COMP128v1 (libosmogsm built-in)",
44 .priority = 1000,
45 .gen_vec = &c128v1_gen_vec,
46};
47
48static __attribute__((constructor)) void on_dso_load_c128(void)
49{
50 osmo_auth_register(&c128v1_alg);
51}
Harald Welte96e2a002017-06-12 21:44:18 +020052
53/*! @} */