eapol/eapol_framework/eapol_common/am/include/ms_mppe_keys.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(_MS_MPPE_KEYS_H_)
       
    22 #define _MS_MPPE_KEYS_H_
       
    23 
       
    24 
       
    25 //----------------------------------------------------------------------------
       
    26 
       
    27 // Here is copy from draft-ietf-radius-mschap-attr-01.txt:
       
    28 //
       
    29 // 0                   1                   2                   3
       
    30 // 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
       
    31 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
       
    32 // |                  Vendor-ID                                  |
       
    33 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
       
    34 // | Vendor-Type   | Vendor-Length |           Keys              |
       
    35 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
       
    36 // |                       Keys (cont) total 24 bytes            |
       
    37 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
       
    38 // |                       Keys (cont)                           |
       
    39 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
       
    40 // |                       Keys (cont)                           |
       
    41 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
       
    42 // |                       Keys (cont)                           |
       
    43 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
       
    44 // |                       Keys (cont)                           |
       
    45 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
       
    46 // |      Keys (cont)              |      Padding                |
       
    47 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
       
    48 // |                       Padding                               |
       
    49 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
       
    50 // |        Padding                |
       
    51 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
       
    52 
       
    53 const u32_t MPPE_LM_KEY_LENGTH  =  8u;
       
    54 const u32_t MPPE_NT_KEY_LENGTH  = 16u;
       
    55 const u32_t MPPE_PADDING_LENGTH =  8u;
       
    56 
       
    57 #pragma pack(1)
       
    58 
       
    59 // 
       
    60 class mppe_keys_c
       
    61 {
       
    62 private:
       
    63 	//--------------------------------------------------
       
    64 
       
    65 	u32_t m_vendor_id;
       
    66 	u8_t m_vendor_type;
       
    67 	u8_t m_vendor_length;
       
    68 	u8_t m_LM_Key[MPPE_LM_KEY_LENGTH];
       
    69 	u8_t m_NT_Key[MPPE_NT_KEY_LENGTH];
       
    70 	u8_t m_padding[MPPE_PADDING_LENGTH];
       
    71 
       
    72 	//--------------------------------------------------
       
    73 protected:
       
    74 	//--------------------------------------------------
       
    75 
       
    76 	//--------------------------------------------------
       
    77 public:
       
    78 	//--------------------------------------------------
       
    79 
       
    80 	// 
       
    81 	~mppe_keys_c()
       
    82 	{
       
    83 	}
       
    84 
       
    85 	// 
       
    86 	mppe_keys_c(abs_eap_am_tools_c * const m_am_tools)
       
    87 	{
       
    88 		reset_header(m_am_tools);
       
    89 	}
       
    90 
       
    91 	void reset_header(abs_eap_am_tools_c * const m_am_tools)
       
    92 	{
       
    93 		m_vendor_id = eap_htonl(311); // microsoft
       
    94 		m_vendor_type = 12u; // MS-CHAP-MPPE-Keys
       
    95 		m_vendor_length = 34u;
       
    96 		m_am_tools->memset(m_LM_Key, 0, sizeof(m_LM_Key));
       
    97 		m_am_tools->memset(m_NT_Key, 0, sizeof(m_NT_Key));
       
    98 		m_am_tools->memset(m_padding, 0, sizeof(m_padding));
       
    99 	}
       
   100 
       
   101 	eap_status_e set_LM_Key(
       
   102 		abs_eap_am_tools_c * const m_am_tools,
       
   103 		const u8_t * const key,
       
   104 		const u32_t key_length)
       
   105 	{
       
   106 		if (key_length >= sizeof(m_LM_Key))
       
   107 		{
       
   108 			m_am_tools->memmove(m_LM_Key, key, sizeof(m_LM_Key));
       
   109 			return eap_status_ok;
       
   110 		}
       
   111 		else
       
   112 		{
       
   113 			return eap_status_key_error;
       
   114 		}
       
   115 	}
       
   116 
       
   117 	eap_status_e set_NT_Key(
       
   118 		abs_eap_am_tools_c * const m_am_tools,
       
   119 		const u8_t * const key,
       
   120 		const u32_t key_length)
       
   121 	{
       
   122 		if (key_length >= sizeof(m_NT_Key))
       
   123 		{
       
   124 			m_am_tools->memmove(m_NT_Key, key, sizeof(m_NT_Key));
       
   125 			return eap_status_ok;
       
   126 		}
       
   127 		else
       
   128 		{
       
   129 			return eap_status_key_error;
       
   130 		}
       
   131 	}
       
   132 
       
   133 	// 
       
   134 	//--------------------------------------------------
       
   135 }; // class mppe_keys_c
       
   136 
       
   137 #pragma pack()
       
   138 
       
   139 #endif //#if !defined(_MS_MPPE_KEYS_H_)
       
   140 
       
   141 //--------------------------------------------------
       
   142 
       
   143 
       
   144 
       
   145 // End.