blob: a314dc242585983dcb1aadbe8911c10f4c689724 [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 *
Harald Welted82e0eb2011-12-06 21:53:42 +010020 */
21
22#include <osmocom/crypt/auth.h>
23#include <osmocom/gsm/comp128.h>
24
Harald Welte96e2a002017-06-12 21:44:18 +020025/*! \addtogroup auth
26 * @{
27 */
28
Harald Welted82e0eb2011-12-06 21:53:42 +010029static int c128v1_gen_vec(struct osmo_auth_vector *vec,
Harald Welte08450c92023-05-30 10:55:37 +020030 struct osmo_sub_auth_data2 *aud,
Harald Welted82e0eb2011-12-06 21:53:42 +010031 const uint8_t *_rand)
32{
Max1f9d8182016-04-21 17:12:40 +020033 comp128v1(aud->u.gsm.ki, _rand, vec->sres, vec->kc);
Harald Welted82e0eb2011-12-06 21:53:42 +010034 vec->auth_types = OSMO_AUTH_TYPE_GSM;
35
36 return 0;
37}
38
39static struct osmo_auth_impl c128v1_alg = {
40 .algo = OSMO_AUTH_ALG_COMP128v1,
41 .name = "COMP128v1 (libosmogsm built-in)",
42 .priority = 1000,
43 .gen_vec = &c128v1_gen_vec,
44};
45
46static __attribute__((constructor)) void on_dso_load_c128(void)
47{
48 osmo_auth_register(&c128v1_alg);
49}
Harald Welte96e2a002017-06-12 21:44:18 +020050
51/*! @} */