Exemplo n.º 1
0
/*
 *	Authenticate a previously sent challenge.
 */
static int mod_process(UNUSED void *arg, eap_handler_t *handler)
{
	MD5_PACKET	*packet;
	MD5_PACKET	*reply;
	VALUE_PAIR	*password;
	REQUEST		*request = handler->request;

	/*
	 *	Get the Cleartext-Password for this user.
	 */
	rad_assert(handler->request != NULL);
	rad_assert(handler->stage == PROCESS);

	password = fr_pair_find_by_num(handler->request->config, PW_CLEARTEXT_PASSWORD, 0, TAG_ANY);
	if (!password) {
		REDEBUG2("Cleartext-Password is required for EAP-MD5 authentication");
		return 0;
	}

	/*
	 *	Extract the EAP-MD5 packet.
	 */
	if (!(packet = eapmd5_extract(handler->eap_ds)))
		return 0;

	/*
	 *	Create a reply, and initialize it.
	 */
	reply = talloc(packet, MD5_PACKET);
	if (!reply) {
		talloc_free(packet);
		return 0;
	}
	reply->id = handler->eap_ds->request->id;
	reply->length = 0;

	/*
	 *	Verify the received packet against the previous packet
	 *	(i.e. challenge) which we sent out.
	 */
	if (eapmd5_verify(packet, password, handler->opaque)) {
		reply->code = PW_MD5_SUCCESS;
	} else {
		reply->code = PW_MD5_FAILURE;
	}

	/*
	 *	Compose the EAP-MD5 packet out of the data structure,
	 *	and free it.
	 */
	eapmd5_compose(handler->eap_ds, reply);
	talloc_free(packet);
	return 1;
}
Exemplo n.º 2
0
/*
 *	Authenticate a previously sent challenge.
 */
static int md5_authenticate(UNUSED void *arg, EAP_HANDLER *handler)
{
    MD5_PACKET	*packet;
    MD5_PACKET	*reply;
    VALUE_PAIR	*password;

    /*
     *	Get the Cleartext-Password for this user.
     */
    rad_assert(handler->request != NULL);
    rad_assert(handler->stage == AUTHENTICATE);

    password = pairfind(handler->request->config_items, PW_CLEARTEXT_PASSWORD);
    if (password == NULL) {
        DEBUG2("rlm_eap_md5: Cleartext-Password is required for EAP-MD5 authentication");
        return 0;
    }

    /*
     *	Extract the EAP-MD5 packet.
     */
    if (!(packet = eapmd5_extract(handler->eap_ds)))
        return 0;

    /*
     *	Create a reply, and initialize it.
     */
    reply = eapmd5_alloc();
    if (!reply) {
        eapmd5_free(&packet);
        return 0;
    }
    reply->id = handler->eap_ds->request->id;
    reply->length = 0;

    /*
     *	Verify the received packet against the previous packet
     *	(i.e. challenge) which we sent out.
     */
    if (eapmd5_verify(packet, password, handler->opaque)) {
        reply->code = PW_MD5_SUCCESS;
    } else {
        reply->code = PW_MD5_FAILURE;
    }

    /*
     *	Compose the EAP-MD5 packet out of the data structure,
     *	and free it.
     */
    eapmd5_compose(handler->eap_ds, reply);

    eapmd5_free(&packet);
    return 1;
}