Ignore:
Timestamp:
2015-04-13T20:48:33Z (9 years ago)
Author:
Jan Kolarik <kolarik@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
cc575ef9
Parents:
053fc2b
Message:

Added TKIP support, handling old WPA in 4way handshake, some fixes in wifi_supplicant app

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/ieee80211/src/ieee80211_impl.c

    r053fc2b ra931b7b  
    165165
    166166/**
    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.
    168169 *
    169170 * @param key Key with PBKDF2 encrypted passphrase.
    170171 * @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.
    173174 *
    174175 * @return EINVAL when key or data not specified, ENOMEM when pointer for
     
    176177 */
    177178int ieee80211_prf(uint8_t *key, uint8_t *data, uint8_t *hash,
    178         hash_func_t hash_sel)
     179        size_t output_size)
    179180{
    180181        if(!key || !data)
     
    184185                return ENOMEM;
    185186       
    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;
    189188       
    190189        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];
    193192        size_t data_size = PRF_CRYPT_DATA_LENGTH + str_size(a) + 2;
    194193        uint8_t work_arr[data_size];
     
    201200                memcpy(work_arr + data_size - 1, &i, 1);
    202201                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
     211int 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);
    210215}
    211216
     
    230235       
    231236        memcpy(work_data, data + 8, n*8);
    232         for(int j = 5; j >=0; j--) {
     237        for(int j = 5; j >= 0; j--) {
    233238                for(int i = n; i > 0; i--) {
    234239                        for(size_t k = 0; k < 8; k++) {
Note: See TracChangeset for help on using the changeset viewer.