networksecurity/tls/protocol/changecipherevents.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 * Change Cipher Spec protocol events class header file.
       
    16 * Describes a concrete class for SSL3.0/TLS1.0 Change Cipher spec messages (events),
       
    17 * sent and received.
       
    18 * 
       
    19 *
       
    20 */
       
    21 
       
    22 
       
    23 
       
    24 /**
       
    25  @file ChangeCipherEvents.h
       
    26 */
       
    27 
       
    28 #ifndef _CHANGECIPHEREVENTS_H_
       
    29 #define _CHANGECIPHEREVENTS_H_
       
    30 
       
    31 #include "tlsevent.h"
       
    32 
       
    33 const TUint8 KChangeCipherSpecMsgLength = 1;	// Length of ChangeCipherSpec message.
       
    34 const TUint8 KChangeCipherSpecMsg = 1;			// Content of ChangeCipherSpec message.
       
    35 
       
    36 class CHandshake;
       
    37 class CRecordComposer;
       
    38 class CStateMachine;
       
    39 class CTLSProvider;
       
    40 class CSendChangeCipherSpec : public CTlsEvent
       
    41 /**
       
    42  * @class This class describes a Change Cipher Spec message sent by the protocol.
       
    43  * @brief This message consists of a single byte of value one, which is compressed
       
    44  * and encrypted under the current connection state.
       
    45  *
       
    46  * Note that Cipher spec messages (sent or received) are not part of the Handshake protocol 
       
    47  * and as such do not derive from the CHandshakeTransmit or CHandshakeReceive classes.
       
    48  */
       
    49 {
       
    50 public:
       
    51    CSendChangeCipherSpec( CTLSProvider& aTlsProvider, CStateMachine& aStateMachine, CRecordComposer& aRecordComposer );
       
    52    virtual CAsynchEvent* ProcessL( TRequestStatus& aStatus );
       
    53    CHandshake& Handshake();		// Used to access the iTransmitList (list of events to transmit).
       
    54 
       
    55 private:
       
    56    CRecordComposer& iRecordComposer;	// Used to compose the transmitted message.
       
    57    TBuf8<KChangeCipherSpecMsgLength> iCipherSpecMsg;
       
    58    const TUint8* iMsgPtr;
       
    59 };
       
    60 
       
    61 inline CSendChangeCipherSpec::CSendChangeCipherSpec( CTLSProvider& aTlsProvider, CStateMachine& aStateMachine, CRecordComposer& aRecordComposer ) :
       
    62 	CTlsEvent( &aTlsProvider, &aStateMachine ),
       
    63 	iRecordComposer( aRecordComposer )
       
    64 {
       
    65 	iMsgPtr = &KChangeCipherSpecMsg;
       
    66 }
       
    67 
       
    68 inline CHandshake& CSendChangeCipherSpec::Handshake()
       
    69 /**
       
    70  * This method returns a reference to a Handshake negotiation state machine.
       
    71  */
       
    72 {
       
    73 	return (CHandshake&) *iStateMachine;
       
    74 }
       
    75 
       
    76 
       
    77 
       
    78 class CRecordParser;
       
    79 class CRecvChangeCipherSpec : public CTlsEvent
       
    80 /**
       
    81  * @class This class describes a Change Cipher Spec message received by the protocol
       
    82  * (i.e., sent by the server). 
       
    83  * @brief This message consists of a single byte of value one, which is compressed
       
    84  * and encrypted under the current connection state.
       
    85  *
       
    86  */
       
    87 {
       
    88 public:
       
    89    CRecvChangeCipherSpec( CStateMachine& aStateMachine, CRecordParser& aRecordParser );
       
    90    virtual TBool AcceptRecord( TInt aRecordType ) const;
       
    91    virtual CAsynchEvent* ProcessL( TRequestStatus& aStatus );
       
    92 
       
    93 private:
       
    94    CRecordParser& iRecordParser;	// Used to parse the received message.
       
    95 };
       
    96 
       
    97 inline CRecvChangeCipherSpec::CRecvChangeCipherSpec( CStateMachine& aStateMachine, CRecordParser& aRecordParser ) :
       
    98    CTlsEvent( NULL, &aStateMachine ),
       
    99    iRecordParser( aRecordParser )
       
   100 {
       
   101 }
       
   102 #endif
       
   103