Main Page | Class Hierarchy | Class List | File List | Class Members | File Members | Related Pages

eap_tls_fsm.hxx

00001 /* BEGIN_COPYRIGHT                                                        */
00002 /*                                                                        */
00003 /* Open Diameter: Open-source software for the Diameter and               */
00004 /*                Diameter related protocols                              */
00005 /*                                                                        */
00006 /* Copyright (C) 2002-2004 Open Diameter Project                          */
00007 /*                                                                        */
00008 /* This program is free software; you can redistribute it and/or modify   */
00009 /* it under the terms of the GNU General Public License as published by   */
00010 /* the Free Software Foundation; either version 2 of the License, or      */
00011 /* (at your option) any later version.                                    */
00012 /*                                                                        */          
00013 /* This program is distributed in the hope that it will be useful,        */
00014 /* but WITHOUT ANY WARRANTY; without even the implied warranty of         */
00015 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          */
00016 /* GNU General Public License for more details.                           */
00017 /*                                                                        */
00018 /* You should have received a copy of the GNU General Public License      */
00019 /* along with this program; if not, write to the Free Software            */
00020 /* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307    */
00021 /* USA.                                                                   */
00022 /*                                                                        */
00023 /* In addition, when you copy and redistribute some or the entire part of */
00024 /* the source code of this software with or without modification, you     */
00025 /* MUST include this copyright notice in each copy.                       */
00026 /*                                                                        */
00027 /* If you make any changes that are appeared to be useful, please send    */
00028 /* sources that include the changed part to                               */
00029 /* diameter-developers@lists.sourceforge.net so that we can reflect your  */
00030 /* changes to one unified version of this software.                       */
00031 /*                                                                        */
00032 /* END_COPYRIGHT                                                          */
00033 /***************************************************************************
00034                           eap_tls_fsm.hxx  -  description
00035                              -------------------
00036     begin                : jue mar 18 2004
00037     copyright            : (C) 2004 by 
00038     email                : 
00039  ***************************************************************************/
00040 
00041 /***************************************************************************
00042  *                                                                         *
00043  *   This program is free software; you can redistribute it and/or modify  *
00044  *   it under the terms of the GNU General Public License as published by  *
00045  *   the Free Software Foundation; either version 2 of the License, or     *
00046  *   (at your option) any later version.                                   *
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   /*AAAMessageBlock *get_master_key()
00126   {
00127     TLS_data *data = ssn->get_tls_data();
00128     ACE_UINT32 msk_length = (ACE_UINT32)(data->session->master_key_length); //Recover master key length
00129     AAAMessageBlock *msk = AAAMessageBlock::Acquire(msk_length);
00130     msk->copy((const char *)data->session->master_key,msk_length);
00131     return msk;
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);    //Fragment size.
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   /*AAAMessageBlock *get_master_key()
00205   {
00206     TLS_data *data = ssn->get_tls_data();
00207     ACE_UINT32 msk_length = (ACE_UINT32)(data->session->master_key_length); //Recover master key length
00208     AAAMessageBlock *msk = AAAMessageBlock::Acquire((char *)data->session->master_key,msk_length);
00209     return msk;
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

Generated on Fri Jun 25 19:16:16 2004 for EAP State Machine by doxygen 1.3.5