networksecurity/tls/protocol/handshaketransmitevents.h
changeset 0 af10295192d8
equal deleted inserted replaced
-1:000000000000 0:af10295192d8
       
     1 /**
       
     2 * Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 * Header file containing classes for transmitted Handshake protocol messages.
       
    16 * 
       
    17 *
       
    18 */
       
    19 
       
    20 
       
    21 
       
    22 /**
       
    23  @file HandshakeTransmitEvents.h
       
    24 */
       
    25 #include "tlsevent.h"
       
    26 #include "tlsconnection.h"
       
    27 #include <tlstypedef.h>
       
    28 
       
    29 #ifndef _HANDSHAKETRANSMITEVENTS_H_
       
    30 #define _HANDSHAKETRANSMITEVENTS_H_
       
    31 
       
    32 class CHandshake;
       
    33 class CHandshakeHeader;
       
    34 class CRecordComposer;
       
    35 class CHandshakeTransmit : public CTlsEvent
       
    36 /**
       
    37  * @class This abstract class describes transmitted SSL3.0 and TLS1.0 Handshake 
       
    38  * protocol messages (event classes). It owns the transmitted message.
       
    39  */
       
    40 {
       
    41 public:
       
    42    CHandshakeTransmit( CTLSProvider& aTlsProvider, CStateMachine& aStateMachine, CRecordComposer& aRecordComposer );
       
    43    ~CHandshakeTransmit();
       
    44    CHandshake& Handshake();
       
    45 
       
    46    CHandshakeHeader* HandshakeMessage() const;
       
    47 
       
    48 protected:
       
    49    void ComposeHandshakeHeader( TInt aHistoryUpdate, ETlsHandshakeMessage aHandshakeMessage, TDesC8& aDesComposeMsg );
       
    50 
       
    51 protected:
       
    52    CHandshakeHeader* iHandshakeMessage; // Currently processed outgoing message
       
    53    CRecordComposer& iRecordComposer;
       
    54 };
       
    55 
       
    56 /////////////////////////////////////////////////////////////////////////////////////////////////
       
    57 /** SSL3.0/TLS1/0 TRANSMITTED MESSAGES **/
       
    58 
       
    59 enum EClientHelloStates
       
    60 {
       
    61 	ETlsGetSessionInfo,				/** Get Session information */
       
    62 	ETlsGetCiphers,					/** Get the list of proposed ciphers */
       
    63 	ETlsComposeHello				/** Compose the Hello message */
       
    64 };
       
    65 
       
    66 enum EClientCertificateStates
       
    67 {
       
    68 	ETlsGetCertInfo,				/** Get the encoded Client certificate */
       
    69 	ETlsComposeClientCert			/** Compose the Client certificate message */
       
    70 };
       
    71 
       
    72 enum EClientKeyExchangeStates
       
    73 {
       
    74 	ETlsGetKeyExchangeMsg,			/** Get the Client key exchange message data */
       
    75 	ETlsComposeKeyExchange			/** Compose the message. */
       
    76 };
       
    77 
       
    78 enum ECertificateVerifyStates
       
    79 {
       
    80 	ETlsGetSignature,				/** Get the signed info (signature). */
       
    81 	ETlsComposeCertVerify			/** Compose the Certificate Verify message */
       
    82 };
       
    83 
       
    84 enum EFinishedStates
       
    85 {
       
    86 	ETlsGetFinishedMsg,				/** Get the Finished message data */
       
    87 	ETlsComposeFinished				/** Compose the message. */
       
    88 };
       
    89 
       
    90 class CClientHello : public CHandshakeTransmit
       
    91 /**
       
    92  * @class This class is used to process a Client Hello message (transmitted by the protocol).
       
    93  */
       
    94 {
       
    95 public:
       
    96    CClientHello( CTLSProvider& aTlsProvider, CStateMachine& aStateMachine, CRecordComposer& aRecordComposer );
       
    97    ~CClientHello();
       
    98    
       
    99    virtual CAsynchEvent* ProcessL( TRequestStatus& aStatus );
       
   100 private:
       
   101    EClientHelloStates iClientHelloStates;	// Client Hello states, used to compose the message
       
   102    TPtr8 iBody;								// Body of Client Hello message
       
   103    RArray<TTLSCipherSuite> iCipherList; //CTlsProvider::CipherSuites returns an array rather than descriptor
       
   104 };
       
   105 
       
   106 class CClientKeyExch : public CHandshakeTransmit
       
   107 /**
       
   108  * @class This class is used to process a Client Key Exchange message (transmitted by the protocol).
       
   109  */
       
   110 {
       
   111 public:
       
   112    CClientKeyExch( CTLSProvider& aTlsProvider, CStateMachine& aStateMachine, CRecordComposer& aRecordComposer );
       
   113    virtual CAsynchEvent* ProcessL( TRequestStatus& aStatus );
       
   114    ~CClientKeyExch();
       
   115    
       
   116 private:
       
   117 	EClientKeyExchangeStates iClientKeyExcStates;	// Client Key exchange states, used for message composition
       
   118 	HBufC8* iKeyExchBuf;							// Buffer for the Key exchange message
       
   119 	TPtr8 iBody;									// Body of Client Key exchange message
       
   120 
       
   121 };
       
   122 
       
   123 class CClientCertificate : public CHandshakeTransmit
       
   124 /**
       
   125  * @class This class is used to process a Client Certificate message (transmitted by the protocol).
       
   126  * @brief This message is used to authenticate a client.
       
   127  */
       
   128 {
       
   129 public:
       
   130    CClientCertificate( CTLSProvider& aTlsProvider, CStateMachine& aStateMachine, CRecordComposer& aRecordComposer );
       
   131    virtual CAsynchEvent* ProcessL( TRequestStatus& aStatus );
       
   132    ~CClientCertificate();
       
   133 
       
   134 private:
       
   135    EClientCertificateStates iClientCertStates;	// Client Certificate states, used to compose the message.
       
   136    RPointerArray<HBufC8> iCertArray;
       
   137 };
       
   138 
       
   139 class CCertificateVerify : public CHandshakeTransmit
       
   140 /**
       
   141  * @class This class is used to process a Client Verify message (transmitted by the protocol).
       
   142  */
       
   143 {
       
   144 public:
       
   145    CCertificateVerify( CTLSProvider& aTlsProvider, CStateMachine& aStateMachine, CRecordComposer& aRecordComposer );
       
   146    ~CCertificateVerify();
       
   147    virtual CAsynchEvent* ProcessL( TRequestStatus& aStatus );
       
   148 
       
   149 private:
       
   150 	ECertificateVerifyStates iCertVerifyStates;	// Certificate Verify states, used to compose the message.
       
   151 	HBufC8* iSignature;
       
   152 };
       
   153 
       
   154 class CSendFinished : public CHandshakeTransmit
       
   155 /**
       
   156  * @class This class is used to process a Finished message (transmitted by the protocol).
       
   157  */
       
   158 {
       
   159 public:
       
   160    CSendFinished( CTLSProvider& aTlsProvider, CStateMachine& aStateMachine, CRecordComposer& aRecordComposer );
       
   161    ~CSendFinished();
       
   162    virtual CAsynchEvent* ProcessL( TRequestStatus& aStatus );
       
   163 
       
   164 private:
       
   165 	EFinishedStates iFinishedStates;	// Finished states, used to compose the message.
       
   166 	HBufC8* iFinishedMsg;				// Buffer for the Finished message
       
   167 	TPtr8 iBody;						// Body of the Finished message
       
   168 	CSHA1* iShaHashPtr;					// Copy of SHA1 hash object, used to hash the handshake messages
       
   169 	CMD5*  iMd5HashPtr;					// Copy of MD5 hash object, used to hash the handshake messages
       
   170 };
       
   171 
       
   172 // Inline methods
       
   173 
       
   174 // CHandshakeTransmit inline methods.
       
   175 inline CHandshakeTransmit::CHandshakeTransmit( CTLSProvider& aTlsProvider, CStateMachine& aStateMachine, CRecordComposer& aRecordComposer ) :
       
   176    CTlsEvent( &aTlsProvider, &aStateMachine ),
       
   177    iRecordComposer( aRecordComposer )
       
   178 {
       
   179 }
       
   180 
       
   181 inline CHandshakeHeader* CHandshakeTransmit::HandshakeMessage() const
       
   182 {
       
   183    return iHandshakeMessage;
       
   184 }
       
   185 
       
   186 inline CHandshake& CHandshakeTransmit::Handshake()
       
   187 /**
       
   188  * This method returns a reference to a Handshake negotiation state machine.
       
   189  */
       
   190 {
       
   191 	return (CHandshake&) *iStateMachine;
       
   192 }
       
   193 
       
   194 // CClientHello inline methods
       
   195 inline CClientHello::CClientHello( CTLSProvider& aTlsProvider, CStateMachine& aStateMachine, CRecordComposer& aRecordComposer ) :
       
   196    CHandshakeTransmit( aTlsProvider, aStateMachine, aRecordComposer ),
       
   197    iClientHelloStates( ETlsGetSessionInfo ),
       
   198    iBody( NULL, 0 )
       
   199 {
       
   200 }
       
   201 
       
   202 // CClientKeyExch inline methods
       
   203 inline CClientKeyExch::CClientKeyExch( CTLSProvider& aTlsProvider, CStateMachine& aStateMachine, CRecordComposer& aRecordComposer ) :
       
   204 	CHandshakeTransmit( aTlsProvider, aStateMachine, aRecordComposer ),
       
   205 	iClientKeyExcStates( ETlsGetKeyExchangeMsg ),
       
   206 	iBody( NULL, 0 )
       
   207 {
       
   208 	iKeyExchBuf = NULL;
       
   209 }
       
   210 
       
   211 // CClientCertificate inline methods
       
   212 inline CClientCertificate::CClientCertificate( CTLSProvider& aTlsProvider, CStateMachine& aStateMachine, CRecordComposer& aRecordComposer ) :
       
   213    CHandshakeTransmit( aTlsProvider, aStateMachine, aRecordComposer ),
       
   214    iClientCertStates( ETlsGetCertInfo )
       
   215 {
       
   216 	   
       
   217 }
       
   218 
       
   219 // CCertificateVerify inline methods
       
   220 inline CCertificateVerify::CCertificateVerify( CTLSProvider& aTlsProvider, CStateMachine& aStateMachine, CRecordComposer& aRecordComposer ) :
       
   221    CHandshakeTransmit( aTlsProvider, aStateMachine, aRecordComposer ),
       
   222    iCertVerifyStates( ETlsGetSignature )
       
   223 {
       
   224 	iSignature = NULL;
       
   225 }
       
   226 
       
   227 // CSendFinished inline methods
       
   228 inline CSendFinished::CSendFinished( CTLSProvider& aTlsProvider, CStateMachine& aStateMachine, CRecordComposer& aRecordComposer ) :
       
   229    CHandshakeTransmit( aTlsProvider, aStateMachine, aRecordComposer ),
       
   230    iFinishedStates( ETlsGetFinishedMsg ),
       
   231    iBody ( NULL, 0 ),
       
   232    iShaHashPtr ( NULL ),
       
   233    iMd5HashPtr ( NULL )	
       
   234 {
       
   235 	iFinishedMsg = NULL;
       
   236 }
       
   237 
       
   238 #endif