Added a stub for the EAP-AKA backend implementing the 3GPP2 functions in software
[strongswan.git] / src / charon / plugins / eap_aka_3gpp2 / eap_aka_3gpp2_card.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_aka_3gpp2_card.h"
17
18 #include <daemon.h>
19
20 typedef struct private_eap_aka_3gpp2_card_t private_eap_aka_3gpp2_card_t;
21
22 /**
23 * Private data of an eap_aka_3gpp2_card_t object.
24 */
25 struct private_eap_aka_3gpp2_card_t {
26
27 /**
28 * Public eap_aka_3gpp2_card_t interface.
29 */
30 eap_aka_3gpp2_card_t public;
31
32 /**
33 * IMSI, is ID_ANY for this software implementation
34 */
35 identification_t *imsi;
36
37 /**
38 * AKA functions
39 */
40 eap_aka_3gpp2_functions_t *f;
41 };
42
43 /**
44 * Implementation of usim_card_t.get_imsi
45 */
46 static identification_t* get_imsi(private_eap_aka_3gpp2_card_t *this)
47 {
48 return this->imsi;
49 }
50
51 /**
52 * Implementation of usim_card_t.get_quintuplet
53 */
54 static status_t get_quintuplet(private_eap_aka_3gpp2_card_t *this,
55 char rand[16], char autn[16],
56 char ck[16], char ik[16], char res[16])
57 {
58 return FAILED;
59 }
60
61 /**
62 * Implementation of usim_card_t.resync
63 */
64 static bool resync(private_eap_aka_3gpp2_card_t *this,
65 char rand[16], char auts[16])
66 {
67 return FALSE;
68 }
69
70 /**
71 * Implementation of eap_aka_3gpp2_card_t.destroy.
72 */
73 static void destroy(private_eap_aka_3gpp2_card_t *this)
74 {
75 this->imsi->destroy(this->imsi);
76 free(this);
77 }
78
79 /**
80 * See header
81 */
82 eap_aka_3gpp2_card_t *eap_aka_3gpp2_card_create(eap_aka_3gpp2_functions_t *f)
83 {
84 private_eap_aka_3gpp2_card_t *this = malloc_thing(private_eap_aka_3gpp2_card_t);
85
86 this->public.card.get_imsi = (identification_t*(*)(usim_card_t*))get_imsi;
87 this->public.card.get_quintuplet = (status_t(*)(usim_card_t*, char rand[16], char autn[16], char ck[16], char ik[16], char res[16]))get_quintuplet;
88 this->public.card.resync = (bool(*)(usim_card_t*, char rand[16], char auts[16]))resync;
89 this->public.destroy = (void(*)(eap_aka_3gpp2_card_t*))destroy;
90
91 /* this software USIM can act with all identities */
92 this->imsi = identification_create_from_encoding(ID_ANY, chunk_empty);
93 this->f = f;
94
95 return &this->public;
96 }
97