eapol/eapol_framework/eapol_common/type/tls_peap/tls/include/tls_message.h
changeset 0 c8830336c852
child 2 1c7bc153c08e
equal deleted inserted replaced
-1:000000000000 0:c8830336c852
       
     1 /*
       
     2 * Copyright (c) 2001-2006 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 the License "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:  EAP and WLAN authentication protocols.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 #if !defined(_TLS_MESSAGE_H_)
       
    22 #define _TLS_MESSAGE_H_
       
    23 
       
    24 #include "eap_tools.h"
       
    25 #include "eap_array.h"
       
    26 #include "tls_record_message.h"
       
    27 #include "abs_tls_message_hash.h"
       
    28 #include "abs_tls_apply_cipher_spec.h"
       
    29 
       
    30 /** @file */
       
    31 
       
    32 
       
    33 //----------------------------------------------------------------------------
       
    34 
       
    35 
       
    36 /// This class defines one TLS-message. One TLS message could include many TLS-records.
       
    37 /**
       
    38  * This class defined one TLS-message.
       
    39  * Parse and analyse of TLS-message is asyncronous.
       
    40  * m_analyse_index tells the index of message where asyncronous
       
    41  * analyse of TLS-message must continue.
       
    42  * Analysed messages are skipped during the asyncronous
       
    43  * analyse of messages. Asyncronous analyse is needed
       
    44  * because of the PKI functions are asyncronous in
       
    45  * Symbian.
       
    46  */
       
    47 class EAP_EXPORT tls_message_c
       
    48 {
       
    49 private:
       
    50 	//--------------------------------------------------
       
    51 
       
    52 	/// This is pointer to the tools class. @see abs_eap_am_tools_c.
       
    53 	abs_eap_am_tools_c * const m_am_tools;
       
    54 
       
    55 	/// This is pointer to interface of message HASH creation. See abs_tls_message_hash_c.
       
    56 	abs_tls_message_hash_c * const m_message_hash;
       
    57 
       
    58 	/// This is pointer to interface of apply cipher spec. See abs_tls_apply_cipher_spec_c.
       
    59 	abs_tls_apply_cipher_spec_c * const m_apply_cipher_spec;
       
    60 
       
    61 	/// This is pointer to interface of change cipher spec. See abs_tls_change_cipher_spec_c.
       
    62 	abs_tls_change_cipher_spec_c * m_change_cipher_spec;
       
    63 
       
    64 	/// This buffer includes copy of the whole received TLS-message data.
       
    65 	eap_variable_data_c m_tls_message_data;
       
    66 
       
    67 	/// This is EAP-identifier of the EAP-packet that includes TLS-message. This is needed in XP-PEAP.
       
    68 	u8_t m_received_eap_identifier;
       
    69 
       
    70 	/// This is the index of message where asyncronous analyse of TLS-message must continue.
       
    71 	u32_t m_analyse_index;
       
    72 
       
    73 	/// This array includes one or more records.
       
    74 	eap_array_c<tls_record_message_c> m_record_messages;
       
    75 
       
    76 	/// This indicates whether this object is client (true) or server (false). This is mostly for traces.
       
    77 	const bool m_is_client;
       
    78 
       
    79 	/// This flag tells the send message includes TLS-Handshake message.
       
    80 	/// Note the received messages are not marked.
       
    81 	/// This information is needed in special PEAP version.
       
    82 	/// All messages including TLS-Handshake message must have PEAP L bit and four octet TLS message length field.
       
    83 	bool m_includes_tls_handshake_message;
       
    84 
       
    85 	//--------------------------------------------------
       
    86 protected:
       
    87 	//--------------------------------------------------
       
    88 
       
    89 	//--------------------------------------------------
       
    90 public:
       
    91 	//--------------------------------------------------
       
    92 
       
    93 	/**
       
    94 	 * The destructor of the tls_message_c class does nothing special.
       
    95 	 */
       
    96 	EAP_FUNC_IMPORT virtual ~tls_message_c();
       
    97 
       
    98 	/**
       
    99 	 * The constructor of the tls_message_c class simply initializes the attributes.
       
   100 	 */
       
   101 	EAP_FUNC_IMPORT tls_message_c(
       
   102 		abs_eap_am_tools_c * const tools,
       
   103 		abs_tls_message_hash_c * const message_hash,
       
   104 		abs_tls_apply_cipher_spec_c * const apply_cipher_spec,
       
   105 		abs_tls_change_cipher_spec_c * const change_cipher_spec,
       
   106 		const bool is_client);
       
   107 
       
   108 	/**
       
   109 	 * This function resets this object.
       
   110 	 */
       
   111 	EAP_FUNC_IMPORT eap_status_e reset();
       
   112 
       
   113 	/**
       
   114 	 * This function returns the index of message where analyse must continue.
       
   115 	 */
       
   116 	EAP_FUNC_IMPORT u32_t get_analyse_index() const;
       
   117 
       
   118 	/**
       
   119 	 * This function saves the index of message where analyse must continue.
       
   120 	 */
       
   121 	EAP_FUNC_IMPORT void save_analyse_index(const u32_t analyse_index);
       
   122 
       
   123 	/**
       
   124 	 * This function copies the received TLS-message data and EAP-identifier.
       
   125 	 * EAP-identifier is needed in XP PEAPv0. That stupid version uses
       
   126 	 * same EAP-identifier with PEAP header and tunneled EAP-header.
       
   127 	 */
       
   128 	EAP_FUNC_IMPORT eap_status_e set_tls_message_data(
       
   129 		eap_variable_data_c * const tls_message_data,
       
   130 		const u8_t received_eap_identifier);
       
   131 
       
   132 	/**
       
   133 	 * This function returns the TLS-message data.
       
   134 	 */
       
   135 	EAP_FUNC_IMPORT eap_variable_data_c * get_tls_message_data();
       
   136 
       
   137 	/**
       
   138 	 * This function returns the EAP-identifier.
       
   139 	 */
       
   140 	EAP_FUNC_IMPORT u8_t get_received_eap_identifier();
       
   141 
       
   142 	/**
       
   143 	 * This function adds TLS-record to m_record_messages.
       
   144 	 * Parameter free_record tells whether record must be freed in destructor.
       
   145 	 */
       
   146 	EAP_FUNC_IMPORT eap_status_e add_record_message(
       
   147 		tls_record_message_c * const record,
       
   148 		const bool free_record,
       
   149 		const bool includes_tls_handshake_message);
       
   150 
       
   151 	/**
       
   152 	 * This function fragments TLS-protocol messages to one or more TLS-record messages.
       
   153 	 */
       
   154 	EAP_FUNC_IMPORT eap_status_e fragment_tls_records(
       
   155 		tls_record_message_c * const tls_record_message,
       
   156 		eap_array_c<tls_record_message_c> * const tls_fragments);
       
   157 
       
   158 	/**
       
   159 	 * This function adds data of every TLS-record to tls_message_buffer.
       
   160 	 */
       
   161 	EAP_FUNC_IMPORT eap_status_e add_message_data(
       
   162 		eap_variable_data_c * const tls_message_buffer,
       
   163 		bool * const includes_tls_handshake_message);
       
   164 
       
   165 	/**
       
   166 	 * This function returns count of the TLS-records.
       
   167 	 */
       
   168 	EAP_FUNC_IMPORT u32_t get_record_message_count() const;
       
   169 
       
   170 	/**
       
   171 	 * This function returns pointer to the TLS-record selected by index.
       
   172 	 */
       
   173 	EAP_FUNC_IMPORT tls_record_message_c * get_record_message(
       
   174 		const u32_t index) const;
       
   175 
       
   176 	/**
       
   177 	 * This function removes the TLS-record selected by index.
       
   178 	 */
       
   179 	EAP_FUNC_IMPORT eap_status_e remove_record_message(
       
   180 		const u32_t index);
       
   181 
       
   182 	/**
       
   183 	 * This function returns pointer to the last TLS-record.
       
   184 	 */
       
   185 	EAP_FUNC_IMPORT tls_record_message_c * get_last_record_message() const;
       
   186 
       
   187 	// 
       
   188 	//--------------------------------------------------
       
   189 }; // class tls_message_c
       
   190 
       
   191 
       
   192 //--------------------------------------------------
       
   193 
       
   194 #endif //#if !defined(_TLS_MESSAGE_H_)
       
   195 
       
   196 
       
   197 
       
   198 // End.