1fcf3ce44SJohn Forte /*
2fcf3ce44SJohn Forte  * CDDL HEADER START
3fcf3ce44SJohn Forte  *
4fcf3ce44SJohn Forte  * The contents of this file are subject to the terms of the
5fcf3ce44SJohn Forte  * Common Development and Distribution License (the "License").
6fcf3ce44SJohn Forte  * You may not use this file except in compliance with the License.
7fcf3ce44SJohn Forte  *
8fcf3ce44SJohn Forte  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9fcf3ce44SJohn Forte  * or http://www.opensolaris.org/os/licensing.
10fcf3ce44SJohn Forte  * See the License for the specific language governing permissions
11fcf3ce44SJohn Forte  * and limitations under the License.
12fcf3ce44SJohn Forte  *
13fcf3ce44SJohn Forte  * When distributing Covered Code, include this CDDL HEADER in each
14fcf3ce44SJohn Forte  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15fcf3ce44SJohn Forte  * If applicable, add the following below this CDDL HEADER, with the
16fcf3ce44SJohn Forte  * fields enclosed by brackets "[]" replaced with your own identifying
17fcf3ce44SJohn Forte  * information: Portions Copyright [yyyy] [name of copyright owner]
18fcf3ce44SJohn Forte  *
19fcf3ce44SJohn Forte  * CDDL HEADER END
20fcf3ce44SJohn Forte  */
21fcf3ce44SJohn Forte /*
22*5df5713fSbing zhao - Sun Microsystems - Beijing China  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
23fcf3ce44SJohn Forte  * Use is subject to license terms.
24fcf3ce44SJohn Forte  */
25fcf3ce44SJohn Forte 
26fcf3ce44SJohn Forte #include "chap.h"
27fcf3ce44SJohn Forte #include "radius_auth.h"
28fcf3ce44SJohn Forte 
29fcf3ce44SJohn Forte #include <netinet/in.h>
30fcf3ce44SJohn Forte #include <sys/int_types.h>
31fcf3ce44SJohn Forte 
32fcf3ce44SJohn Forte chap_validation_status_type
chap_validate_tgt(char * target_chap_name,char * initiator_chap_name,uint8_t * challenge,uint32_t challenge_length,uint8_t * target_response,uint32_t response_length,uint8_t identifier,authentication_method_type auth_method,void * auth_config_data)33*5df5713fSbing zhao - Sun Microsystems - Beijing China chap_validate_tgt(char *target_chap_name,
34fcf3ce44SJohn Forte 	char *initiator_chap_name,
35fcf3ce44SJohn Forte 	uint8_t *challenge,
36*5df5713fSbing zhao - Sun Microsystems - Beijing China 	uint32_t challenge_length,
37fcf3ce44SJohn Forte 	uint8_t *target_response,
38*5df5713fSbing zhao - Sun Microsystems - Beijing China 	uint32_t response_length,
39fcf3ce44SJohn Forte 	uint8_t identifier,
40fcf3ce44SJohn Forte 	authentication_method_type auth_method,
41fcf3ce44SJohn Forte 	void *auth_config_data) {
42fcf3ce44SJohn Forte 
43fcf3ce44SJohn Forte 	if (auth_method == RADIUS_AUTHENTICATION) {
44fcf3ce44SJohn Forte 		RADIUS_CONFIG *radius_config =
45fcf3ce44SJohn Forte 			(RADIUS_CONFIG *)auth_config_data;
46fcf3ce44SJohn Forte 
47fcf3ce44SJohn Forte 		if (radius_config == 0) {
48fcf3ce44SJohn Forte 			return (CHAP_VALIDATION_INTERNAL_ERROR);
49fcf3ce44SJohn Forte 		}
50fcf3ce44SJohn Forte 
51fcf3ce44SJohn Forte 		return (radius_chap_validate(
52fcf3ce44SJohn Forte 			target_chap_name,
53fcf3ce44SJohn Forte 			initiator_chap_name,
54fcf3ce44SJohn Forte 			challenge,
55*5df5713fSbing zhao - Sun Microsystems - Beijing China 			challenge_length,
56fcf3ce44SJohn Forte 			target_response,
57*5df5713fSbing zhao - Sun Microsystems - Beijing China 			response_length,
58fcf3ce44SJohn Forte 			identifier,
59fcf3ce44SJohn Forte 			radius_config->rad_svr_addr,
60fcf3ce44SJohn Forte 			radius_config->rad_svr_port,
61fcf3ce44SJohn Forte 			radius_config->rad_svr_shared_secret,
62fcf3ce44SJohn Forte 			radius_config->rad_svr_shared_secret_len));
63fcf3ce44SJohn Forte 	} else if (auth_method == DIRECT_AUTHENTICATION) {
64fcf3ce44SJohn Forte 		return (CHAP_VALIDATION_UNKNOWN_AUTH_METHOD);
65fcf3ce44SJohn Forte 	}
66fcf3ce44SJohn Forte 
67fcf3ce44SJohn Forte 	return (CHAP_VALIDATION_UNKNOWN_AUTH_METHOD);
68fcf3ce44SJohn Forte }
69