2 * Copyright (C) 2008-2009 Martin Willi
4 * Copyright (C) secunet Security Networks AG
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>.
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
17 * Copyright (C) 2015 Thomas Strangert
18 * Polystar System AB, Sweden
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:
27 * The above copyright notice and this permission notice shall be included in
28 * all copies or substantial portions of the Software.
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
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"
46 typedef struct private_eap_aka_3gpp_t private_eap_aka_3gpp_t
;
49 * Private data of an eap_aka_3gpp_t object.
51 struct private_eap_aka_3gpp_t
{
54 * Public eap_aka_3gpp_plugin_t interface.
56 eap_aka_3gpp_plugin_t
public;
61 eap_aka_3gpp_card_t
*card
;
66 eap_aka_3gpp_provider_t
*provider
;
71 eap_aka_3gpp_functions_t
*functions
;
74 METHOD(plugin_t
, get_name
, char*,
75 private_eap_aka_3gpp_t
*this)
77 return "eap-aka-3gpp";
81 * Try to instantiate ea_aka_3gpp functions and card/provider backends
83 static bool register_functions(private_eap_aka_3gpp_t
*this,
84 plugin_feature_t
*feature
, bool reg
, void *data
)
88 this->functions
= eap_aka_3gpp_functions_create();
93 this->card
= eap_aka_3gpp_card_create(this->functions
);
94 this->provider
= eap_aka_3gpp_provider_create(this->functions
);
97 this->card
->destroy(this->card
);
98 this->provider
->destroy(this->provider
);
99 this->functions
->destroy(this->functions
);
101 this->provider
= NULL
;
102 this->functions
= NULL
;
107 * Callback providing our card to register
109 static simaka_card_t
* get_card(private_eap_aka_3gpp_t
*this)
111 return &this->card
->card
;
115 * Callback providing our provider to register
117 static simaka_provider_t
* get_provider(private_eap_aka_3gpp_t
*this)
119 return &this->provider
->provider
;
122 METHOD(plugin_t
, get_features
, int,
123 private_eap_aka_3gpp_t
*this, plugin_feature_t
*features
[])
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"),
142 METHOD(plugin_t
, destroy
, void, private_eap_aka_3gpp_t
*this)
150 plugin_t
*eap_aka_3gpp_plugin_create()
152 private_eap_aka_3gpp_t
*this;
157 .get_name
= _get_name
,
158 .get_features
= _get_features
,
164 return &this->public.plugin
;