Changeset a931b7b in mainline for uspace/lib/ieee80211/src/ieee80211_impl.c
- Timestamp:
- 2015-04-13T20:48:33Z (10 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- cc575ef9
- Parents:
- 053fc2b
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/ieee80211/src/ieee80211_impl.c
r053fc2b ra931b7b 165 165 166 166 /** 167 * Pseudorandom function used for IEEE 802.11 pairwise key computation. 167 * Pseudorandom function used for IEEE 802.11 pairwise key computation 168 * using SHA1 hash algorithm. 168 169 * 169 170 * @param key Key with PBKDF2 encrypted passphrase. 170 171 * @param data Concatenated sequence of both mac addresses and nonces. 171 * @param hash Output parameter for result hash (48 byte value).172 * @param hash_sel Hash function selector.172 * @param hash Output parameter for result hash. 173 * @param output_size Length of output sequence to be generated. 173 174 * 174 175 * @return EINVAL when key or data not specified, ENOMEM when pointer for … … 176 177 */ 177 178 int ieee80211_prf(uint8_t *key, uint8_t *data, uint8_t *hash, 178 hash_func_t hash_sel)179 size_t output_size) 179 180 { 180 181 if(!key || !data) … … 184 185 return ENOMEM; 185 186 186 size_t result_length = (hash_sel == HASH_MD5) ? 187 IEEE80211_PTK_TKIP_LENGTH : IEEE80211_PTK_CCMP_LENGTH; 188 size_t iters = ((result_length * 8) + 159) / 160; 187 size_t iters = ((output_size * 8) + 159) / 160; 189 188 190 189 const char *a = "Pairwise key expansion"; 191 uint8_t result[ hash_sel*iters];192 uint8_t temp[ hash_sel];190 uint8_t result[HASH_SHA1*iters]; 191 uint8_t temp[HASH_SHA1]; 193 192 size_t data_size = PRF_CRYPT_DATA_LENGTH + str_size(a) + 2; 194 193 uint8_t work_arr[data_size]; … … 201 200 memcpy(work_arr + data_size - 1, &i, 1); 202 201 hmac(key, PBKDF2_KEY_LENGTH, work_arr, data_size, temp, 203 hash_sel); 204 memcpy(result + i*hash_sel, temp, hash_sel); 205 } 206 207 memcpy(hash, result, result_length); 208 209 return EOK; 202 HASH_SHA1); 203 memcpy(result + i*HASH_SHA1, temp, HASH_SHA1); 204 } 205 206 memcpy(hash, result, output_size); 207 208 return EOK; 209 } 210 211 int ieee80211_rc4_key_unwrap(uint8_t *key, uint8_t *data, size_t data_size, 212 uint8_t *output) 213 { 214 return rc4(key, 32, data, data_size, 256, output); 210 215 } 211 216 … … 230 235 231 236 memcpy(work_data, data + 8, n*8); 232 for(int j = 5; j >= 0; j--) {237 for(int j = 5; j >= 0; j--) { 233 238 for(int i = n; i > 0; i--) { 234 239 for(size_t k = 0; k < 8; k++) {
Note:
See TracChangeset
for help on using the changeset viewer.