Neels Hofmeyr | 17518fe | 2017-06-20 04:35:06 +0200 | [diff] [blame] | 1 | /*! \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 Redon | be355cd | 2013-11-02 18:11:01 +0100 | [diff] [blame] | 6 | * (C) 2013 by Kévin Redon <kevredon@mail.tsaitgaist.info> |
| 7 | * |
| 8 | * All Rights Reserved |
| 9 | * |
Harald Welte | e08da97 | 2017-11-13 01:00:26 +0900 | [diff] [blame] | 10 | * SPDX-License-Identifier: GPL-2.0+ |
| 11 | * |
Kevin Redon | be355cd | 2013-11-02 18:11:01 +0100 | [diff] [blame] | 12 | * 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 | * |
| 22 | * You should have received a copy of the GNU General Public License along |
| 23 | * with this program; if not, write to the Free Software Foundation, Inc., |
| 24 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 25 | * |
| 26 | */ |
| 27 | |
| 28 | #include <osmocom/crypt/auth.h> |
| 29 | #include <osmocom/gsm/comp128v23.h> |
| 30 | |
Harald Welte | 96e2a00 | 2017-06-12 21:44:18 +0200 | [diff] [blame] | 31 | /*! \addtogroup auth |
| 32 | * @{ |
| 33 | */ |
| 34 | |
Kevin Redon | be355cd | 2013-11-02 18:11:01 +0100 | [diff] [blame] | 35 | static int c128v2_gen_vec(struct osmo_auth_vector *vec, |
| 36 | struct osmo_sub_auth_data *aud, |
| 37 | const uint8_t *_rand) |
| 38 | { |
Max | 4f0abc0 | 2013-12-02 11:30:32 +0100 | [diff] [blame] | 39 | comp128v2(aud->u.gsm.ki, _rand, vec->sres, vec->kc); |
Kevin Redon | be355cd | 2013-11-02 18:11:01 +0100 | [diff] [blame] | 40 | vec->auth_types = OSMO_AUTH_TYPE_GSM; |
| 41 | |
| 42 | return 0; |
| 43 | } |
| 44 | |
| 45 | static struct osmo_auth_impl c128v2_alg = { |
| 46 | .algo = OSMO_AUTH_ALG_COMP128v2, |
| 47 | .name = "COMP128v2 (libosmogsm built-in)", |
| 48 | .priority = 1000, |
| 49 | .gen_vec = &c128v2_gen_vec, |
| 50 | }; |
| 51 | |
| 52 | static int c128v3_gen_vec(struct osmo_auth_vector *vec, |
| 53 | struct osmo_sub_auth_data *aud, |
| 54 | const uint8_t *_rand) |
| 55 | { |
Max | 4f0abc0 | 2013-12-02 11:30:32 +0100 | [diff] [blame] | 56 | comp128v3(aud->u.gsm.ki, _rand, vec->sres, vec->kc); |
Kevin Redon | be355cd | 2013-11-02 18:11:01 +0100 | [diff] [blame] | 57 | vec->auth_types = OSMO_AUTH_TYPE_GSM; |
| 58 | |
| 59 | return 0; |
| 60 | } |
| 61 | |
| 62 | static struct osmo_auth_impl c128v3_alg = { |
| 63 | .algo = OSMO_AUTH_ALG_COMP128v3, |
| 64 | .name = "COMP128v3 (libosmogsm built-in)", |
| 65 | .priority = 1000, |
| 66 | .gen_vec = &c128v3_gen_vec, |
| 67 | }; |
| 68 | |
| 69 | static __attribute__((constructor)) void on_dso_load_c128(void) |
| 70 | { |
| 71 | osmo_auth_register(&c128v2_alg); |
| 72 | osmo_auth_register(&c128v3_alg); |
| 73 | } |
Harald Welte | 96e2a00 | 2017-06-12 21:44:18 +0200 | [diff] [blame] | 74 | |
| 75 | /*! @} */ |