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
kde_helper.h
00001 /* 00002 * Copyright (c) 2018-2019, 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 KDE_HELPER_H_ 00019 #define KDE_HELPER_H_ 00020 00021 /* 00022 * EAPOL KDE helper functions 00023 * 00024 */ 00025 00026 #define KDE_GTK_LEN 6 + 2 + 16 00027 #define KDE_PMKID_LEN 6 + 16 00028 #define KDE_PTKID_LEN 6 + 16 00029 #define KDE_LIFETIME_LEN 6 + 4 00030 #define KDE_GTKL_LEN 6 + 1 00031 00032 /** 00033 * kde_padded_length_calc calculates padded length for kde (see IEEE 802.11 chapter 11.6.2 EAPOL-Key frames) 00034 * 00035 * \param kde_length length without padding 00036 * 00037 * \return padded length 00038 */ 00039 uint16_t kde_padded_length_calc(uint16_t kde_length); 00040 00041 /** 00042 * kde_padding_write writes padded bytes 00043 * 00044 * \param start_ptr first byte of the padding 00045 * \param end_ptr last bytes next byte 00046 * 00047 */ 00048 void kde_padding_write(uint8_t *start_ptr, uint8_t *end_ptr); 00049 00050 /** 00051 * kde_gtk_write writes GTK 00052 * 00053 * \param ptr pointer where to write 00054 * \param key_id key identifier (index) 00055 * \param gtk GTK 00056 * 00057 * return incremented write pointer 00058 * 00059 */ 00060 uint8_t *kde_gtk_write(uint8_t *ptr, uint8_t key_id, const uint8_t *gtk); 00061 00062 /** 00063 * kde_pmkid_write writes PMKID 00064 * 00065 * \param ptr pointer where to write 00066 * \param pmkid PMKID 00067 * 00068 * return incremented write pointer 00069 * 00070 */ 00071 uint8_t *kde_pmkid_write(uint8_t *ptr, const uint8_t *pmkid); 00072 00073 /** 00074 * kde_ptkid_write writes PTKID 00075 * 00076 * \param ptr pointer where to write 00077 * \param pmkid PTKID 00078 * 00079 * return incremented write pointer 00080 * 00081 */ 00082 uint8_t *kde_ptkid_write(uint8_t *ptr, const uint8_t *ptkid); 00083 00084 /** 00085 * kde_lifetime_write writes GTK lifetime 00086 * 00087 * \param ptr pointer where to write 00088 * \param lifetime GTK lifetime 00089 * 00090 * return incremented write pointer 00091 * 00092 */ 00093 uint8_t *kde_lifetime_write(uint8_t *ptr, uint32_t lifetime); 00094 00095 /** 00096 * kde_gtkl_write writes GTK liveness information 00097 * 00098 * \param ptr pointer where to write 00099 * \param gtkl GTK liveness bit field 00100 * 00101 * return incremented write pointer 00102 * 00103 */ 00104 uint8_t *kde_gtkl_write(uint8_t *ptr, uint8_t gtkl); 00105 00106 /** 00107 * kde_gtk_read reads GTK 00108 * 00109 * \param ptr pointer where to read 00110 * \param len length of the remaining data 00111 * \param key_id key identifier (index) 00112 * \param gtk GTK 00113 * 00114 * \return < 0 failure 00115 * \return >= 0 success 00116 * 00117 */ 00118 int8_t kde_gtk_read(const uint8_t *ptr, uint16_t len, uint8_t *key_id, uint8_t *gtk); 00119 00120 /** 00121 * kde_pmkid_read reads PMKID 00122 * 00123 * \param ptr pointer where to read 00124 * \param len length of the remaining data 00125 * \param pmkid PMKID 00126 * 00127 * \return < 0 failure 00128 * \return >= 0 success 00129 * 00130 */ 00131 int8_t kde_pmkid_read(const uint8_t *ptr, uint16_t len, uint8_t *pmkid); 00132 00133 /** 00134 * kde_ptkid_read reads PTKID 00135 * 00136 * \param ptr pointer where to read 00137 * \param len length of the remaining data 00138 * \param ptkid PTKID 00139 * 00140 * \return < 0 failure 00141 * \return >= 0 success 00142 * 00143 */ 00144 int8_t kde_ptkid_read(const uint8_t *ptr, uint16_t len, uint8_t *ptkid); 00145 00146 /** 00147 * kde_lifetime_read reads GTK lifetime 00148 * 00149 * \param ptr pointer where to read 00150 * \param len length of the remaining data 00151 * \param lifetime GTK lifetime 00152 * 00153 * \return < 0 failure 00154 * \return >= 0 success 00155 * 00156 */ 00157 int8_t kde_lifetime_read(const uint8_t *ptr, uint16_t len, uint32_t *lifetime); 00158 00159 /** 00160 * kde_gtkl_read reads GTK liveness information 00161 * 00162 * \param ptr pointer where to read 00163 * \param len length of the remaining data 00164 * \param gtkl GTK liveness bit field 00165 * 00166 * \return < 0 failure 00167 * \return >= 0 success 00168 * 00169 */ 00170 int8_t kde_gtkl_read(const uint8_t *ptr, uint16_t len, uint8_t *gtkl); 00171 00172 #endif /* KDE_HELPER_H_ */
Generated on Tue Jul 12 2022 13:54:25 by
