blob: 168f8865d8498a6d5663378239ff38c75cc1d17a [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
30static int c128v2_gen_vec(struct osmo_auth_vector *vec,
31 struct osmo_sub_auth_data *aud,
32 const uint8_t *_rand)
33{
Max4f0abc02013-12-02 11:30:32 +010034 comp128v2(aud->u.gsm.ki, _rand, vec->sres, vec->kc);
Kevin Redonbe355cd2013-11-02 18:11:01 +010035 vec->auth_types = OSMO_AUTH_TYPE_GSM;
36
37 return 0;
38}
39
40static struct osmo_auth_impl c128v2_alg = {
41 .algo = OSMO_AUTH_ALG_COMP128v2,
42 .name = "COMP128v2 (libosmogsm built-in)",
43 .priority = 1000,
44 .gen_vec = &c128v2_gen_vec,
45};
46
47static int c128v3_gen_vec(struct osmo_auth_vector *vec,
48 struct osmo_sub_auth_data *aud,
49 const uint8_t *_rand)
50{
Max4f0abc02013-12-02 11:30:32 +010051 comp128v3(aud->u.gsm.ki, _rand, vec->sres, vec->kc);
Kevin Redonbe355cd2013-11-02 18:11:01 +010052 vec->auth_types = OSMO_AUTH_TYPE_GSM;
53
54 return 0;
55}
56
57static struct osmo_auth_impl c128v3_alg = {
58 .algo = OSMO_AUTH_ALG_COMP128v3,
59 .name = "COMP128v3 (libosmogsm built-in)",
60 .priority = 1000,
61 .gen_vec = &c128v3_gen_vec,
62};
63
64static __attribute__((constructor)) void on_dso_load_c128(void)
65{
66 osmo_auth_register(&c128v2_alg);
67 osmo_auth_register(&c128v3_alg);
68}