Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: TYBLE16_simple_data_logger TYBLE16_MP3_Air
ieee_802_11.h
00001 /* 00002 * Copyright (c) 2016-2018, Arm Limited and affiliates. 00003 * SPDX-License-Identifier: Apache-2.0 00004 * 00005 * Licensed under the Apache License, Version 2.0 (the "License"); 00006 * you may not use this file except in compliance with the License. 00007 * You may obtain a copy of the License at 00008 * 00009 * http://www.apache.org/licenses/LICENSE-2.0 00010 * 00011 * Unless required by applicable law or agreed to in writing, software 00012 * distributed under the License is distributed on an "AS IS" BASIS, 00013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00014 * See the License for the specific language governing permissions and 00015 * limitations under the License. 00016 */ 00017 00018 #ifndef IEEE_802_11_ 00019 #define IEEE_802_11_ 00020 00021 typedef struct { 00022 const uint8_t *key; /**< Key string */ 00023 uint8_t *string; /**< Data string (A string + Y + B string + X) */ 00024 uint16_t bits; /**< Number of PRF bits */ 00025 uint16_t key_len; /**< Key string length */ 00026 uint16_t a_len; /**< A string length */ 00027 uint16_t b_len; /**< B string length */ 00028 } ieee_802_11_prf_t; 00029 00030 /* 00031 From IEEE 802.11 chapter 11.6.1.2 PRF: 00032 00033 In the following, K is a key; A is a unique label for each different purpose 00034 of the PRF; B is a variable-length string; Y is a single octet containing 0; 00035 X is a single octet containing the loop parameter i; and || denotes concatenation: 00036 00037 H-SHA-1(K, A, B, X) ← HMAC-SHA-1(K, A || Y || B || X) 00038 00039 PRF(K, A, B, Len) 00040 for i ← 0 to (Len+159)/160 do 00041 R ← R || H-SHA-1(K, A, B, i) 00042 return L(R, 0, Len) 00043 00044 PRF-128(K, A, B) = PRF(K, A, B, 128) 00045 PRF-192(K, A, B) = PRF(K, A, B, 192) 00046 PRF-256(K, A, B) = PRF(K, A, B, 256) 00047 PRF-384(K, A, B) = PRF(K, A, B, 384) 00048 PRF-512(K, A, B) = PRF(K, A, B, 512) 00049 */ 00050 00051 /** 00052 * \brief Setup IEEE 802.11 PRF 00053 * 00054 * Update is made based on failed and successful message sending 00055 * attempts for a message. 00056 * 00057 * \param prf pointer to PRF data 00058 * \param bits number of bits 00059 * \param a_len A string length 00060 * \param b_len B string length 00061 * 00062 * \return length of the combined string that is input parameter for further functions 00063 * (this is length of the A string + Y + B string + X) 00064 */ 00065 uint16_t ieee_802_11_prf_setup(ieee_802_11_prf_t *prf, uint16_t bits, uint16_t a_len, uint16_t b_len); 00066 00067 /** 00068 * \brief Get A string pointer 00069 * 00070 * Get a pointer to A string start that is used to write A string contents 00071 * 00072 * \param prf pointer to PRF data 00073 * \param string pointer to input string 00074 * 00075 * \return pointer to A string part of the input string 00076 */ 00077 uint8_t *ieee_802_11_prf_get_a_string(ieee_802_11_prf_t *prf, uint8_t *string); 00078 00079 /** 00080 * \brief Get B string pointer 00081 * 00082 * Get a pointer to B string start that is used to write B string contents 00083 * 00084 * \param prf pointer to PRF data 00085 * \param string pointer to input string 00086 * 00087 * \return pointer to B string part of the input string 00088 */ 00089 uint8_t *ieee_802_11_prf_get_b_string(ieee_802_11_prf_t *prf, uint8_t *string); 00090 00091 /** 00092 * \brief Start PRF process 00093 * 00094 * Start PRF process 00095 * 00096 * \param prf pointer to PRF data 00097 * \param key key 00098 * \param key_len key length 00099 * 00100 * \return length of the return string 00101 */ 00102 uint16_t ieee_802_11_prf_starts(ieee_802_11_prf_t *prf, const uint8_t *key, uint16_t key_len); 00103 00104 /** 00105 * \brief Update PRF process 00106 * 00107 * Update PRF process 00108 * 00109 * \param prf pointer to PRF data 00110 * \param string pointer to input string 00111 * 00112 */ 00113 void ieee_802_11_prf_update(ieee_802_11_prf_t *prf, uint8_t *string); 00114 00115 /** 00116 * \brief Finish PRF process 00117 * 00118 * Finish PRF process 00119 * 00120 * \param prf pointer to PRF data 00121 * \param result pointer to result string 00122 * 00123 * \return < 0 failure 00124 * \return >= 0 success 00125 * 00126 */ 00127 int8_t ieee_802_11_prf_finish(ieee_802_11_prf_t *prf, uint8_t *result); 00128 00129 #endif /* IEEE_802_11_*/
Generated on Tue Jul 12 2022 13:54:24 by
1.7.2