00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049 #ifndef __EAP_TLS_FSM_HXX__
00050 #define __EAP_TLS_FSM_HXX__
00051
00052
00053 #include <ace/Reactor.h>
00054 #include <stdio.h>
00055 #include "eap_tls.hxx"
00056 #include "eap_fsm.hxx"
00057 #include "eap_peerfsm.hxx"
00058 #include "eap_authfsm.hxx"
00059 #include "eap_method_registrar.hxx"
00060 #include "eap_tls_session.hxx"
00061 #include "eap_tls_parser.hxx"
00062 #include "eap_tls_mng.hxx"
00063
00065 class EapPeerTlsStateMachine
00066 : public EapMethodStateMachine,
00067 public EapStateMachine<EapPeerTlsStateMachine>
00068 {
00069 friend class EapMethodStateMachineCreator<EapPeerTlsStateMachine>;
00070 friend class EapPeerTlsStateTable_S;
00071 public:
00072
00074 void Start() throw(AAA_Error)
00075 {
00076 std::string cliente("cliente");
00077 std::string clt_key("./tests/tls_config/peer/clt-key.pem");
00078 std::string clt_cert("./tests/tls_config/peer/clt-cert.pem");
00079 std::string random_peer("./tests/tls_config/auth/random");
00080 std::string ca_path_peer("./tests/tls_config/peer");
00081 std::string ca_cert_peer("./tests/tls_config/peer/ca-cert.pem");
00082 std::string dh_peer("./tests/tls_config/auth/dh");
00083 EAPTLS_config *config_peer= new EAPTLS_config(cliente,
00084 clt_key,
00085 clt_cert,
00086 random_peer,
00087 ca_path_peer,
00088 ca_cert_peer,
00089 dh_peer,
00090 (ACE_INT32)0,
00091 (ACE_INT32)1,
00092 (ACE_INT32)512,
00093 (ACE_INT32)512,
00094 (ACE_INT32)1,
00095 (ACE_INT32)1,
00096 false,
00097 (ACE_INT32)600);
00098
00099
00100
00101 ctx_peer=tls_mng_peer.init_tls_ctx(*config_peer);
00102 tls_conf_ctx_peer = new EAPTLS_tls_t(config_peer,ctx_peer);
00103 EapStateMachine<EapPeerTlsStateMachine>::Start();
00104 }
00105
00107 inline void Notify(AAA_Event ev)
00108 {
00109 EapStateMachine<EapPeerTlsStateMachine>::Notify(ev);
00110 }
00111
00114 virtual std::string& InputIdentity()=0;
00115
00117 EAPTLS_session_t_peer* get_tls_session() {return ssn;};
00118 EAPTLS_tls_mng_peer& get_mng_peer(){return tls_mng_peer;};
00120 void set_tls_session(EAPTLS_session_t_peer *ssn)
00121 {
00122 if (this->ssn != NULL) delete this->ssn;this->ssn = ssn;
00123 }
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134 EAPTLS_tls_t * get_ctx_peer() {return tls_conf_ctx_peer;};
00135
00136 protected:
00137 EAPTLS_config *config_peer;
00138 EAPTLS_tls_mng_peer tls_mng_peer;
00139 TLS_context *ctx_peer;
00140 EAPTLS_tls_t *tls_conf_ctx_peer;
00141
00142 EapPeerTlsStateMachine(EapSwitchStateMachine &s);
00143 ~EapPeerTlsStateMachine() {};
00145 EAPTLS_session_t_peer *ssn;
00147 std::string history;
00148 };
00149
00151 class EapAuthTlsStateMachine
00152 : public EapMethodStateMachine,
00153 public EapStateMachine<EapAuthTlsStateMachine>
00154 {
00155 friend class EapMethodStateMachineCreator<EapAuthTlsStateMachine>;
00156 friend class EapAuthTlsStateTable_S;
00157 public:
00158
00160 void Start() throw(AAA_Error)
00161 {
00162 std::string servidor("servidor");
00163 std::string srv_key("./tests/tls_config/auth/srv-key.pem");
00164 std::string srv_cert("./tests/tls_config/auth/srv-cert.pem");
00165 std::string random("./tests/tls_config/auth/random");
00166 std::string ca_path("./tests/tls_config/auth");
00167 std::string ca_cert("./tests/tls_config/auth/ca-cert.pem");
00168 std::string dh("./tests/tls_config/auth/dh");
00169 int s_server_session_id_context=0xFFFFF;
00170
00171 EAPTLS_config *config_auth=new EAPTLS_config(servidor,
00172 srv_key,
00173 srv_cert,
00174 random,
00175 ca_path,
00176 ca_cert,
00177 dh,
00178 (ACE_INT32)0,
00179 (ACE_INT32)1,
00180 (ACE_INT32)512,
00181 (ACE_INT32)512,
00182 (ACE_INT32)1,
00183 (ACE_INT32)1,
00184 false,
00185 (ACE_INT32)500);
00186 ctx_auth=tls_mng_auth.init_tls_ctx(*config_auth,s_server_session_id_context);
00187 tls_conf_ctx_auth = new EAPTLS_tls_t(config_auth,ctx_auth);
00188
00189
00190 EapStateMachine<EapAuthTlsStateMachine>::Start();
00191 }
00192
00194 inline void Notify(AAA_Event ev)
00195 {
00196 EapStateMachine<EapAuthTlsStateMachine>::Notify(ev);
00197 }
00199 EAPTLS_session_t_auth* get_tls_session() {return ssn;};
00200 EAPTLS_tls_mng_auth& get_mng_auth(){return tls_mng_auth;};
00202 void set_tls_session(EAPTLS_session_t_auth *ssn) {if (this->ssn != NULL) delete this->ssn;this->ssn = ssn;};
00204
00205
00206
00207
00208
00209
00210
00211
00212 EAPTLS_tls_t * get_ctx_auth(){ return tls_conf_ctx_auth;}
00213
00215 std::string& History() { return history; }
00216 protected:
00217
00218 EAPTLS_config *config_auth;
00219 EAPTLS_tls_mng_auth tls_mng_auth;
00220 TLS_context *ctx_auth;
00221 EAPTLS_tls_t *tls_conf_ctx_auth;
00222
00223 EapAuthTlsStateMachine(EapSwitchStateMachine &s);
00224 ~EapAuthTlsStateMachine() {}
00226 EAPTLS_session_t_auth *ssn;
00228 std::string history;
00229 };
00230 #endif