added EAP-SIM authentication
[strongswan.git] / src / charon / sa / authenticators / eap / eap_sim.h
1 /**
2 * @file eap_sim.h
3 *
4 * @brief Interface of eap_sim_t.
5 *
6 */
7
8 /*
9 * Copyright (C) 2007 Martin Willi
10 * Hochschule fuer Technik Rapperswil
11 *
12 * This program is free software; you can redistribute it and/or modify it
13 * under the terms of the GNU General Public License as published by the
14 * Free Software Foundation; either version 2 of the License, or (at your
15 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
19 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
20 * for more details.
21 */
22
23 #ifndef EAP_SIM_H_
24 #define EAP_SIM_H_
25
26 typedef struct eap_sim_t eap_sim_t;
27 typedef enum sim_subtype_t sim_subtype_t;
28 typedef enum sim_attribute_t sim_attribute_t;
29
30 #include <sa/authenticators/eap/eap_method.h>
31
32 /**
33 * Subtypes of SIM messages
34 */
35 enum sim_subtype_t {
36 SIM_START = 10,
37 SIM_CHALLENGE = 11,
38 SIM_NOTIFICATION = 12,
39 SIM_CLIENT_ERROR = 14,
40 };
41
42 /**
43 * enum names for sim_subtype_t
44 */
45 extern enum_name_t *sim_subtype_names;
46
47 enum sim_attribute_t {
48 /** defines the end of attribute list */
49 AT_END = -1,
50 AT_RAND = 1,
51 AT_AUTN = 2,
52 AT_RES = 3,
53 AT_AUTS = 4,
54 AT_PADDING = 6,
55 AT_NONCE_MT = 7,
56 AT_PERMANENT_ID_REQ = 10,
57 AT_MAC = 11,
58 AT_NOTIFICATION = 12,
59 AT_ANY_ID_REQ = 13,
60 AT_IDENTITY = 14,
61 AT_VERSION_LIST = 15,
62 AT_SELECTED_VERSION = 16,
63 AT_FULLAUTH_ID_REQ = 17,
64 AT_COUNTER = 19,
65 AT_COUNTER_TOO_SMALL = 20,
66 AT_NONCE_S = 21,
67 AT_CLIENT_ERROR_CODE = 22,
68 AT_IV = 129,
69 AT_ENCR_DATA = 130,
70 AT_NEXT_PSEUDONYM = 132,
71 AT_NEXT_REAUTH_ID = 133,
72 AT_CHECKCODE = 134,
73 AT_RESULT_IND = 135,
74 };
75
76 /**
77 * enum names for sim_subtype_t
78 */
79 extern enum_name_t *sim_attribute_names;
80
81 /**
82 * @brief Cardreaders SIM function.
83 *
84 * @param rand RAND to run algo with
85 * @param rand_length length of value in rand
86 * @param sres buffer to get SRES
87 * @param sres_length size of buffer in sres, returns bytes written to SRES
88 * @param kc buffer to get Kc
89 * @param kc_length size of buffer in Kc, returns bytes written to Kc
90 * @return zero on success
91 */
92 typedef int (*sim_algo_t)(const unsigned char *rand, int rand_length,
93 unsigned char *sres, int *sres_length,
94 unsigned char *kc, int *kc_length);
95
96 #ifndef SIM_READER_LIB
97 /** the library containing the cardreader with the SIM function */
98 #define SIM_READER_LIB "/home/martin/strongswan/trunk/src/charon/sa/authenticators/eap/sim_reader/sim_api.so"
99 #endif /* SIM_READER_LIB */
100
101 #ifndef SIM_READER_ALG
102 /** the SIM_READER_LIB's algorithm, uses sim_algo_t signature */
103 #define SIM_READER_ALG "sim_run_alg"
104 #endif /* SIM_READER_ALG */
105
106
107
108 /**
109 * @brief Implementation of the eap_method_t interface using EAP-SIM.
110 *
111 * This EAP-SIM client implementation uses another pluggable library to
112 * access the SIM card. This module is specified using the SIM_READER_LIB
113 * definition. The function to run the algorithm has the sim_algo_t type and
114 * is named as SIM_READER_ALG is defined.
115 *
116 * @b Constructors:
117 * - eap_sim_create()
118 * - eap_client_create() using eap_method EAP_SIM
119 *
120 * @ingroup eap
121 */
122 struct eap_sim_t {
123
124 /**
125 * Implemented eap_method_t interface.
126 */
127 eap_method_t eap_method_interface;
128 };
129
130 /**
131 * @brief Creates the EAP method EAP-SIM.
132 *
133 * @param server ID of the EAP server
134 * @param peer ID of the EAP client
135 * @return eap_sim_t object
136 *
137 * @ingroup eap
138 */
139 eap_sim_t *eap_create(eap_role_t role,
140 identification_t *server, identification_t *peer);
141
142 #endif /* EAP_SIM_H_ */