Neels Hofmeyr | 17518fe | 2017-06-20 04:35:06 +0200 | [diff] [blame] | 1 | /*! \file auth_comp128v1.c |
| 2 | * GSM/GPRS/3G authentication core infrastructure */ |
| 3 | /* |
| 4 | * (C) 2010-2011 by Harald Welte <laforge@gnumonks.org> |
Harald Welte | d82e0eb | 2011-12-06 21:53:42 +0100 | [diff] [blame] | 5 | * |
| 6 | * All Rights Reserved |
| 7 | * |
Harald Welte | e08da97 | 2017-11-13 01:00:26 +0900 | [diff] [blame] | 8 | * SPDX-License-Identifier: GPL-2.0+ |
| 9 | * |
Harald Welte | d82e0eb | 2011-12-06 21:53:42 +0100 | [diff] [blame] | 10 | * 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 Welte | d82e0eb | 2011-12-06 21:53:42 +0100 | [diff] [blame] | 20 | */ |
| 21 | |
| 22 | #include <osmocom/crypt/auth.h> |
| 23 | #include <osmocom/gsm/comp128.h> |
| 24 | |
Harald Welte | 96e2a00 | 2017-06-12 21:44:18 +0200 | [diff] [blame] | 25 | /*! \addtogroup auth |
| 26 | * @{ |
| 27 | */ |
| 28 | |
Harald Welte | d82e0eb | 2011-12-06 21:53:42 +0100 | [diff] [blame] | 29 | static int c128v1_gen_vec(struct osmo_auth_vector *vec, |
Harald Welte | 08450c9 | 2023-05-30 10:55:37 +0200 | [diff] [blame] | 30 | struct osmo_sub_auth_data2 *aud, |
Harald Welte | d82e0eb | 2011-12-06 21:53:42 +0100 | [diff] [blame] | 31 | const uint8_t *_rand) |
| 32 | { |
Harald Welte | 5248c47 | 2023-05-30 11:09:17 +0200 | [diff] [blame] | 33 | OSMO_ASSERT(aud->algo == OSMO_AUTH_ALG_COMP128v1); |
Max | 1f9d818 | 2016-04-21 17:12:40 +0200 | [diff] [blame] | 34 | comp128v1(aud->u.gsm.ki, _rand, vec->sres, vec->kc); |
Harald Welte | d82e0eb | 2011-12-06 21:53:42 +0100 | [diff] [blame] | 35 | vec->auth_types = OSMO_AUTH_TYPE_GSM; |
| 36 | |
| 37 | return 0; |
| 38 | } |
| 39 | |
| 40 | static struct osmo_auth_impl c128v1_alg = { |
| 41 | .algo = OSMO_AUTH_ALG_COMP128v1, |
| 42 | .name = "COMP128v1 (libosmogsm built-in)", |
| 43 | .priority = 1000, |
| 44 | .gen_vec = &c128v1_gen_vec, |
| 45 | }; |
| 46 | |
| 47 | static __attribute__((constructor)) void on_dso_load_c128(void) |
| 48 | { |
| 49 | osmo_auth_register(&c128v1_alg); |
| 50 | } |
Harald Welte | 96e2a00 | 2017-06-12 21:44:18 +0200 | [diff] [blame] | 51 | |
| 52 | /*! @} */ |