Removed strayed code fragment
[strongswan.git] / src / charon / plugins / eap_sim_file / eap_sim_file_provider.c
1 /*
2 * Copyright (C) 2008-2009 Martin Willi
3 * Hochschule fuer Technik Rapperswil
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * for more details.
14 */
15
16 #include "eap_sim_file_provider.h"
17
18 #include <daemon.h>
19
20 typedef struct private_eap_sim_file_provider_t private_eap_sim_file_provider_t;
21
22 /**
23 * Private data of an eap_sim_file_provider_t object.
24 */
25 struct private_eap_sim_file_provider_t {
26
27 /**
28 * Public eap_sim_file_provider_t interface.
29 */
30 eap_sim_file_provider_t public;
31
32 /**
33 * source of triplets
34 */
35 eap_sim_file_triplets_t *triplets;
36 };
37
38 /**
39 * Implementation of sim_provider_t.get_triplet
40 */
41 static bool get_triplet(private_eap_sim_file_provider_t *this,
42 identification_t *id, char *rand, char *sres, char *kc)
43 {
44 enumerator_t *enumerator;
45 identification_t *cand;
46 char *c_rand, *c_sres, *c_kc;
47
48 enumerator = this->triplets->create_enumerator(this->triplets);
49 while (enumerator->enumerate(enumerator, &cand, &c_rand, &c_sres, &c_kc))
50 {
51 if (id->matches(id, cand))
52 {
53 memcpy(rand, c_rand, SIM_RAND_LEN);
54 memcpy(sres, c_sres, SIM_SRES_LEN);
55 memcpy(kc, c_kc, SIM_KC_LEN);
56 enumerator->destroy(enumerator);
57 return TRUE;
58 }
59 }
60 enumerator->destroy(enumerator);
61 return FALSE;
62 }
63
64 /**
65 * Implementation of eap_sim_file_provider_t.destroy.
66 */
67 static void destroy(private_eap_sim_file_provider_t *this)
68 {
69 free(this);
70 }
71
72 /**
73 * See header
74 */
75 eap_sim_file_provider_t *eap_sim_file_provider_create(
76 eap_sim_file_triplets_t *triplets)
77 {
78 private_eap_sim_file_provider_t *this = malloc_thing(private_eap_sim_file_provider_t);
79
80 this->public.provider.get_triplet = (bool(*)(sim_provider_t*, identification_t *id, char rand[SIM_RAND_LEN], char sres[SIM_SRES_LEN], char kc[SIM_KC_LEN]))get_triplet;
81 this->public.provider.get_quintuplet = (bool(*)(sim_provider_t*, identification_t *id, char rand[AKA_RAND_LEN], char xres[AKA_RES_MAX], int *xres_len, char ck[AKA_CK_LEN], char ik[AKA_IK_LEN], char autn[AKA_AUTN_LEN]))return_false;
82 this->public.provider.resync = (bool(*)(sim_provider_t*, identification_t *id, char rand[AKA_RAND_LEN], char auts[AKA_AUTS_LEN]))return_false;
83 this->public.provider.is_pseudonym = (identification_t*(*)(sim_provider_t*, identification_t *id))return_null;
84 this->public.provider.gen_pseudonym = (identification_t*(*)(sim_provider_t*, identification_t *id))return_null;
85 this->public.provider.is_reauth = (identification_t*(*)(sim_provider_t*, identification_t *id, char [HASH_SIZE_SHA1], u_int16_t *counter))return_null;
86 this->public.provider.gen_reauth = (identification_t*(*)(sim_provider_t*, identification_t *id, char mk[HASH_SIZE_SHA1]))return_null;
87 this->public.destroy = (void(*)(eap_sim_file_provider_t*))destroy;
88
89 this->triplets = triplets;
90
91 return &this->public;
92 }
93