~ubuntu-branches/ubuntu/wily/wpasupplicant/wily

« back to all changes in this revision

Viewing changes to src/rsn_supp/wpa.c

  • Committer: Bazaar Package Importer
  • Author(s): Kel Modderman
  • Date: 2010-02-27 11:30:53 UTC
  • mfrom: (5.1.2 sid)
  • Revision ID: james.westby@ubuntu.com-20100227113053-axxieaw3hmuqbqls
Tags: 0.6.10-2
* Switch to source format 3.0 (quilt), drop quilt build dependency
  and remove '--with quilt' from dh command in debian/rules.
* Fix "FTBFS on kfreebsd-gnu" with addition of 21_kfreebsd.patch.
  Thanks to work by Stefan Lippers-Hollmann and Petr Salinger.
  (Closes: #480572)
* Disable experimental feature CONFIG_IEEE80211W (management frame
  protection) due to it not being supported by any driver but ath9k
  and it generating ioctl errors which cause much concern among users
  for little to no benefit.
* Add traling blank line to debian/NEWS to assist apt-listchanges as
  per lintian advice.
* Cherry pick 30_cfg80211_association_optimisation.patch from upstream
  git. Add cfg80211-specific optimization to avoid silly behavior.

Show diffs side-by-side

added added

removed removed

Lines of Context:
358
358
                          const struct wpa_eapol_key *key,
359
359
                          struct wpa_ptk *ptk)
360
360
{
 
361
        size_t ptk_len = sm->pairwise_cipher == WPA_CIPHER_CCMP ? 48 : 64;
361
362
#ifdef CONFIG_IEEE80211R
362
363
        if (wpa_key_mgmt_ft(sm->key_mgmt))
363
 
                return wpa_derive_ptk_ft(sm, src_addr, key, ptk);
 
364
                return wpa_derive_ptk_ft(sm, src_addr, key, ptk, ptk_len);
364
365
#endif /* CONFIG_IEEE80211R */
365
366
 
366
367
        wpa_pmk_to_ptk(sm->pmk, sm->pmk_len, "Pairwise key expansion",
367
368
                       sm->own_addr, sm->bssid, sm->snonce, key->key_nonce,
368
 
                       (u8 *) ptk, sizeof(*ptk),
 
369
                       (u8 *) ptk, ptk_len,
369
370
                       wpa_key_mgmt_sha256(sm->key_mgmt));
370
371
        return 0;
371
372
}
407
408
#endif /* CONFIG_NO_WPA2 */
408
409
 
409
410
        if (wpa_supplicant_get_pmk(sm, src_addr, ie.pmkid))
410
 
                return;
 
411
                goto failed;
411
412
 
412
413
        if (sm->renew_snonce) {
413
414
                if (os_get_random(sm->snonce, WPA_NONCE_LEN)) {
414
415
                        wpa_msg(sm->ctx->ctx, MSG_WARNING,
415
416
                                "WPA: Failed to get random data for SNonce");
416
 
                        return;
 
417
                        goto failed;
417
418
                }
418
419
                sm->renew_snonce = 0;
419
420
                wpa_hexdump(MSG_DEBUG, "WPA: Renewed SNonce",
433
434
        if (wpa_supplicant_send_2_of_4(sm, sm->bssid, key, ver, sm->snonce,
434
435
                                       sm->assoc_wpa_ie, sm->assoc_wpa_ie_len,
435
436
                                       ptk))
436
 
                return;
 
437
                goto failed;
437
438
 
438
439
        os_memcpy(sm->anonce, key->key_nonce, WPA_NONCE_LEN);
 
440
        return;
 
441
 
 
442
failed:
 
443
        wpa_sm_deauthenticate(sm, WLAN_REASON_UNSPECIFIED);
439
444
}
440
445
 
441
446
 
537
542
        if (wpa_sm_set_key(sm, alg, sm->bssid, 0, 1, key_rsc, rsclen,
538
543
                           (u8 *) sm->ptk.tk1, keylen) < 0) {
539
544
                wpa_printf(MSG_WARNING, "WPA: Failed to set PTK to the "
540
 
                           "driver.");
 
545
                           "driver (alg=%d keylen=%d bssid=" MACSTR ")",
 
546
                           alg, keylen, MAC2STR(sm->bssid));
541
547
                return -1;
542
548
        }
543
549
 
647
653
                                  gd->keyidx, gd->tx, key_rsc, gd->key_rsc_len,
648
654
                                  _gtk, gd->gtk_len) < 0) {
649
655
                wpa_printf(MSG_WARNING, "WPA: Failed to set GTK to "
650
 
                           "the driver.");
 
656
                           "the driver (alg=%d keylen=%d keyidx=%d)",
 
657
                           gd->alg, gd->gtk_len, gd->keyidx);
651
658
                return -1;
652
659
        }
653
660
 
944
951
        wpa_supplicant_parse_ies(pos, len, &ie);
945
952
        if (ie.gtk && !(key_info & WPA_KEY_INFO_ENCR_KEY_DATA)) {
946
953
                wpa_printf(MSG_WARNING, "WPA: GTK IE in unencrypted key data");
947
 
                return;
 
954
                goto failed;
948
955
        }
949
956
#ifdef CONFIG_IEEE80211W
950
957
        if (ie.igtk && !(key_info & WPA_KEY_INFO_ENCR_KEY_DATA)) {
951
958
                wpa_printf(MSG_WARNING, "WPA: IGTK KDE in unencrypted key "
952
959
                           "data");
953
 
                return;
 
960
                goto failed;
954
961
        }
955
962
 
956
963
        if (ie.igtk && ie.igtk_len != sizeof(struct wpa_igtk_kde)) {
957
964
                wpa_printf(MSG_WARNING, "WPA: Invalid IGTK KDE length %lu",
958
965
                           (unsigned long) ie.igtk_len);
959
 
                return;
 
966
                goto failed;
960
967
        }
961
968
#endif /* CONFIG_IEEE80211W */
962
969
 
963
970
        if (wpa_supplicant_validate_ie(sm, sm->bssid, &ie) < 0)
964
 
                return;
 
971
                goto failed;
965
972
 
966
973
        if (os_memcmp(sm->anonce, key->key_nonce, WPA_NONCE_LEN) != 0) {
967
974
                wpa_printf(MSG_WARNING, "WPA: ANonce from message 1 of 4-Way "
968
975
                           "Handshake differs from 3 of 4-Way Handshake - drop"
969
976
                           " packet (src=" MACSTR ")", MAC2STR(sm->bssid));
970
 
                return;
 
977
                goto failed;
971
978
        }
972
979
 
973
980
        keylen = WPA_GET_BE16(key->key_length);
977
984
                        wpa_printf(MSG_WARNING, "WPA: Invalid CCMP key length "
978
985
                                   "%d (src=" MACSTR ")",
979
986
                                   keylen, MAC2STR(sm->bssid));
980
 
                        return;
 
987
                        goto failed;
981
988
                }
982
989
                break;
983
990
        case WPA_CIPHER_TKIP:
985
992
                        wpa_printf(MSG_WARNING, "WPA: Invalid TKIP key length "
986
993
                                   "%d (src=" MACSTR ")",
987
994
                                   keylen, MAC2STR(sm->bssid));
988
 
                        return;
 
995
                        goto failed;
989
996
                }
990
997
                break;
991
998
        }
992
999
 
993
1000
        if (wpa_supplicant_send_4_of_4(sm, sm->bssid, key, ver, key_info,
994
 
                                       NULL, 0, &sm->ptk))
995
 
                return;
 
1001
                                       NULL, 0, &sm->ptk)) {
 
1002
                goto failed;
 
1003
        }
996
1004
 
997
1005
        /* SNonce was successfully used in msg 3/4, so mark it to be renewed
998
1006
         * for the next 4-Way Handshake. If msg 3 is received again, the old
1000
1008
        sm->renew_snonce = 1;
1001
1009
 
1002
1010
        if (key_info & WPA_KEY_INFO_INSTALL) {
1003
 
                wpa_supplicant_install_ptk(sm, key);
 
1011
                if (wpa_supplicant_install_ptk(sm, key))
 
1012
                        goto failed;
1004
1013
        }
1005
1014
 
1006
1015
        if (key_info & WPA_KEY_INFO_SECURE) {
1015
1024
            wpa_supplicant_pairwise_gtk(sm, key,
1016
1025
                                        ie.gtk, ie.gtk_len, key_info) < 0) {
1017
1026
                wpa_printf(MSG_INFO, "RSN: Failed to configure GTK");
 
1027
                goto failed;
1018
1028
        }
1019
1029
 
1020
 
        if (ieee80211w_set_keys(sm, &ie) < 0)
 
1030
        if (ieee80211w_set_keys(sm, &ie) < 0) {
1021
1031
                wpa_printf(MSG_INFO, "RSN: Failed to configure IGTK");
 
1032
                goto failed;
 
1033
        }
 
1034
 
 
1035
        return;
 
1036
 
 
1037
failed:
 
1038
        wpa_sm_deauthenticate(sm, WLAN_REASON_UNSPECIFIED);
1022
1039
}
1023
1040
 
1024
1041
 
1209
1226
        wpa_sm_set_state(sm, WPA_GROUP_HANDSHAKE);
1210
1227
 
1211
1228
        if (ret)
1212
 
                return;
 
1229
                goto failed;
1213
1230
 
1214
1231
        if (wpa_supplicant_install_gtk(sm, &gd, key->key_rsc) ||
1215
1232
            wpa_supplicant_send_2_of_2(sm, key, ver, key_info))
1216
 
                return;
 
1233
                goto failed;
1217
1234
 
1218
1235
        if (rekey) {
1219
1236
                wpa_msg(sm->ctx->ctx, MSG_INFO, "WPA: Group rekeying "
1226
1243
                                                key_info &
1227
1244
                                                WPA_KEY_INFO_SECURE);
1228
1245
        }
 
1246
        return;
 
1247
 
 
1248
failed:
 
1249
        wpa_sm_deauthenticate(sm, WLAN_REASON_UNSPECIFIED);
1229
1250
}
1230
1251
 
1231
1252