]> git.ipfire.org Git - thirdparty/strongswan.git/blob - src/libcharon/plugins/eap_aka_3gpp/eap_aka_3gpp_plugin.c
Update copyright headers after acquisition by secunet
[thirdparty/strongswan.git] / src / libcharon / plugins / eap_aka_3gpp / eap_aka_3gpp_plugin.c
1 /*
2 * Copyright (C) 2008-2009 Martin Willi
3 *
4 * Copyright (C) secunet Security Networks AG
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2 of the License, or (at your
9 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * for more details.
15 */
16 /*
17 * Copyright (C) 2015 Thomas Strangert
18 * Polystar System AB, Sweden
19 *
20 * Permission is hereby granted, free of charge, to any person obtaining a copy
21 * of this software and associated documentation files (the "Software"), to deal
22 * in the Software without restriction, including without limitation the rights
23 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
24 * copies of the Software, and to permit persons to whom the Software is
25 * furnished to do so, subject to the following conditions:
26 *
27 * The above copyright notice and this permission notice shall be included in
28 * all copies or substantial portions of the Software.
29 *
30 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
31 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
32 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
33 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
34 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
35 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
36 * THE SOFTWARE.
37 */
38
39 #include "eap_aka_3gpp_plugin.h"
40 #include "eap_aka_3gpp_card.h"
41 #include "eap_aka_3gpp_provider.h"
42 #include "eap_aka_3gpp_functions.h"
43
44 #include <daemon.h>
45
46 typedef struct private_eap_aka_3gpp_t private_eap_aka_3gpp_t;
47
48 /**
49 * Private data of an eap_aka_3gpp_t object.
50 */
51 struct private_eap_aka_3gpp_t {
52
53 /**
54 * Public eap_aka_3gpp_plugin_t interface.
55 */
56 eap_aka_3gpp_plugin_t public;
57
58 /**
59 * USIM/EAP-AKA card
60 */
61 eap_aka_3gpp_card_t *card;
62
63 /**
64 * EAP-AKA provider
65 */
66 eap_aka_3gpp_provider_t *provider;
67
68 /**
69 * AKA functions
70 */
71 eap_aka_3gpp_functions_t *functions;
72 };
73
74 METHOD(plugin_t, get_name, char*,
75 private_eap_aka_3gpp_t *this)
76 {
77 return "eap-aka-3gpp";
78 }
79
80 /**
81 * Try to instantiate ea_aka_3gpp functions and card/provider backends
82 */
83 static bool register_functions(private_eap_aka_3gpp_t *this,
84 plugin_feature_t *feature, bool reg, void *data)
85 {
86 if (reg)
87 {
88 this->functions = eap_aka_3gpp_functions_create();
89 if (!this->functions)
90 {
91 return FALSE;
92 }
93 this->card = eap_aka_3gpp_card_create(this->functions);
94 this->provider = eap_aka_3gpp_provider_create(this->functions);
95 return TRUE;
96 }
97 this->card->destroy(this->card);
98 this->provider->destroy(this->provider);
99 this->functions->destroy(this->functions);
100 this->card = NULL;
101 this->provider = NULL;
102 this->functions = NULL;
103 return TRUE;
104 }
105
106 /**
107 * Callback providing our card to register
108 */
109 static simaka_card_t* get_card(private_eap_aka_3gpp_t *this)
110 {
111 return &this->card->card;
112 }
113
114 /**
115 * Callback providing our provider to register
116 */
117 static simaka_provider_t* get_provider(private_eap_aka_3gpp_t *this)
118 {
119 return &this->provider->provider;
120 }
121
122 METHOD(plugin_t, get_features, int,
123 private_eap_aka_3gpp_t *this, plugin_feature_t *features[])
124 {
125 static plugin_feature_t f[] = {
126 PLUGIN_CALLBACK((void*)register_functions, NULL),
127 PLUGIN_PROVIDE(CUSTOM, "eap-aka-3gpp-functions"),
128 PLUGIN_DEPENDS(CRYPTER, ENCR_AES_CBC, 16),
129 PLUGIN_CALLBACK(simaka_manager_register, get_card),
130 PLUGIN_PROVIDE(CUSTOM, "aka-card"),
131 PLUGIN_DEPENDS(CUSTOM, "aka-manager"),
132 PLUGIN_DEPENDS(CUSTOM, "eap-aka-3gpp-functions"),
133 PLUGIN_CALLBACK(simaka_manager_register, get_provider),
134 PLUGIN_PROVIDE(CUSTOM, "aka-provider"),
135 PLUGIN_DEPENDS(CUSTOM, "aka-manager"),
136 PLUGIN_DEPENDS(CUSTOM, "eap-aka-3gpp-functions"),
137 };
138 *features = f;
139 return countof(f);
140 }
141
142 METHOD(plugin_t, destroy, void, private_eap_aka_3gpp_t *this)
143 {
144 free(this);
145 }
146
147 /**
148 * See header
149 */
150 plugin_t *eap_aka_3gpp_plugin_create()
151 {
152 private_eap_aka_3gpp_t *this;
153
154 INIT(this,
155 .public = {
156 .plugin = {
157 .get_name = _get_name,
158 .get_features = _get_features,
159 .destroy = _destroy,
160 },
161 },
162 );
163
164 return &this->public.plugin;
165 }