--- /dev/null
+#pragma once
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+/**
+ * $Id$
+ * @file eap_attrs.h
+ * @brief Interface into the base EAP library
+ *
+ * @copyright 2018 Arran Cudbard-Bell (a.cudbardb@freeradius.org)
+ */
+RCSIDH(eap_attrs_h, "$Id$")
+
+extern fr_dict_attr_t const *attr_chbind_response_code;
+extern fr_dict_attr_t const *attr_eap_session_id;
+extern fr_dict_attr_t const *attr_eap_type;
+extern fr_dict_attr_t const *attr_virtual_server;
+
+extern fr_dict_attr_t const *attr_message_authenticator;
+extern fr_dict_attr_t const *attr_eap_channel_binding_message;
+extern fr_dict_attr_t const *attr_eap_message;
+extern fr_dict_attr_t const *attr_eap_msk;
+extern fr_dict_attr_t const *attr_eap_emsk;
+extern fr_dict_attr_t const *attr_freeradius_proxied_to;
+extern fr_dict_attr_t const *attr_ms_mppe_send_key;
+extern fr_dict_attr_t const *attr_ms_mppe_recv_key;
#include <freeradius-devel/libradius.h>
#include <freeradius-devel/rad_assert.h>
#include "eap_types.h"
+#include "eap_attrs.h"
#include "eap.h"
+static fr_dict_t const *dict_freeradius;
static fr_dict_t const *dict_radius;
extern fr_dict_autoload_t eap_base_dict[];
fr_dict_autoload_t eap_base_dict[] = {
+ { .out = &dict_freeradius, .proto = "freeradius" },
{ .out = &dict_radius, .proto = "radius" },
-
{ NULL }
};
+fr_dict_attr_t const *attr_chbind_response_code;
+fr_dict_attr_t const *attr_eap_session_id;
+fr_dict_attr_t const *attr_eap_type;
+fr_dict_attr_t const *attr_virtual_server;
+
+fr_dict_attr_t const *attr_message_authenticator;
+fr_dict_attr_t const *attr_eap_channel_binding_message;
+fr_dict_attr_t const *attr_eap_message;
fr_dict_attr_t const *attr_eap_msk;
fr_dict_attr_t const *attr_eap_emsk;
-
+fr_dict_attr_t const *attr_freeradius_proxied_to;
fr_dict_attr_t const *attr_ms_mppe_send_key;
fr_dict_attr_t const *attr_ms_mppe_recv_key;
extern fr_dict_attr_autoload_t eap_base_dict_attr[];
fr_dict_attr_autoload_t eap_base_dict_attr[] = {
+ { .out = &attr_chbind_response_code, .name = "Chbind-Response-Code", .type = FR_TYPE_UINT32, .dict = &dict_freeradius },
+ { .out = &attr_eap_session_id, .name = "EAP-Session-Id", .type = FR_TYPE_OCTETS, .dict = &dict_freeradius },
+ { .out = &attr_eap_type, .name = "EAP-Type", .type = FR_TYPE_UINT32, .dict = &dict_freeradius },
+ { .out = &attr_virtual_server, .name = "Virtual-Server", .type = FR_TYPE_STRING, .dict = &dict_freeradius },
+
+ { .out = &attr_message_authenticator, .name = "Message-Authenticator", .type = FR_TYPE_OCTETS, .dict = &dict_radius },
+ { .out = &attr_eap_channel_binding_message, .name = "EAP-Channel-Binding-Message", .type = FR_TYPE_OCTETS, .dict = &dict_radius },
+ { .out = &attr_eap_message, .name = "EAP-Message", .type = FR_TYPE_OCTETS, .dict = &dict_radius },
{ .out = &attr_eap_msk, .name = "EAP-MSK", .type = FR_TYPE_OCTETS, .dict = &dict_radius },
{ .out = &attr_eap_emsk, .name = "EAP-EMSK", .type = FR_TYPE_OCTETS, .dict = &dict_radius },
+ { .out = &attr_freeradius_proxied_to, .name = "FreeRADIUS-Proxied-To", .type = FR_TYPE_IPV4_ADDR, .dict = &dict_radius },
{ .out = &attr_ms_mppe_send_key, .name = "MS-MPPE-Send-Key", .type = FR_TYPE_OCTETS, .dict = &dict_radius },
{ .out = &attr_ms_mppe_recv_key, .name = "MS-MPPE-Recv-Key", .type = FR_TYPE_OCTETS, .dict = &dict_radius },
{
fr_dict_enum_t *dv;
- dv = fr_dict_enum_by_alias(fr_dict_attr_by_num(NULL, 0, FR_EAP_TYPE), name);
+ dv = fr_dict_enum_by_alias(attr_eap_type, name);
if (!dv) return FR_EAP_INVALID;
if (dv->value->vb_uint32 >= FR_EAP_MAX_TYPES) return FR_EAP_INVALID;
{
fr_dict_enum_t *dv;
- dv = fr_dict_enum_by_value(fr_dict_attr_by_num(NULL, 0, FR_EAP_TYPE), fr_box_uint32(method));
+ dv = fr_dict_enum_by_value(attr_eap_type, fr_box_uint32(method));
if (dv) return dv->alias;
return "unknown";
size = total;
if (size > 253) size = 253;
- vp = fr_pair_afrom_num(packet, 0, FR_EAP_MESSAGE);
+ vp = fr_pair_afrom_da(packet, attr_eap_message);
if (!vp) {
fr_pair_list_free(&head);
return NULL;
/*
* Get only EAP-Message attribute list
*/
- first = fr_pair_find_by_num(vps, 0, FR_EAP_MESSAGE, TAG_ANY);
+ first = fr_pair_find_by_da(vps, attr_eap_message, TAG_ANY);
if (!first) {
fr_strerror_printf("EAP-Message not found");
return NULL;
*/
total_len = 0;
fr_pair_cursor_init(&cursor, &first);
- while ((i = fr_pair_cursor_next_by_num(&cursor, 0, FR_EAP_MESSAGE, TAG_ANY))) {
+ while ((i = fr_pair_cursor_next_by_da(&cursor, attr_eap_message, TAG_ANY))) {
total_len += i->vp_length;
if (total_len > len) {
/* RADIUS ensures order of attrs, so just concatenate all */
fr_pair_cursor_first(&cursor);
- while ((i = fr_pair_cursor_next_by_num(&cursor, 0, FR_EAP_MESSAGE, TAG_ANY))) {
+ while ((i = fr_pair_cursor_next_by_da(&cursor, attr_eap_message, TAG_ANY))) {
memcpy(ptr, i->vp_strvalue, i->vp_length);
ptr += i->vp_length;
}
rlm_rcode_t rcode;
VALUE_PAIR *vp;
- vp = fr_pair_find_by_num(request->control, 0, FR_VIRTUAL_SERVER, TAG_ANY);
+ vp = fr_pair_find_by_da(request->control, attr_virtual_server, TAG_ANY);
fake->server_cs = vp ? virtual_server_find(vp->vp_strvalue) : virtual_server_find(virtual_server);
if (fake->server_cs) {
#include "eap_types.h"
-extern fr_dict_attr_t const *attr_eap_msk;
-extern fr_dict_attr_t const *attr_eap_emsk;
-
-extern fr_dict_attr_t const *attr_ms_mppe_send_key;
-extern fr_dict_attr_t const *attr_ms_mppe_recv_key;
-
/*
* interfaces in eapcommon.c
*/
RCSID("$Id$")
#include "eap_chbind.h"
+#include "eap_attrs.h"
static bool chbind_build_response(REQUEST *request, CHBIND_REQ *chbind)
{
* Skip things which shouldn't be in channel bindings.
*/
if (vp->da->flags.encrypt != FLAG_ENCRYPT_NONE) continue;
- if (fr_dict_attr_is_top_level(vp->da) && (vp->da->attr == FR_MESSAGE_AUTHENTICATOR)) continue;
+ if (vp->da == attr_message_authenticator) continue;
total += 2 + vp->vp_length;
}
* Set the response code. Default to "fail" if none was
* specified.
*/
- vp = fr_pair_find_by_num(request->control, 0, FR_CHBIND_RESPONSE_CODE, TAG_ANY);
+ vp = fr_pair_find_by_da(request->control, attr_chbind_response_code, TAG_ANY);
if (vp) {
ptr[0] = vp->vp_uint32;
} else {
fr_cursor_next(&cursor);
continue;
}
- if (fr_dict_attr_is_top_level(vp->da) && (vp->da->attr == FR_MESSAGE_AUTHENTICATOR)) goto next;
+ if (vp->da == attr_message_authenticator) goto next;
length = fr_radius_encode_pair(ptr, end - ptr, &cursor, NULL);
ptr += length;
FR_CODE chbind_process(REQUEST *request, CHBIND_REQ *chbind)
{
- FR_CODE code;
- rlm_rcode_t rcode;
- REQUEST *fake = NULL;
- uint8_t const *attr_data;
- size_t data_len = 0;
+ FR_CODE code;
+ rlm_rcode_t rcode;
+ REQUEST *fake = NULL;
+ uint8_t const *attr_data;
+ size_t data_len = 0;
+ VALUE_PAIR *vp;
/* check input parameters */
rad_assert((request != NULL) &&
/* Set-up the fake request */
fake = request_alloc_fake(request);
- fr_pair_make(fake->packet, &fake->packet->vps, "Freeradius-Proxied-To", "127.0.0.1", T_OP_EQ);
+ MEM(vp = fr_pair_add_by_da(fake->packet, &fake->packet->vps, attr_freeradius_proxied_to, 0));
+ fr_pair_value_from_str(vp, "127.0.0.1", sizeof("127.0.0.1"));
/* Add the username to the fake request */
if (chbind->username) {
chbind_packet_t *packet;
vp_cursor_t cursor;
- first = fr_pair_find_by_num(vps, VENDORPEC_UKERNA, FR_UKERNA_CHBIND, TAG_ANY);
+ first = fr_pair_find_by_da(vps, attr_eap_channel_binding_message, TAG_ANY);
if (!first) return NULL;
/*
* Compute the total length of the channel binding data.
*/
length = 0;
- for (vp =fr_pair_cursor_init(&cursor, &first);
+ for (vp = fr_pair_cursor_init(&cursor, &first);
vp != NULL;
- vp = fr_pair_cursor_next_by_num(&cursor, VENDORPEC_UKERNA, FR_UKERNA_CHBIND, TAG_ANY)) {
+ vp = fr_pair_cursor_next_by_da(&cursor, attr_eap_channel_binding_message, TAG_ANY)) {
length += vp->vp_length;
}
packet = (chbind_packet_t *) ptr;
for (vp = fr_pair_cursor_init(&cursor, &first);
vp != NULL;
- vp = fr_pair_cursor_next_by_num(&cursor, VENDORPEC_UKERNA, FR_UKERNA_CHBIND, TAG_ANY)) {
+ vp = fr_pair_cursor_next_by_da(&cursor, attr_eap_channel_binding_message, TAG_ANY)) {
memcpy(ptr, vp->vp_octets, vp->vp_length);
ptr += vp->vp_length;
}
if (!chbind) return NULL; /* don't produce garbage */
- vp = fr_pair_afrom_num(packet, VENDORPEC_UKERNA, FR_UKERNA_CHBIND);
+ vp = fr_pair_afrom_da(packet, attr_eap_channel_binding_message);
if (!vp) return NULL;
fr_pair_value_memcpy(vp, (uint8_t *) chbind, talloc_array_length((uint8_t *)chbind));
USES_APPLE_DEPRECATED_API /* OpenSSL API has been deprecated by Apple */
#include "eap_tls.h"
+#include "eap_attrs.h"
FR_NAME_NUMBER const eap_tls_status_table[] = {
{ "invalid", EAP_TLS_INVALID },
#include <freeradius-devel/sha1.h>
#include "eap_tls.h"
#include "eap_base.h"
+#include "eap_attrs.h"
#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER)
VALUE_PAIR *vp;
uint8_t *buff, *p;
- vp = fr_pair_afrom_num(packet, 0, FR_EAP_SESSION_ID);
+ vp = fr_pair_afrom_da(packet, attr_eap_session_id);
if (!vp) return;
MEM(buff = p = talloc_array(vp, uint8_t, 1 + (2 * SSL3_RANDOM_SIZE)));
};
static fr_dict_t const *dict_freeradius;
+static fr_dict_t const *dict_radius;
static fr_dict_t const *dict_eap_aka;
extern fr_dict_autoload_t rlm_eap_aka_dict[];
fr_dict_autoload_t rlm_eap_aka_dict[] = {
{ .out = &dict_freeradius, .proto = "freeradius" },
+ { .out = &dict_radius, .proto = "radius" },
{ .out = &dict_eap_aka, .proto = "eap-aka" },
{ NULL }
};
static fr_dict_attr_t const *attr_eap_aka_subtype;
static fr_dict_attr_t const *attr_sim_amf;
+static fr_dict_attr_t const *attr_ms_mppe_send_key;
+static fr_dict_attr_t const *attr_ms_mppe_recv_key;
+
static fr_dict_attr_t const *attr_eap_aka_any_id_req;
static fr_dict_attr_t const *attr_eap_aka_autn;
static fr_dict_attr_t const *attr_eap_aka_bidding;
{ .out = &attr_eap_aka_subtype, .name = "EAP-AKA-Subtype", .type = FR_TYPE_UINT32, .dict = &dict_freeradius },
{ .out = &attr_sim_amf, .name = "SIM-AMF", .type = FR_TYPE_OCTETS, .dict = &dict_freeradius },
+ { .out = &attr_ms_mppe_send_key, .name = "MS-MPPE-Send-Key", .type = FR_TYPE_OCTETS, .dict = &dict_radius },
+ { .out = &attr_ms_mppe_recv_key, .name = "MS-MPPE-Recv-Key", .type = FR_TYPE_OCTETS, .dict = &dict_radius },
+
{ .out = &attr_eap_aka_any_id_req, .name = "EAP-AKA-Any-ID-Req", .type = FR_TYPE_BOOL, .dict = &dict_eap_aka },
{ .out = &attr_eap_aka_autn, .name = "EAP-AKA-AUTN", .type = FR_TYPE_OCTETS, .dict = &dict_eap_aka },
{ .out = &attr_eap_aka_bidding, .name = "EAP-AKA-Bidding", .type = FR_TYPE_UINT16, .dict = &dict_eap_aka },
extern fr_dict_attr_t const *attr_proxy_to_realm;
extern fr_dict_attr_t const *attr_eap_message;
+extern fr_dict_attr_t const *attr_eap_msk;
+extern fr_dict_attr_t const *attr_eap_emsk;
extern fr_dict_attr_t const *attr_freeradius_proxied_to;
+extern fr_dict_attr_t const *attr_ms_mppe_send_key;
+extern fr_dict_attr_t const *attr_ms_mppe_recv_key;
extern fr_dict_attr_t const *attr_user_name;
extern fr_dict_attr_t const *attr_user_password;
fr_dict_attr_t const *attr_proxy_to_realm;
fr_dict_attr_t const *attr_eap_message;
+fr_dict_attr_t const *attr_eap_msk;
+fr_dict_attr_t const *attr_eap_emsk;
fr_dict_attr_t const *attr_freeradius_proxied_to;
+fr_dict_attr_t const *attr_ms_mppe_send_key;
+fr_dict_attr_t const *attr_ms_mppe_recv_key;
fr_dict_attr_t const *attr_user_name;
fr_dict_attr_t const *attr_user_password;
{ .out = &attr_proxy_to_realm, .name = "Proxy-To-Realm", .type = FR_TYPE_STRING, .dict = &dict_freeradius },
{ .out = &attr_eap_message, .name = "EAP-Message", .type = FR_TYPE_OCTETS, .dict = &dict_radius },
+ { .out = &attr_eap_msk, .name = "EAP-MSK", .type = FR_TYPE_OCTETS, .dict = &dict_radius },
+ { .out = &attr_eap_emsk, .name = "EAP-EMSK", .type = FR_TYPE_OCTETS, .dict = &dict_radius },
{ .out = &attr_freeradius_proxied_to, .name = "FreeRADIUS-Proxied-To", .type = FR_TYPE_IPV4_ADDR, .dict = &dict_radius },
+ { .out = &attr_ms_mppe_send_key, .name = "MS-MPPE-Send-Key", .type = FR_TYPE_OCTETS, .dict = &dict_radius },
+ { .out = &attr_ms_mppe_recv_key, .name = "MS-MPPE-Recv-Key", .type = FR_TYPE_OCTETS, .dict = &dict_radius },
{ .out = &attr_user_name, .name = "User-Name", .type = FR_TYPE_STRING, .dict = &dict_radius },
{ .out = &attr_user_password, .name = "User-Password", .type = FR_TYPE_STRING, .dict = &dict_radius },
static fr_dict_attr_t const *attr_ms_chap2_success;
static fr_dict_attr_t const *attr_ms_mppe_encryption_policy;
static fr_dict_attr_t const *attr_ms_mppe_encryption_type;
+static fr_dict_attr_t const *attr_ms_mppe_send_key;
+static fr_dict_attr_t const *attr_ms_mppe_recv_key;
static fr_dict_attr_t const *attr_state;
static fr_dict_attr_t const *attr_user_name;
{ .out = &attr_ms_chap2_success, .name = "MS-CHAP2-Success", .type = FR_TYPE_OCTETS, .dict = &dict_radius },
{ .out = &attr_ms_mppe_encryption_policy, .name = "MS-MPPE-Encryption-Policy", .type = FR_TYPE_UINT32, .dict = &dict_radius },
{ .out = &attr_ms_mppe_encryption_type, .name = "MS-MPPE-Encryption-Type", .type = FR_TYPE_UINT32, .dict = &dict_radius },
+ { .out = &attr_ms_mppe_send_key, .name = "MS-MPPE-Send-Key", .type = FR_TYPE_OCTETS, .dict = &dict_radius },
+ { .out = &attr_ms_mppe_recv_key, .name = "MS-MPPE-Recv-Key", .type = FR_TYPE_OCTETS, .dict = &dict_radius },
{ .out = &attr_state, .name = "State", .type = FR_TYPE_OCTETS, .dict = &dict_radius },
{ .out = &attr_user_name, .name = "User-Name", .type = FR_TYPE_STRING, .dict = &dict_radius },
{ NULL }
static fr_dict_attr_t const *attr_cleartext_password;
static fr_dict_attr_t const *attr_framed_mtu;
+static fr_dict_attr_t const *attr_ms_mppe_send_key;
+static fr_dict_attr_t const *attr_ms_mppe_recv_key;
extern fr_dict_attr_autoload_t rlm_eap_pwd_dict_attr[];
fr_dict_attr_autoload_t rlm_eap_pwd_dict_attr[] = {
{ .out = &attr_cleartext_password, .name = "Cleartext-Password", .type = FR_TYPE_STRING, .dict = &dict_freeradius },
{ .out = &attr_framed_mtu, .name = "Framed-MTU", .type = FR_TYPE_UINT32, .dict = &dict_radius },
+ { .out = &attr_ms_mppe_send_key, .name = "MS-MPPE-Send-Key", .type = FR_TYPE_OCTETS, .dict = &dict_radius },
+ { .out = &attr_ms_mppe_recv_key, .name = "MS-MPPE-Recv-Key", .type = FR_TYPE_OCTETS, .dict = &dict_radius },
{ NULL }
};
};
static fr_dict_t const *dict_freeradius;
+static fr_dict_t const *dict_radius;
static fr_dict_t const *dict_eap_sim;
extern fr_dict_autoload_t rlm_eap_sim_dict[];
fr_dict_autoload_t rlm_eap_sim_dict[] = {
{ .out = &dict_freeradius, .proto = "freeradius" },
+ { .out = &dict_radius, .proto = "radius" },
{ .out = &dict_eap_sim, .proto = "eap-sim" },
{ NULL }
};
static fr_dict_attr_t const *attr_eap_sim_root;
static fr_dict_attr_t const *attr_eap_sim_subtype;
+static fr_dict_attr_t const *attr_ms_mppe_send_key;
+static fr_dict_attr_t const *attr_ms_mppe_recv_key;
+
static fr_dict_attr_t const *attr_eap_sim_any_id_req;
static fr_dict_attr_t const *attr_eap_sim_client_error_code;
static fr_dict_attr_t const *attr_eap_sim_counter;
{ .out = &attr_eap_sim_root, .name = "EAP-SIM-Root", .type = FR_TYPE_TLV, .dict = &dict_freeradius },
{ .out = &attr_eap_sim_subtype, .name = "EAP-SIM-Subtype", .type = FR_TYPE_UINT32, .dict = &dict_freeradius },
+ { .out = &attr_ms_mppe_send_key, .name = "MS-MPPE-Send-Key", .type = FR_TYPE_OCTETS, .dict = &dict_radius },
+ { .out = &attr_ms_mppe_recv_key, .name = "MS-MPPE-Recv-Key", .type = FR_TYPE_OCTETS, .dict = &dict_radius },
+
{ .out = &attr_eap_sim_any_id_req, .name = "EAP-SIM-Any-ID-Req", .type = FR_TYPE_BOOL, .dict = &dict_eap_sim },
{ .out = &attr_eap_sim_client_error_code, .name = "EAP-SIM-Client-Error-Code", .type = FR_TYPE_UINT16, .dict = &dict_eap_sim },
{ .out = &attr_eap_sim_counter, .name = "EAP-SIM-Counter", .type = FR_TYPE_UINT16, .dict = &dict_eap_sim },