blob: 697858a0927e04fb256e33e2cd63f6256f5d6a18 [file] [log] [blame]
Neels Hofmeyr17518fe2017-06-20 04:35:06 +02001/*! \file auth_comp128v23.c
2 * registers COMP128 version 2 and 3 A3/A8 algorithms for the
3 * GSM/GPRS/3G authentication core infrastructure. */
4/*
5 * (C) 2010-2011 by Harald Welte <laforge@gnumonks.org>
Kevin Redonbe355cd2013-11-02 18:11:01 +01006 * (C) 2013 by Kévin Redon <kevredon@mail.tsaitgaist.info>
7 *
8 * All Rights Reserved
9 *
Harald Weltee08da972017-11-13 01:00:26 +090010 * SPDX-License-Identifier: GPL-2.0+
11 *
Kevin Redonbe355cd2013-11-02 18:11:01 +010012 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
16 *
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
Kevin Redonbe355cd2013-11-02 18:11:01 +010022 */
23
24#include <osmocom/crypt/auth.h>
25#include <osmocom/gsm/comp128v23.h>
26
Harald Welte96e2a002017-06-12 21:44:18 +020027/*! \addtogroup auth
28 * @{
29 */
30
Kevin Redonbe355cd2013-11-02 18:11:01 +010031static int c128v2_gen_vec(struct osmo_auth_vector *vec,
Harald Welte08450c92023-05-30 10:55:37 +020032 struct osmo_sub_auth_data2 *aud,
Kevin Redonbe355cd2013-11-02 18:11:01 +010033 const uint8_t *_rand)
34{
Max4f0abc02013-12-02 11:30:32 +010035 comp128v2(aud->u.gsm.ki, _rand, vec->sres, vec->kc);
Kevin Redonbe355cd2013-11-02 18:11:01 +010036 vec->auth_types = OSMO_AUTH_TYPE_GSM;
37
38 return 0;
39}
40
41static struct osmo_auth_impl c128v2_alg = {
42 .algo = OSMO_AUTH_ALG_COMP128v2,
43 .name = "COMP128v2 (libosmogsm built-in)",
44 .priority = 1000,
45 .gen_vec = &c128v2_gen_vec,
46};
47
48static int c128v3_gen_vec(struct osmo_auth_vector *vec,
Harald Welte08450c92023-05-30 10:55:37 +020049 struct osmo_sub_auth_data2 *aud,
Kevin Redonbe355cd2013-11-02 18:11:01 +010050 const uint8_t *_rand)
51{
Max4f0abc02013-12-02 11:30:32 +010052 comp128v3(aud->u.gsm.ki, _rand, vec->sres, vec->kc);
Kevin Redonbe355cd2013-11-02 18:11:01 +010053 vec->auth_types = OSMO_AUTH_TYPE_GSM;
54
55 return 0;
56}
57
58static struct osmo_auth_impl c128v3_alg = {
59 .algo = OSMO_AUTH_ALG_COMP128v3,
60 .name = "COMP128v3 (libosmogsm built-in)",
61 .priority = 1000,
62 .gen_vec = &c128v3_gen_vec,
63};
64
65static __attribute__((constructor)) void on_dso_load_c128(void)
66{
67 osmo_auth_register(&c128v2_alg);
68 osmo_auth_register(&c128v3_alg);
69}
Harald Welte96e2a002017-06-12 21:44:18 +020070
71/*! @} */