Harald Welte | d82e0eb | 2011-12-06 21:53:42 +0100 | [diff] [blame] | 1 | |
| 2 | /* GSM/GPRS/3G authentication core infrastructure */ |
| 3 | |
| 4 | /* (C) 2010-2011 by Harald Welte <laforge@gnumonks.org> |
| 5 | * |
| 6 | * All Rights Reserved |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify |
| 9 | * it under the terms of the GNU General Public License as published by |
| 10 | * the Free Software Foundation; either version 2 of the License, or |
| 11 | * (at your option) any later version. |
| 12 | * |
| 13 | * This program is distributed in the hope that it will be useful, |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | * GNU General Public License for more details. |
| 17 | * |
| 18 | * You should have received a copy of the GNU General Public License along |
| 19 | * with this program; if not, write to the Free Software Foundation, Inc., |
| 20 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 21 | * |
| 22 | */ |
| 23 | |
| 24 | #include <osmocom/crypt/auth.h> |
| 25 | #include <osmocom/gsm/comp128.h> |
| 26 | |
| 27 | static int c128v1_gen_vec(struct osmo_auth_vector *vec, |
| 28 | struct osmo_sub_auth_data *aud, |
| 29 | const uint8_t *_rand) |
| 30 | { |
| 31 | comp128(aud->gsm.ki, _rand, vec->sres, vec->kc); |
| 32 | vec->auth_types = OSMO_AUTH_TYPE_GSM; |
| 33 | |
| 34 | return 0; |
| 35 | } |
| 36 | |
| 37 | static struct osmo_auth_impl c128v1_alg = { |
| 38 | .algo = OSMO_AUTH_ALG_COMP128v1, |
| 39 | .name = "COMP128v1 (libosmogsm built-in)", |
| 40 | .priority = 1000, |
| 41 | .gen_vec = &c128v1_gen_vec, |
| 42 | }; |
| 43 | |
| 44 | static __attribute__((constructor)) void on_dso_load_c128(void) |
| 45 | { |
| 46 | osmo_auth_register(&c128v1_alg); |
| 47 | } |