Changeset 8565a42 in mainline for uspace/lib/ieee80211/src/ieee80211_impl.c
- Timestamp:
- 2018-03-02T20:34:50Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- a1a81f69, d5e5fd1
- Parents:
- 3061bc1 (diff), 34e1206 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - git-author:
- Jiří Zárevúcky <zarevucky.jiri@…> (2018-03-02 20:34:50)
- git-committer:
- GitHub <noreply@…> (2018-03-02 20:34:50)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/ieee80211/src/ieee80211_impl.c
r3061bc1 r8565a42 119 119 { 120 120 fibril_mutex_lock(&ieee80211_dev->scan_mutex); 121 121 122 122 if (ieee80211_get_auth_phase(ieee80211_dev) == 123 123 IEEE80211_AUTH_DISCONNECTED) { 124 124 fibril_mutex_lock(&ieee80211_dev->ap_list.results_mutex); 125 125 126 126 /* Remove old entries we don't receive beacons from. */ 127 127 ieee80211_scan_result_list_t *result_list = 128 128 &ieee80211_dev->ap_list; 129 129 130 130 list_foreach_safe(result_list->list, cur_link, next_link) { 131 131 ieee80211_scan_result_link_t *cur_result = 132 132 list_get_instance(cur_link, 133 133 ieee80211_scan_result_link_t, link); 134 134 135 135 if ((time(NULL) - cur_result->last_beacon) > 136 136 MAX_KEEP_SCAN_SPAN_SEC) … … 138 138 cur_result); 139 139 } 140 140 141 141 fibril_mutex_unlock(&ieee80211_dev->ap_list.results_mutex); 142 142 143 143 uint16_t orig_freq = ieee80211_dev->current_freq; 144 144 145 145 for (uint16_t freq = IEEE80211_FIRST_FREQ; 146 146 freq <= IEEE80211_MAX_FREQ; freq += IEEE80211_CHANNEL_GAP) { 147 147 if (ieee80211_pending_connect_request(ieee80211_dev)) 148 148 break; 149 149 150 150 ieee80211_dev->ops->set_freq(ieee80211_dev, freq); 151 151 ieee80211_probe_request(ieee80211_dev, NULL); 152 152 153 153 /* Wait for probe responses. */ 154 154 async_usleep(SCAN_CHANNEL_WAIT_USEC); 155 155 } 156 156 157 157 ieee80211_dev->ops->set_freq(ieee80211_dev, orig_freq); 158 158 } 159 159 160 160 fibril_mutex_unlock(&ieee80211_dev->scan_mutex); 161 161 162 162 return EOK; 163 163 } … … 183 183 if ((!key) || (!data)) 184 184 return EINVAL; 185 185 186 186 if (!hash) 187 187 return ENOMEM; 188 188 189 189 size_t iters = ((output_size * 8) + 159) / 160; 190 190 191 191 const char *a = "Pairwise key expansion"; 192 192 uint8_t result[HASH_SHA1 * iters]; 193 193 uint8_t temp[HASH_SHA1]; 194 194 195 195 size_t data_size = PRF_CRYPT_DATA_LENGTH + str_size(a) + 2; 196 196 uint8_t work_arr[data_size]; 197 197 memset(work_arr, 0, data_size); 198 198 199 199 memcpy(work_arr, a, str_size(a)); 200 200 memcpy(work_arr + str_size(a) + 1, data, PRF_CRYPT_DATA_LENGTH); 201 201 202 202 for (uint8_t i = 0; i < iters; i++) { 203 203 memcpy(work_arr + data_size - 1, &i, 1); … … 206 206 memcpy(result + i*HASH_SHA1, temp, HASH_SHA1); 207 207 } 208 208 209 209 memcpy(hash, result, output_size); 210 210 211 211 return EOK; 212 212 } … … 223 223 if ((!kek) || (!data)) 224 224 return EINVAL; 225 225 226 226 if (!output) 227 227 return ENOMEM; 228 228 229 229 uint32_t n = data_size / 8 - 1; 230 230 uint8_t work_data[n * 8]; … … 233 233 uint8_t *work_block; 234 234 uint8_t a[8]; 235 235 236 236 memcpy(a, data, 8); 237 237 238 238 uint64_t mask = 0xff; 239 239 uint8_t shift, shb; 240 240 241 241 memcpy(work_data, data + 8, n * 8); 242 242 for (int j = 5; j >= 0; j--) { … … 247 247 a[k] ^= shb; 248 248 } 249 249 250 250 work_block = work_data + (i - 1) * 8; 251 251 memcpy(work_input, a, 8); … … 256 256 } 257 257 } 258 258 259 259 size_t it; 260 260 for (it = 0; it < 8; it++) { … … 262 262 break; 263 263 } 264 264 265 265 if (it == 8) { 266 266 memcpy(output, work_data, n * 8); 267 267 return EOK; 268 268 } 269 269 270 270 return EINVAL; 271 271 } … … 290 290 if ((!key) || (!buffer)) 291 291 return EINVAL; 292 292 293 293 if (!mic) 294 294 return ENOMEM; 295 295 296 296 uint32_t l = uint32le_from_seq(key); 297 297 uint32_t r = uint32le_from_seq(key + 4); 298 298 299 299 ieee80211_data_header_t *data_header = 300 300 (ieee80211_data_header_t *) buffer; 301 301 302 302 uint8_t *data = buffer + sizeof(ieee80211_data_header_t) + 303 303 IEEE80211_TKIP_HEADER_LENGTH; 304 304 size_t data_size = size - sizeof(ieee80211_data_header_t) - 305 305 IEEE80211_TKIP_HEADER_LENGTH; 306 306 307 307 /* Process header. */ 308 308 uint8_t *src_addr = … … 312 312 ieee80211_is_tods_frame(data_header->frame_ctrl) ? 313 313 data_header->address3 : data_header->address1; 314 314 315 315 ieee80211_michael_mic_block(&l, &r, uint32le_from_seq(dest_addr)); 316 316 ieee80211_michael_mic_block(&l, &r, … … 319 319 ieee80211_michael_mic_block(&l, &r, uint32le_from_seq(src_addr + 2)); 320 320 ieee80211_michael_mic_block(&l, &r, 0); 321 321 322 322 /* Process data. */ 323 323 size_t blocks = data_size / 4; 324 324 size_t pad = data_size % 4; 325 325 326 326 for (size_t k = 0; k < blocks; k++) { 327 327 ieee80211_michael_mic_block(&l, &r, 328 328 uint32le_from_seq(&data[k * 4])); 329 329 } 330 330 331 331 /* Add padding. */ 332 332 uint32_t value = 0x5a; … … 335 335 value |= data[blocks * 4 + (i - 1)]; 336 336 } 337 337 338 338 ieee80211_michael_mic_block(&l, &r, value); 339 339 ieee80211_michael_mic_block(&l, &r, 0); 340 340 341 341 l = host2uint32_t_le(l); 342 342 r = host2uint32_t_le(r); 343 343 344 344 memcpy(mic, &l, 4); 345 345 memcpy(mic + 4, &r, 4); 346 346 347 347 return EOK; 348 348 } … … 376 376 if (!sequence) 377 377 return ENOMEM; 378 378 379 379 for (size_t i = 0; i < length; i++) 380 380 sequence[i] = (uint8_t) rand(); 381 381 382 382 return EOK; 383 383 } … … 387 387 if ((!seq1) || (!seq2)) 388 388 return NULL; 389 389 390 390 for (size_t i = 0; i < size; i++) { 391 391 if (seq1[i] < seq2[i]) … … 394 394 return seq2; 395 395 } 396 396 397 397 return seq1; 398 398 } … … 403 403 if (min == seq1) 404 404 return seq2; 405 405 406 406 return seq1; 407 407 }
Note:
See TracChangeset
for help on using the changeset viewer.