blob: b0900af26aa5e04f01a4fc553e079c952ef3c94f [file] [log] [blame]
Kevin Redonbe355cd2013-11-02 18:11:01 +01001/* registers COMP128 version 2 and 3 A3/A8 algorithms for the
2 * GSM/GPRS/3G authentication core infrastructure
3 *
4 */
5
6/* (C) 2010-2011 by Harald Welte <laforge@gnumonks.org>
7 * (C) 2013 by Kévin Redon <kevredon@mail.tsaitgaist.info>
8 *
9 * All Rights Reserved
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License along
22 * with this program; if not, write to the Free Software Foundation, Inc.,
23 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 *
25 */
26
27#include <osmocom/crypt/auth.h>
28#include <osmocom/gsm/comp128v23.h>
29
Harald Welte96e2a002017-06-12 21:44:18 +020030/*! \addtogroup auth
31 * @{
32 */
33
Kevin Redonbe355cd2013-11-02 18:11:01 +010034static int c128v2_gen_vec(struct osmo_auth_vector *vec,
35 struct osmo_sub_auth_data *aud,
36 const uint8_t *_rand)
37{
Max4f0abc02013-12-02 11:30:32 +010038 comp128v2(aud->u.gsm.ki, _rand, vec->sres, vec->kc);
Kevin Redonbe355cd2013-11-02 18:11:01 +010039 vec->auth_types = OSMO_AUTH_TYPE_GSM;
40
41 return 0;
42}
43
44static struct osmo_auth_impl c128v2_alg = {
45 .algo = OSMO_AUTH_ALG_COMP128v2,
46 .name = "COMP128v2 (libosmogsm built-in)",
47 .priority = 1000,
48 .gen_vec = &c128v2_gen_vec,
49};
50
51static int c128v3_gen_vec(struct osmo_auth_vector *vec,
52 struct osmo_sub_auth_data *aud,
53 const uint8_t *_rand)
54{
Max4f0abc02013-12-02 11:30:32 +010055 comp128v3(aud->u.gsm.ki, _rand, vec->sres, vec->kc);
Kevin Redonbe355cd2013-11-02 18:11:01 +010056 vec->auth_types = OSMO_AUTH_TYPE_GSM;
57
58 return 0;
59}
60
61static struct osmo_auth_impl c128v3_alg = {
62 .algo = OSMO_AUTH_ALG_COMP128v3,
63 .name = "COMP128v3 (libosmogsm built-in)",
64 .priority = 1000,
65 .gen_vec = &c128v3_gen_vec,
66};
67
68static __attribute__((constructor)) void on_dso_load_c128(void)
69{
70 osmo_auth_register(&c128v2_alg);
71 osmo_auth_register(&c128v3_alg);
72}
Harald Welte96e2a002017-06-12 21:44:18 +020073
74/*! @} */