]> git.ipfire.org Git - thirdparty/hostap.git/blobdiff - wpa_supplicant/eapol_test.c
EAP: Increase the maximum number of message exchanges
[thirdparty/hostap.git] / wpa_supplicant / eapol_test.c
index 1aede79a24534371e5303b1fcf49a8c1ae3a353d..524724f19735d990664b719a7c6d888f61b2bd9d 100644 (file)
@@ -15,6 +15,7 @@
 #include "common.h"
 #include "utils/ext_password.h"
 #include "common/version.h"
+#include "crypto/tls.h"
 #include "config.h"
 #include "eapol_supp/eapol_supp_sm.h"
 #include "eap_peer/eap.h"
@@ -258,6 +259,13 @@ static void ieee802_1x_encapsulate_radius(struct eapol_test_data *e,
                goto fail;
        }
 
+       if (!find_extra_attr(e->extra_attrs, RADIUS_ATTR_SERVICE_TYPE) &&
+           !radius_msg_add_attr_int32(msg, RADIUS_ATTR_SERVICE_TYPE,
+                                      RADIUS_SERVICE_TYPE_FRAMED)) {
+               printf("Could not add Service-Type\n");
+               goto fail;
+       }
+
        os_snprintf(buf, sizeof(buf), "%s", e->connect_info);
        if (!find_extra_attr(e->extra_attrs, RADIUS_ATTR_CONNECT_INFO) &&
            !radius_msg_add_attr(msg, RADIUS_ATTR_CONNECT_INFO,
@@ -490,45 +498,40 @@ static void eapol_test_eap_param_needed(void *ctx, enum wpa_ctrl_req_type field,
 #endif /* CONFIG_CTRL_IFACE || !CONFIG_NO_STDOUT_DEBUG */
 
 
-static void eapol_test_cert_cb(void *ctx, int depth, const char *subject,
-                              const char *altsubject[], int num_altsubject,
-                              const char *cert_hash,
-                              const struct wpabuf *cert)
+static void eapol_test_cert_cb(void *ctx, struct tls_cert_data *cert,
+                              const char *cert_hash)
 {
        struct eapol_test_data *e = ctx;
+       int i;
 
        wpa_msg(e->wpa_s, MSG_INFO, WPA_EVENT_EAP_PEER_CERT
                "depth=%d subject='%s'%s%s",
-               depth, subject,
+               cert->depth, cert->subject,
                cert_hash ? " hash=" : "",
                cert_hash ? cert_hash : "");
 
-       if (cert) {
+       if (cert->cert) {
                char *cert_hex;
-               size_t len = wpabuf_len(cert) * 2 + 1;
+               size_t len = wpabuf_len(cert->cert) * 2 + 1;
                cert_hex = os_malloc(len);
                if (cert_hex) {
-                       wpa_snprintf_hex(cert_hex, len, wpabuf_head(cert),
-                                        wpabuf_len(cert));
+                       wpa_snprintf_hex(cert_hex, len, wpabuf_head(cert->cert),
+                                        wpabuf_len(cert->cert));
                        wpa_msg_ctrl(e->wpa_s, MSG_INFO,
                                     WPA_EVENT_EAP_PEER_CERT
                                     "depth=%d subject='%s' cert=%s",
-                                    depth, subject, cert_hex);
+                                    cert->depth, cert->subject, cert_hex);
                        os_free(cert_hex);
                }
 
                if (e->server_cert_file)
                        eapol_test_write_cert(e->server_cert_file,
-                                             subject, cert);
+                                             cert->subject, cert->cert);
        }
 
-       if (altsubject) {
-               int i;
-
-               for (i = 0; i < num_altsubject; i++)
-                       wpa_msg(e->wpa_s, MSG_INFO, WPA_EVENT_EAP_PEER_ALT
-                               "depth=%d %s", depth, altsubject[i]);
-       }
+       for (i = 0; i < cert->num_altsubject; i++)
+               wpa_msg(e->wpa_s, MSG_INFO, WPA_EVENT_EAP_PEER_ALT
+                       "depth=%d %s", cert->depth, cert->altsubject[i]);
 }
 
 
@@ -704,7 +707,8 @@ static void send_eap_request_identity(void *eloop_ctx, void *timeout_ctx)
 
        eap = (struct eap_hdr *) (hdr + 1);
        eap->code = EAP_CODE_REQUEST;
-       eap->identifier = 0;
+       if (os_get_random((u8 *) &eap->identifier, sizeof(eap->identifier)) < 0)
+               eap->identifier = os_random() & 0xff;
        eap->length = htons(5);
        pos = (u8 *) (eap + 1);
        *pos = EAP_TYPE_IDENTITY;