123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020 |
- #include "includes.h"
- #include "common.h"
- #include "crypto/sha1.h"
- #include "crypto/tls.h"
- #include "eap_i.h"
- #include "eap_tls_common.h"
- #include "eap_config.h"
- static int eap_tls_check_blob(struct eap_sm *sm, const char **name,
- const u8 **data, size_t *data_len)
- {
- const struct wpa_config_blob *blob;
- if (*name == NULL || os_strncmp(*name, "blob://", 7) != 0)
- return 0;
- blob = eap_get_config_blob(sm, *name + 7);
- if (blob == NULL) {
- wpa_printf(MSG_ERROR, "%s: Named configuration blob '%s' not "
- "found", __func__, *name + 7);
- return -1;
- }
- *name = NULL;
- *data = blob->data;
- *data_len = blob->len;
- return 0;
- }
- static void eap_tls_params_flags(struct tls_connection_params *params,
- const char *txt)
- {
- if (txt == NULL)
- return;
- if (os_strstr(txt, "tls_allow_md5=1"))
- params->flags |= TLS_CONN_ALLOW_SIGN_RSA_MD5;
- if (os_strstr(txt, "tls_disable_time_checks=1"))
- params->flags |= TLS_CONN_DISABLE_TIME_CHECKS;
- }
- static void eap_tls_params_from_conf1(struct tls_connection_params *params,
- struct eap_peer_config *config)
- {
- params->ca_cert = (char *) config->ca_cert;
- params->ca_path = (char *) config->ca_path;
- params->client_cert = (char *) config->client_cert;
- params->private_key = (char *) config->private_key;
- params->private_key_passwd = (char *) config->private_key_passwd;
- params->dh_file = (char *) config->dh_file;
- params->subject_match = (char *) config->subject_match;
- params->altsubject_match = (char *) config->altsubject_match;
- params->engine = config->engine;
- params->engine_id = config->engine_id;
- params->pin = config->pin;
- params->key_id = config->key_id;
- params->cert_id = config->cert_id;
- params->ca_cert_id = config->ca_cert_id;
- eap_tls_params_flags(params, config->phase1);
- }
- static void eap_tls_params_from_conf2(struct tls_connection_params *params,
- struct eap_peer_config *config)
- {
- params->ca_cert = (char *) config->ca_cert2;
- params->ca_path = (char *) config->ca_path2;
- params->client_cert = (char *) config->client_cert2;
- params->private_key = (char *) config->private_key2;
- params->private_key_passwd = (char *) config->private_key2_passwd;
- params->dh_file = (char *) config->dh_file2;
- params->subject_match = (char *) config->subject_match2;
- params->altsubject_match = (char *) config->altsubject_match2;
- params->engine = config->engine2;
- params->engine_id = config->engine2_id;
- params->pin = config->pin2;
- params->key_id = config->key2_id;
- params->cert_id = config->cert2_id;
- params->ca_cert_id = config->ca_cert2_id;
- eap_tls_params_flags(params, config->phase2);
- }
- static int eap_tls_params_from_conf(struct eap_sm *sm,
- struct eap_ssl_data *data,
- struct tls_connection_params *params,
- struct eap_peer_config *config, int phase2)
- {
- os_memset(params, 0, sizeof(*params));
- if (phase2) {
- wpa_printf(MSG_DEBUG, "TLS: using phase2 config options");
- eap_tls_params_from_conf2(params, config);
- } else {
- wpa_printf(MSG_DEBUG, "TLS: using phase1 config options");
- eap_tls_params_from_conf1(params, config);
- }
-
- if (eap_tls_check_blob(sm, ¶ms->ca_cert, ¶ms->ca_cert_blob,
- ¶ms->ca_cert_blob_len) ||
- eap_tls_check_blob(sm, ¶ms->client_cert,
- ¶ms->client_cert_blob,
- ¶ms->client_cert_blob_len) ||
- eap_tls_check_blob(sm, ¶ms->private_key,
- ¶ms->private_key_blob,
- ¶ms->private_key_blob_len) ||
- eap_tls_check_blob(sm, ¶ms->dh_file, ¶ms->dh_blob,
- ¶ms->dh_blob_len)) {
- wpa_printf(MSG_INFO, "SSL: Failed to get configuration blobs");
- return -1;
- }
- return 0;
- }
- static int eap_tls_init_connection(struct eap_sm *sm,
- struct eap_ssl_data *data,
- struct eap_peer_config *config,
- struct tls_connection_params *params)
- {
- int res;
- data->conn = tls_connection_init(sm->ssl_ctx);
- if (data->conn == NULL) {
- wpa_printf(MSG_INFO, "SSL: Failed to initialize new TLS "
- "connection");
- return -1;
- }
- res = tls_connection_set_params(sm->ssl_ctx, data->conn, params);
- if (res == TLS_SET_PARAMS_ENGINE_PRV_INIT_FAILED) {
-
- os_free(config->pin);
- config->pin = NULL;
- } else if (res == TLS_SET_PARAMS_ENGINE_PRV_VERIFY_FAILED) {
- wpa_printf(MSG_INFO, "TLS: Failed to load private key");
-
- os_free(config->pin);
- config->pin = NULL;
- eap_sm_request_pin(sm);
- sm->ignore = TRUE;
- tls_connection_deinit(sm->ssl_ctx, data->conn);
- data->conn = NULL;
- return -1;
- } else if (res) {
- wpa_printf(MSG_INFO, "TLS: Failed to set TLS connection "
- "parameters");
- tls_connection_deinit(sm->ssl_ctx, data->conn);
- data->conn = NULL;
- return -1;
- }
- return 0;
- }
- int eap_peer_tls_ssl_init(struct eap_sm *sm, struct eap_ssl_data *data,
- struct eap_peer_config *config)
- {
- struct tls_connection_params params;
- if (config == NULL)
- return -1;
- data->eap = sm;
- data->phase2 = sm->init_phase2;
- if (eap_tls_params_from_conf(sm, data, ¶ms, config, data->phase2) <
- 0)
- return -1;
- if (eap_tls_init_connection(sm, data, config, ¶ms) < 0)
- return -1;
- data->tls_out_limit = config->fragment_size;
- if (data->phase2) {
-
- if (data->tls_out_limit > 100)
- data->tls_out_limit -= 100;
- }
- if (config->phase1 &&
- os_strstr(config->phase1, "include_tls_length=1")) {
- wpa_printf(MSG_DEBUG, "TLS: Include TLS Message Length in "
- "unfragmented packets");
- data->include_tls_length = 1;
- }
- return 0;
- }
- void eap_peer_tls_ssl_deinit(struct eap_sm *sm, struct eap_ssl_data *data)
- {
- tls_connection_deinit(sm->ssl_ctx, data->conn);
- eap_peer_tls_reset_input(data);
- eap_peer_tls_reset_output(data);
- }
- u8 * eap_peer_tls_derive_key(struct eap_sm *sm, struct eap_ssl_data *data,
- const char *label, size_t len)
- {
- struct tls_keys keys;
- u8 *rnd = NULL, *out;
- out = os_malloc(len);
- if (out == NULL)
- return NULL;
-
- if (tls_connection_prf(sm->ssl_ctx, data->conn, label, 0, out, len) ==
- 0)
- return out;
-
- if (tls_connection_get_keys(sm->ssl_ctx, data->conn, &keys))
- goto fail;
- if (keys.client_random == NULL || keys.server_random == NULL ||
- keys.master_key == NULL)
- goto fail;
- rnd = os_malloc(keys.client_random_len + keys.server_random_len);
- if (rnd == NULL)
- goto fail;
- os_memcpy(rnd, keys.client_random, keys.client_random_len);
- os_memcpy(rnd + keys.client_random_len, keys.server_random,
- keys.server_random_len);
- if (tls_prf(keys.master_key, keys.master_key_len,
- label, rnd, keys.client_random_len +
- keys.server_random_len, out, len))
- goto fail;
- os_free(rnd);
- return out;
- fail:
- os_free(out);
- os_free(rnd);
- return NULL;
- }
- static int eap_peer_tls_reassemble_fragment(struct eap_ssl_data *data,
- const struct wpabuf *in_data)
- {
- size_t tls_in_len, in_len;
- tls_in_len = data->tls_in ? wpabuf_len(data->tls_in) : 0;
- in_len = in_data ? wpabuf_len(in_data) : 0;
- if (tls_in_len + in_len == 0) {
-
- wpa_printf(MSG_WARNING, "SSL: Invalid reassembly state: "
- "tls_in_left=%lu tls_in_len=%lu in_len=%lu",
- (unsigned long) data->tls_in_left,
- (unsigned long) tls_in_len,
- (unsigned long) in_len);
- eap_peer_tls_reset_input(data);
- return -1;
- }
- if (tls_in_len + in_len > 65536) {
-
- wpa_printf(MSG_INFO, "SSL: Too long TLS fragment (size over "
- "64 kB)");
- eap_peer_tls_reset_input(data);
- return -1;
- }
- if (in_len > data->tls_in_left) {
-
- wpa_printf(MSG_INFO, "SSL: more data than TLS message length "
- "indicated");
- eap_peer_tls_reset_input(data);
- return -1;
- }
- if (wpabuf_resize(&data->tls_in, in_len) < 0) {
- wpa_printf(MSG_INFO, "SSL: Could not allocate memory for TLS "
- "data");
- eap_peer_tls_reset_input(data);
- return -1;
- }
- if (in_data)
- wpabuf_put_buf(data->tls_in, in_data);
- data->tls_in_left -= in_len;
- if (data->tls_in_left > 0) {
- wpa_printf(MSG_DEBUG, "SSL: Need %lu bytes more input "
- "data", (unsigned long) data->tls_in_left);
- return 1;
- }
- return 0;
- }
- static const struct wpabuf * eap_peer_tls_data_reassemble(
- struct eap_ssl_data *data, const struct wpabuf *in_data,
- int *need_more_input)
- {
- *need_more_input = 0;
- if (data->tls_in_left > wpabuf_len(in_data) || data->tls_in) {
-
- int res = eap_peer_tls_reassemble_fragment(data, in_data);
- if (res) {
- if (res == 1)
- *need_more_input = 1;
- return NULL;
- }
-
- } else {
-
- data->tls_in_left = 0;
- data->tls_in = wpabuf_dup(in_data);
- if (data->tls_in == NULL)
- return NULL;
- }
- return data->tls_in;
- }
- static int eap_tls_process_input(struct eap_sm *sm, struct eap_ssl_data *data,
- const u8 *in_data, size_t in_len,
- struct wpabuf **out_data)
- {
- const struct wpabuf *msg;
- int need_more_input;
- struct wpabuf *appl_data;
- struct wpabuf buf;
- wpabuf_set(&buf, in_data, in_len);
- msg = eap_peer_tls_data_reassemble(data, &buf, &need_more_input);
- if (msg == NULL)
- return need_more_input ? 1 : -1;
-
- if (data->tls_out) {
-
- wpa_printf(MSG_INFO, "SSL: eap_tls_process_input - pending "
- "tls_out data even though tls_out_len = 0");
- wpabuf_free(data->tls_out);
- WPA_ASSERT(data->tls_out == NULL);
- }
- appl_data = NULL;
- data->tls_out = tls_connection_handshake(sm->ssl_ctx, data->conn,
- msg, &appl_data);
- eap_peer_tls_reset_input(data);
- if (appl_data &&
- tls_connection_established(sm->ssl_ctx, data->conn) &&
- !tls_connection_get_failed(sm->ssl_ctx, data->conn)) {
- wpa_hexdump_buf_key(MSG_MSGDUMP, "SSL: Application data",
- appl_data);
- *out_data = appl_data;
- return 2;
- }
- wpabuf_free(appl_data);
- return 0;
- }
- static int eap_tls_process_output(struct eap_ssl_data *data, EapType eap_type,
- int peap_version, u8 id, int ret,
- struct wpabuf **out_data)
- {
- size_t len;
- u8 *flags;
- int more_fragments, length_included;
- if (data->tls_out == NULL)
- return -1;
- len = wpabuf_len(data->tls_out) - data->tls_out_pos;
- wpa_printf(MSG_DEBUG, "SSL: %lu bytes left to be sent out (of total "
- "%lu bytes)",
- (unsigned long) len,
- (unsigned long) wpabuf_len(data->tls_out));
-
- if (len > data->tls_out_limit) {
- more_fragments = 1;
- len = data->tls_out_limit;
- wpa_printf(MSG_DEBUG, "SSL: sending %lu bytes, more fragments "
- "will follow", (unsigned long) len);
- } else
- more_fragments = 0;
- length_included = data->tls_out_pos == 0 &&
- (wpabuf_len(data->tls_out) > data->tls_out_limit ||
- data->include_tls_length);
- if (!length_included &&
- eap_type == EAP_TYPE_PEAP && peap_version == 0 &&
- !tls_connection_established(data->eap->ssl_ctx, data->conn)) {
-
- length_included = 1;
- }
- *out_data = eap_msg_alloc(EAP_VENDOR_IETF, eap_type,
- 1 + length_included * 4 + len,
- EAP_CODE_RESPONSE, id);
- if (*out_data == NULL)
- return -1;
- flags = wpabuf_put(*out_data, 1);
- *flags = peap_version;
- if (more_fragments)
- *flags |= EAP_TLS_FLAGS_MORE_FRAGMENTS;
- if (length_included) {
- *flags |= EAP_TLS_FLAGS_LENGTH_INCLUDED;
- wpabuf_put_be32(*out_data, wpabuf_len(data->tls_out));
- }
- wpabuf_put_data(*out_data,
- wpabuf_head_u8(data->tls_out) + data->tls_out_pos,
- len);
- data->tls_out_pos += len;
- if (!more_fragments)
- eap_peer_tls_reset_output(data);
- return ret;
- }
- int eap_peer_tls_process_helper(struct eap_sm *sm, struct eap_ssl_data *data,
- EapType eap_type, int peap_version,
- u8 id, const u8 *in_data, size_t in_len,
- struct wpabuf **out_data)
- {
- int ret = 0;
- *out_data = NULL;
- if (data->tls_out && wpabuf_len(data->tls_out) > 0 && in_len > 0) {
- wpa_printf(MSG_DEBUG, "SSL: Received non-ACK when output "
- "fragments are waiting to be sent out");
- return -1;
- }
- if (data->tls_out == NULL || wpabuf_len(data->tls_out) == 0) {
-
- int res = eap_tls_process_input(sm, data, in_data, in_len,
- out_data);
- if (res) {
-
- return res;
- }
-
- }
- if (data->tls_out == NULL) {
-
- eap_peer_tls_reset_output(data);
- return -1;
- }
- if (tls_connection_get_failed(sm->ssl_ctx, data->conn)) {
-
- wpa_printf(MSG_DEBUG, "SSL: Failed - tls_out available to "
- "report error");
- ret = -1;
-
- }
- if (data->tls_out == NULL || wpabuf_len(data->tls_out) == 0) {
-
- wpa_printf(MSG_DEBUG, "SSL: No data to be sent out");
- wpabuf_free(data->tls_out);
- data->tls_out = NULL;
- return 1;
- }
-
- return eap_tls_process_output(data, eap_type, peap_version, id, ret,
- out_data);
- }
- struct wpabuf * eap_peer_tls_build_ack(u8 id, EapType eap_type,
- int peap_version)
- {
- struct wpabuf *resp;
- resp = eap_msg_alloc(EAP_VENDOR_IETF, eap_type, 1, EAP_CODE_RESPONSE,
- id);
- if (resp == NULL)
- return NULL;
- wpa_printf(MSG_DEBUG, "SSL: Building ACK (type=%d id=%d ver=%d)",
- (int) eap_type, id, peap_version);
- wpabuf_put_u8(resp, peap_version);
- return resp;
- }
- int eap_peer_tls_reauth_init(struct eap_sm *sm, struct eap_ssl_data *data)
- {
- eap_peer_tls_reset_input(data);
- eap_peer_tls_reset_output(data);
- return tls_connection_shutdown(sm->ssl_ctx, data->conn);
- }
- int eap_peer_tls_status(struct eap_sm *sm, struct eap_ssl_data *data,
- char *buf, size_t buflen, int verbose)
- {
- char name[128];
- int len = 0, ret;
- if (tls_get_cipher(sm->ssl_ctx, data->conn, name, sizeof(name)) == 0) {
- ret = os_snprintf(buf + len, buflen - len,
- "EAP TLS cipher=%s\n", name);
- if (ret < 0 || (size_t) ret >= buflen - len)
- return len;
- len += ret;
- }
- return len;
- }
- const u8 * eap_peer_tls_process_init(struct eap_sm *sm,
- struct eap_ssl_data *data,
- EapType eap_type,
- struct eap_method_ret *ret,
- const struct wpabuf *reqData,
- size_t *len, u8 *flags)
- {
- const u8 *pos;
- size_t left;
- unsigned int tls_msg_len;
- if (tls_get_errors(sm->ssl_ctx)) {
- wpa_printf(MSG_INFO, "SSL: TLS errors detected");
- ret->ignore = TRUE;
- return NULL;
- }
- pos = eap_hdr_validate(EAP_VENDOR_IETF, eap_type, reqData, &left);
- if (pos == NULL) {
- ret->ignore = TRUE;
- return NULL;
- }
- if (left == 0) {
- wpa_printf(MSG_DEBUG, "SSL: Invalid TLS message: no Flags "
- "octet included");
- if (!sm->workaround) {
- ret->ignore = TRUE;
- return NULL;
- }
- wpa_printf(MSG_DEBUG, "SSL: Workaround - assume no Flags "
- "indicates ACK frame");
- *flags = 0;
- } else {
- *flags = *pos++;
- left--;
- }
- wpa_printf(MSG_DEBUG, "SSL: Received packet(len=%lu) - "
- "Flags 0x%02x", (unsigned long) wpabuf_len(reqData),
- *flags);
- if (*flags & EAP_TLS_FLAGS_LENGTH_INCLUDED) {
- if (left < 4) {
- wpa_printf(MSG_INFO, "SSL: Short frame with TLS "
- "length");
- ret->ignore = TRUE;
- return NULL;
- }
- tls_msg_len = WPA_GET_BE32(pos);
- wpa_printf(MSG_DEBUG, "SSL: TLS Message Length: %d",
- tls_msg_len);
- if (data->tls_in_left == 0) {
- data->tls_in_total = tls_msg_len;
- data->tls_in_left = tls_msg_len;
- wpabuf_free(data->tls_in);
- data->tls_in = NULL;
- }
- pos += 4;
- left -= 4;
- }
- ret->ignore = FALSE;
- ret->methodState = METHOD_MAY_CONT;
- ret->decision = DECISION_FAIL;
- ret->allowNotifications = TRUE;
- *len = left;
- return pos;
- }
- void eap_peer_tls_reset_input(struct eap_ssl_data *data)
- {
- data->tls_in_left = data->tls_in_total = 0;
- wpabuf_free(data->tls_in);
- data->tls_in = NULL;
- }
- void eap_peer_tls_reset_output(struct eap_ssl_data *data)
- {
- data->tls_out_pos = 0;
- wpabuf_free(data->tls_out);
- data->tls_out = NULL;
- }
- int eap_peer_tls_decrypt(struct eap_sm *sm, struct eap_ssl_data *data,
- const struct wpabuf *in_data,
- struct wpabuf **in_decrypted)
- {
- const struct wpabuf *msg;
- int need_more_input;
- msg = eap_peer_tls_data_reassemble(data, in_data, &need_more_input);
- if (msg == NULL)
- return need_more_input ? 1 : -1;
- *in_decrypted = tls_connection_decrypt(sm->ssl_ctx, data->conn, msg);
- eap_peer_tls_reset_input(data);
- if (*in_decrypted == NULL) {
- wpa_printf(MSG_INFO, "SSL: Failed to decrypt Phase 2 data");
- return -1;
- }
- return 0;
- }
- int eap_peer_tls_encrypt(struct eap_sm *sm, struct eap_ssl_data *data,
- EapType eap_type, int peap_version, u8 id,
- const struct wpabuf *in_data,
- struct wpabuf **out_data)
- {
- if (in_data) {
- eap_peer_tls_reset_output(data);
- data->tls_out = tls_connection_encrypt(sm->ssl_ctx, data->conn,
- in_data);
- if (data->tls_out == NULL) {
- wpa_printf(MSG_INFO, "SSL: Failed to encrypt Phase 2 "
- "data (in_len=%lu)",
- (unsigned long) wpabuf_len(in_data));
- eap_peer_tls_reset_output(data);
- return -1;
- }
- }
- return eap_tls_process_output(data, eap_type, peap_version, id, 0,
- out_data);
- }
- int eap_peer_select_phase2_methods(struct eap_peer_config *config,
- const char *prefix,
- struct eap_method_type **types,
- size_t *num_types)
- {
- char *start, *pos, *buf;
- struct eap_method_type *methods = NULL, *_methods;
- u8 method;
- size_t num_methods = 0, prefix_len;
- if (config == NULL || config->phase2 == NULL)
- goto get_defaults;
- start = buf = os_strdup(config->phase2);
- if (buf == NULL)
- return -1;
- prefix_len = os_strlen(prefix);
- while (start && *start != '\0') {
- int vendor;
- pos = os_strstr(start, prefix);
- if (pos == NULL)
- break;
- if (start != pos && *(pos - 1) != ' ') {
- start = pos + prefix_len;
- continue;
- }
- start = pos + prefix_len;
- pos = os_strchr(start, ' ');
- if (pos)
- *pos++ = '\0';
- method = eap_get_phase2_type(start, &vendor);
- if (vendor == EAP_VENDOR_IETF && method == EAP_TYPE_NONE) {
- wpa_printf(MSG_ERROR, "TLS: Unsupported Phase2 EAP "
- "method '%s'", start);
- } else {
- num_methods++;
- _methods = os_realloc(methods,
- num_methods * sizeof(*methods));
- if (_methods == NULL) {
- os_free(methods);
- os_free(buf);
- return -1;
- }
- methods = _methods;
- methods[num_methods - 1].vendor = vendor;
- methods[num_methods - 1].method = method;
- }
- start = pos;
- }
- os_free(buf);
- get_defaults:
- if (methods == NULL)
- methods = eap_get_phase2_types(config, &num_methods);
- if (methods == NULL) {
- wpa_printf(MSG_ERROR, "TLS: No Phase2 EAP methods available");
- return -1;
- }
- wpa_hexdump(MSG_DEBUG, "TLS: Phase2 EAP types",
- (u8 *) methods,
- num_methods * sizeof(struct eap_method_type));
- *types = methods;
- *num_types = num_methods;
- return 0;
- }
- int eap_peer_tls_phase2_nak(struct eap_method_type *types, size_t num_types,
- struct eap_hdr *hdr, struct wpabuf **resp)
- {
- u8 *pos = (u8 *) (hdr + 1);
- size_t i;
-
- wpa_printf(MSG_DEBUG, "TLS: Phase 2 Request: Nak type=%d", *pos);
- wpa_hexdump(MSG_DEBUG, "TLS: Allowed Phase2 EAP types",
- (u8 *) types, num_types * sizeof(struct eap_method_type));
- *resp = eap_msg_alloc(EAP_VENDOR_IETF, EAP_TYPE_NAK, num_types,
- EAP_CODE_RESPONSE, hdr->identifier);
- if (*resp == NULL)
- return -1;
- for (i = 0; i < num_types; i++) {
- if (types[i].vendor == EAP_VENDOR_IETF &&
- types[i].method < 256)
- wpabuf_put_u8(*resp, types[i].method);
- }
- eap_update_len(*resp);
- return 0;
- }
|