2 * Copyright (C) 2007-2008 Martin Willi
3 * Hochschule fuer Technik Rapperswil
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>.
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
17 * @defgroup eap_sim_i eap_sim
24 typedef struct eap_sim_t eap_sim_t
;
26 #include <sa/authenticators/eap/eap_method.h>
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 */
34 * Cardreaders SIM function.
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
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
);
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 */
54 * Function to get a SIM triplet.
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
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
);
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 */
76 * Implementation of the eap_method_t interface using EAP-SIM.
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.
88 * Implemented eap_method_t interface.
90 eap_method_t eap_method_interface
;
94 * Creates the EAP method EAP-SIM acting as server.
96 * @param server ID of the EAP server
97 * @param peer ID of the EAP client
98 * @return eap_sim_t object
100 eap_sim_t
*eap_sim_create_server(identification_t
*server
, identification_t
*peer
);
103 * Creates the EAP method EAP-SIM acting as peer.
105 * @param server ID of the EAP server
106 * @param peer ID of the EAP client
107 * @return eap_sim_t object
109 eap_sim_t
*eap_sim_create_peer(identification_t
*server
, identification_t
*peer
);
111 #endif /* EAP_SIM_H_ @}*/