updated Doxyfile
[strongswan.git] / src / charon / sa / authenticators / eap / sim_manager.h
1 /*
2 * Copyright (C) 2008 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 /**
17 * @defgroup sim_manager sim_manager
18 * @{ @ingroup eap
19 */
20
21 #ifndef SIM_MANAGER_H_
22 #define SIM_MANAGER_H_
23
24 #include <utils/identification.h>
25 #include <utils/enumerator.h>
26
27 typedef struct sim_manager_t sim_manager_t;
28 typedef struct sim_card_t sim_card_t;
29 typedef struct sim_provider_t sim_provider_t;
30
31 /**
32 * Interface for a SIM card (used as EAP client).
33 */
34 struct sim_card_t {
35
36 /**
37 * Get the identity of a SIM card.
38 *
39 * The returned identity owned by the sim_card and not destroyed outside.
40 * The SIM card may return ID_ANY if it does not support/use an IMSI.
41 *
42 * @return identity of type ID_EAP/ID_ANY
43 */
44 identification_t* (*get_imsi)(sim_card_t *this);
45
46 /**
47 * Calculate SRES/KC from a RAND.
48 *
49 * @param rand RAND input buffer, fixed size 16 bytes
50 * @param sres SRES output buffer, fixed size 4 byte
51 * @param kc KC output buffer, fixed size 8 bytes
52 * @return TRUE if SRES/KC calculated, FALSE on error
53 */
54 bool (*get_triplet)(sim_card_t *this,
55 char rand[16], char sres[4], char kc[8]);
56 };
57
58 /**
59 * Interface for a triplet provider (used as EAP server).
60 */
61 struct sim_provider_t {
62
63 /**
64 * Get a single triplet to authenticate a EAP client.
65 *
66 * @param imsi client identity of type ID_EAP
67 * @param rand RAND output buffer, fixed size 16 bytes
68 * @param sres SRES output buffer, fixed size 4 byte
69 * @param kc KC output buffer, fixed size 8 bytes
70 * @return TRUE if triplet received, FALSE otherwise
71 */
72 bool (*get_triplet)(sim_provider_t *this, identification_t *imsi,
73 char rand[16], char sres[4], char kc[8]);
74 };
75
76 /**
77 * The EAP-SIM manager handles multiple SIM cards and providers.
78 */
79 struct sim_manager_t {
80
81 /**
82 * Register a SIM card (client) at the manager.
83 *
84 * @param card sim card to register
85 */
86 void (*add_card)(sim_manager_t *this, sim_card_t *card);
87
88 /**
89 * Unregister a previously registered card from the manager.
90 *
91 * @param card sim card to unregister
92 */
93 void (*remove_card)(sim_manager_t *this, sim_card_t *card);
94
95 /**
96 * Create an enumerator over all registered cards.
97 *
98 * @return enumerator over sim_card_t's
99 */
100 enumerator_t* (*create_card_enumerator)(sim_manager_t *this);
101
102 /**
103 * Register a triplet provider (server) at the manager.
104 *
105 * @param card sim card to register
106 */
107 void (*add_provider)(sim_manager_t *this, sim_provider_t *provider);
108
109 /**
110 * Unregister a previously registered provider from the manager.
111 *
112 * @param card sim card to unregister
113 */
114 void (*remove_provider)(sim_manager_t *this, sim_provider_t *provider);
115
116 /**
117 * Create an enumerator over all registered provider.
118 *
119 * @return enumerator over sim_provider_t's
120 */
121 enumerator_t* (*create_provider_enumerator)(sim_manager_t *this);
122
123 /**
124 * Destroy a manager instance.
125 */
126 void (*destroy)(sim_manager_t *this);
127 };
128
129 /**
130 * Create an SIM manager to handle multiple SIM cards/providers.
131 *
132 * @return sim_t object
133 */
134 sim_manager_t *sim_manager_create();
135
136 #endif /** SIM_MANAGER_H_ @}*/