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