fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER START
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The contents of this file are subject to the terms of the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Common Development and Distribution License (the "License").
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * You may not use this file except in compliance with the License.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * See the License for the specific language governing permissions
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * and limitations under the License.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * When distributing Covered Code, include this CDDL HEADER in each
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If applicable, add the following below this CDDL HEADER, with the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * fields enclosed by brackets "[]" replaced with your own identifying
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * information: Portions Copyright [yyyy] [name of copyright owner]
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER END
5df5713f81d69c1a0797f99b13e95e220da00ef9bing zhao - Sun Microsystems - Beijing China * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Use is subject to license terms.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* Forward declaration */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Annotate the radius_attr_t objects with authentication data.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte unsigned char *target_response,
5df5713f81d69c1a0797f99b13e95e220da00ef9bing zhao - Sun Microsystems - Beijing China uint32_t response_length,
5df5713f81d69c1a0797f99b13e95e220da00ef9bing zhao - Sun Microsystems - Beijing China uint8_t *challenge,
5df5713f81d69c1a0797f99b13e95e220da00ef9bing zhao - Sun Microsystems - Beijing China uint32_t challenge_length);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* ARGSUSED */
5df5713f81d69c1a0797f99b13e95e220da00ef9bing zhao - Sun Microsystems - Beijing China uint32_t challenge_length,
5df5713f81d69c1a0797f99b13e95e220da00ef9bing zhao - Sun Microsystems - Beijing China uint32_t response_length,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint8_t md5_digest[16]; /* MD5 digest length 16 */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* The secret must not be empty (section 3, RFC 2865) */
5df5713f81d69c1a0797f99b13e95e220da00ef9bing zhao - Sun Microsystems - Beijing China response_length,
5df5713f81d69c1a0797f99b13e95e220da00ef9bing zhao - Sun Microsystems - Beijing China challenge_length);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Prepare the request authenticator */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* First, the shared secret */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MD5Update(&context, rad_svr_shared_secret, rad_svr_shared_secret_len);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Then a unique number - use lbolt plus a random number */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) snprintf(lbolt, sizeof (lbolt), "%lx", ddi_get_lbolt());
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MD5Update(&context, (uint8_t *)lbolt, strlen(lbolt));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MD5Update(&context, random_number, sizeof (random_number));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy(md5_digest, &req.authenticator, RAD_AUTHENTICATOR_LEN);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte socket = iscsi_net->socket(AF_INET, SOCK_DGRAM, 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Error obtaining socket for RADIUS use */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Send the authentication access request to the RADIUS server */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Analyze the response coming through from the same socket. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte validation_status = CHAP_VALIDATION_INVALID_RESPONSE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (rcv_status == RAD_RSP_RCVD_AUTH_FAILED) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte cmn_err(CE_WARN, "RADIUS packet authentication failed");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte validation_status = CHAP_VALIDATION_BAD_RADIUS_SECRET;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte validation_status = CHAP_VALIDATION_RADIUS_ACCESS_ERROR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* See forward declaration. */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte unsigned char *target_response,
5df5713f81d69c1a0797f99b13e95e220da00ef9bing zhao - Sun Microsystems - Beijing China uint32_t response_length,
5df5713f81d69c1a0797f99b13e95e220da00ef9bing zhao - Sun Microsystems - Beijing China uint8_t *challenge,
5df5713f81d69c1a0797f99b13e95e220da00ef9bing zhao - Sun Microsystems - Beijing China uint32_t challenge_length)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte req->attrs[0].attr_value_len = strlen(target_chap_name);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte req->attrs[1].attr_type_code = RAD_CHAP_PASSWORD;
5df5713f81d69c1a0797f99b13e95e220da00ef9bing zhao - Sun Microsystems - Beijing China bcopy(target_response,
5df5713f81d69c1a0797f99b13e95e220da00ef9bing zhao - Sun Microsystems - Beijing China (char *)req->attrs[1].attr_value,
5df5713f81d69c1a0797f99b13e95e220da00ef9bing zhao - Sun Microsystems - Beijing China min(response_length, sizeof (req->attrs[1].attr_value)));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* A target response is an MD5 hash thus its length has to be 16. */
5df5713f81d69c1a0797f99b13e95e220da00ef9bing zhao - Sun Microsystems - Beijing China req->attrs[1].attr_value_len = response_length;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte req->attrs[2].attr_type_code = RAD_CHAP_CHALLENGE;
5df5713f81d69c1a0797f99b13e95e220da00ef9bing zhao - Sun Microsystems - Beijing China bcopy(challenge,
5df5713f81d69c1a0797f99b13e95e220da00ef9bing zhao - Sun Microsystems - Beijing China (char *)req->attrs[2].attr_value,
5df5713f81d69c1a0797f99b13e95e220da00ef9bing zhao - Sun Microsystems - Beijing China min(challenge_length, sizeof (req->attrs[2].attr_value)));
5df5713f81d69c1a0797f99b13e95e220da00ef9bing zhao - Sun Microsystems - Beijing China req->attrs[2].attr_value_len = challenge_length;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* 3 attributes associated with each RADIUS packet. */