#include "gssapiP_eap.h"
+static gss_buffer_desc radiusUrnPrefix = {
+ sizeof("urn:radius:") - 1,
+ (void *)"urn:radius:"
+};
+
VALUE_PAIR *
gss_eap_radius_attr_provider::copyAvps(const VALUE_PAIR *src)
{
}
static bool
-isSecretAttributeP(int attrid, int vendor)
+isHiddenAttributeP(int attrid, int vendor)
{
bool ret = false;
switch (vendor) {
- case RADIUS_VENDOR_ID_MICROSOFT:
+ case VENDOR_ID_MICROSOFT:
switch (attrid) {
- case RADIUS_VENDOR_ATTR_MS_MPPE_SEND_KEY:
- case RADIUS_VENDOR_ATTR_MS_MPPE_RECV_KEY:
+ case VENDOR_ATTR_MS_MPPE_SEND_KEY:
+ case VENDOR_ATTR_MS_MPPE_RECV_KEY:
ret = true;
break;
default:
break;
}
+ case VENDOR_ID_UKERNA:
+ ret = true;
+ break;
default:
break;
}
for (vp = m_avps; vp != NULL; vp = vp->next) {
gss_buffer_desc attribute;
-
- if (isSecretAttributeP(ATTRID(vp->attribute), VENDOR(vp->attribute)))
+ char attrid[64];
+ if (isHiddenAttributeP(ATTRID(vp->attribute), VENDOR(vp->attribute)))
continue;
if (alreadyAddedAttributeP(seen, vp))
continue;
- attribute.value = (void *)vp->name;
- attribute.length = strlen(vp->name);
+ snprintf(attrid, sizeof(attrid), "%s%d",
+ (char *)radiusUrnPrefix.value, vp->attribute);
+
+ attribute.value = attrid;
+ attribute.length = strlen(attrid);
if (!addAttribute(this, &attribute, data))
return false;
char *s;
/* XXX vendor */
-
duplicateBuffer(*attr, &strAttr);
s = (char *)strAttr.value;
- if (isdigit(((char *)strAttr.value)[0])) {
+ if (attr->length < radiusUrnPrefix.length ||
+ memcmp(s, radiusUrnPrefix.value, radiusUrnPrefix.length) != 0)
+ return false;
+
+ s += radiusUrnPrefix.length;
+
+ if (isdigit(*s)) {
attrid = strtoul(s, NULL, 10);
} else {
d = rc_dict_findattr(m_rh, (char *)s);
isPrintableAttributeP(VALUE_PAIR *vp)
{
size_t i;
+ int gotChar = 0;
for (i = 0; i < sizeof(vp->strvalue); i++) {
+ if (gotChar && vp->strvalue[i] == '\0')
+ return true;
+
if (!isprint(vp->strvalue[i]))
return false;
+
+ if (!gotChar)
+ gotChar++;
}
return true;
{
OM_uint32 tmpMinor;
VALUE_PAIR *vp;
- int i = *more;
- int max = 0;
+ int i = *more, count = 0;
char name[NAME_LENGTH + 1];
char displayString[AUTH_STRING_LEN + 1];
gss_buffer_desc valueBuf = GSS_C_EMPTY_BUFFER;
*more = 0;
- if (isSecretAttributeP(attrid, vendor))
- return false;
-
- vp = rc_avpair_get(m_avps, attrid, vendor);
- if (vp == NULL)
+ if (isHiddenAttributeP(attrid, vendor))
return false;
if (i == -1)
i = 0;
- do {
- if (i == max)
+ for (vp = rc_avpair_get(m_avps, attrid, vendor);
+ vp != NULL;
+ vp = rc_avpair_get(vp->next, attrid, vendor)) {
+ if (count++ == i) {
+ if (rc_avpair_get(vp->next, attrid, vendor) != NULL)
+ *more = count;
break;
+ }
+ }
- max++;
- } while ((vp = rc_avpair_get(vp->next, attrid, vendor)) != NULL);
-
- if (i > max)
+ if (vp == NULL && *more == 0)
return false;
if (vp->type == PW_TYPE_STRING) {
if (complete != NULL)
*complete = true;
- if (max > i)
- *more = i;
-
return true;
}
bool
+gss_eap_radius_attr_provider::getFragmentedAttribute(int attribute,
+ int vendor,
+ int *authenticated,
+ int *complete,
+ gss_buffer_t value) const
+{
+ OM_uint32 major, minor;
+
+ major = getBufferFromAvps(&minor, m_avps, attribute, vendor, value, TRUE);
+
+ if (authenticated != NULL)
+ *authenticated = m_authenticated;
+ if (complete != NULL)
+ *complete = true;
+
+ return !GSS_ERROR(major);
+}
+
+bool
gss_eap_radius_attr_provider::getAttribute(int attrid,
int *authenticated,
int *complete,
rc_handle *rh,
VALUE_PAIR **vp,
int type,
+ int vendor,
gss_buffer_t buffer)
{
- if (rc_avpair_add(rh, vp, type, buffer->value, buffer->length, 0) == NULL) {
+ if (rc_avpair_add(rh, vp, type,
+ buffer->value, buffer->length, vendor) == NULL) {
return GSS_S_FAILURE;
}
getBufferFromAvps(OM_uint32 *minor,
VALUE_PAIR *vps,
int type,
+ int vendor,
gss_buffer_t buffer,
int concat)
{
buffer->length = 0;
buffer->value = NULL;
- vp = rc_avpair_get(vps, type, 0);
+ vp = rc_avpair_get(vps, type, vendor);
if (vp == NULL)
return GSS_S_UNAVAILABLE;
do {
buffer->length += vp->lvalue;
- } while (concat && (vp = rc_avpair_get(vp->next, type, 0)) != NULL);
+ } while (concat && (vp = rc_avpair_get(vp->next, type, vendor)) != NULL);
buffer->value = GSSEAP_MALLOC(buffer->length);
if (buffer->value == NULL) {
p = (unsigned char *)buffer->value;
- for (vp = rc_avpair_get(vps, type, 0);
+ for (vp = rc_avpair_get(vps, type, vendor);
concat && vp != NULL;
- vp = rc_avpair_get(vp->next, type, 0)) {
+ vp = rc_avpair_get(vp->next, type, vendor)) {
memcpy(p, vp->strvalue, vp->lvalue);
p += vp->lvalue;
}
assert(remain == 0);
}
+
+time_t
+gss_eap_radius_attr_provider::getExpiryTime(void) const
+{
+ VALUE_PAIR *vp;
+
+ vp = rc_avpair_get(m_avps, PW_SESSION_TIMEOUT, 0);
+ if (vp == NULL || vp->lvalue == 0)
+ return 0;
+
+ return time(NULL) + vp->lvalue;
+}