65020aa644f8462dc1ccbeb6936794642c0bba64
[strongswan.git] / src / charon / plugins / eap_sim / eap_sim.h
1 /*
2 * Copyright (C) 2007-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 eap_sim_i eap_sim
18 * @{ @ingroup eap_sim
19 */
20
21 #ifndef EAP_SIM_H_
22 #define EAP_SIM_H_
23
24 typedef struct eap_sim_t eap_sim_t;
25
26 #include <sa/authenticators/eap/eap_method.h>
27
28 /** the library containing with the triplet functions */
29 #ifndef SIM_READER_LIB
30 #error SIM_READER_LIB not specified, use --with-sim-reader option
31 #endif /* SIM_READER_LIB */
32
33 /**
34 * Cardreaders SIM function.
35 *
36 * @param rand RAND to run algo with
37 * @param rand_length length of value in rand
38 * @param sres buffer to get SRES
39 * @param sres_length size of buffer in sres, returns bytes written to SRES
40 * @param kc buffer to get Kc
41 * @param kc_length size of buffer in Kc, returns bytes written to Kc
42 * @return zero on success
43 */
44 typedef int (*sim_algo_t)(const unsigned char *rand, int rand_length,
45 unsigned char *sres, int *sres_length,
46 unsigned char *kc, int *kc_length);
47
48 #ifndef SIM_READER_ALG
49 /** the SIM_READER_LIB's algorithm, uses sim_algo_t signature */
50 #define SIM_READER_ALG "sim_run_alg"
51 #endif /* SIM_READER_ALG */
52
53 /**
54 * Function to get a SIM triplet.
55 *
56 * @param identity identity (imsi) to get a triplet for
57 * @param rand buffer to get RAND
58 * @param rand_length size of buffer in rand, returns bytes written to RAND
59 * @param sres buffer to get SRES
60 * @param sres_length size of buffer in sres, returns bytes written to SRES
61 * @param kc buffer to get Kc
62 * @param kc_length size of buffer in Kc, returns bytes written to Kc
63 * @return zero on success
64 */
65 typedef int (*sim_get_triplet_t)(char *identity,
66 unsigned char *rand, int *rand_length,
67 unsigned char *sres, int *sres_length,
68 unsigned char *kc, int *kc_length);
69
70 #ifndef SIM_READER_GET_TRIPLET
71 /** the SIM_READER_LIB's get-triplet function, uses sim_get_triplet_t signature */
72 #define SIM_READER_GET_TRIPLET "sim_get_triplet"
73 #endif /* SIM_READER_GET_TRIPLET */
74
75 /**
76 * Implementation of the eap_method_t interface using EAP-SIM.
77 *
78 * This EAP-SIM client implementation uses another pluggable library to
79 * access the SIM card/triplet provider. This module is specified using the
80 * SIM_READER_LIB definition. It has to privde a sim_run_alg() function to
81 * calculate a triplet (client), and/or a sim_get_triplet() function to get
82 * a triplet (server). These functions are named to the SIM_READER_ALG and
83 * the SIM_READER_GET_TRIPLET definitions.
84 */
85 struct eap_sim_t {
86
87 /**
88 * Implemented eap_method_t interface.
89 */
90 eap_method_t eap_method_interface;
91 };
92
93 /**
94 * Creates the EAP method EAP-SIM acting as server.
95 *
96 * @param server ID of the EAP server
97 * @param peer ID of the EAP client
98 * @return eap_sim_t object
99 */
100 eap_sim_t *eap_sim_create_server(identification_t *server, identification_t *peer);
101
102 /**
103 * Creates the EAP method EAP-SIM acting as peer.
104 *
105 * @param server ID of the EAP server
106 * @param peer ID of the EAP client
107 * @return eap_sim_t object
108 */
109 eap_sim_t *eap_sim_create_peer(identification_t *server, identification_t *peer);
110
111 #endif /* EAP_SIM_H_ @}*/