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 
22fcf3ce44SJohn Forte /*
23*291a2b48SSukumar Swaminathan  * Copyright 2009 Emulex.  All rights reserved.
24fcf3ce44SJohn Forte  * Use is subject to License terms.
25fcf3ce44SJohn Forte  */
26fcf3ce44SJohn Forte 
27fcf3ce44SJohn Forte 
28fcf3ce44SJohn Forte #ifndef _EMLXS_DHCHAP_H
29fcf3ce44SJohn Forte #define	_EMLXS_DHCHAP_H
30fcf3ce44SJohn Forte 
31fcf3ce44SJohn Forte #ifdef	__cplusplus
32fcf3ce44SJohn Forte extern "C" {
33fcf3ce44SJohn Forte #endif
34fcf3ce44SJohn Forte 
35fcf3ce44SJohn Forte #ifdef DHCHAP_SUPPORT
36fcf3ce44SJohn Forte #include <sys/random.h>
37fcf3ce44SJohn Forte 
38fcf3ce44SJohn Forte 
39fcf3ce44SJohn Forte /* emlxs_auth_cfg_t */
40*291a2b48SSukumar Swaminathan #define	PASSWORD_TYPE_ASCII	1
41*291a2b48SSukumar Swaminathan #define	PASSWORD_TYPE_BINARY	2
42*291a2b48SSukumar Swaminathan #define	PASSWORD_TYPE_IGNORE	3
43fcf3ce44SJohn Forte 
44*291a2b48SSukumar Swaminathan #define	AUTH_MODE_DISABLED	1
45*291a2b48SSukumar Swaminathan #define	AUTH_MODE_ACTIVE	2
46*291a2b48SSukumar Swaminathan #define	AUTH_MODE_PASSIVE	3
47fcf3ce44SJohn Forte 
48*291a2b48SSukumar Swaminathan #define	ELX_DHCHAP		0x01	/* Only one currently supported */
49*291a2b48SSukumar Swaminathan #define	ELX_FCAP		0x02
50*291a2b48SSukumar Swaminathan #define	ELX_FCPAP		0x03
51*291a2b48SSukumar Swaminathan #define	ELX_KERBEROS		0x04
52fcf3ce44SJohn Forte 
53*291a2b48SSukumar Swaminathan #define	ELX_MD5			0x01
54*291a2b48SSukumar Swaminathan #define	ELX_SHA1		0x02
55fcf3ce44SJohn Forte 
56*291a2b48SSukumar Swaminathan #define	ELX_GROUP_NULL		0x01
57*291a2b48SSukumar Swaminathan #define	ELX_GROUP_1024		0x02
58*291a2b48SSukumar Swaminathan #define	ELX_GROUP_1280		0x03
59*291a2b48SSukumar Swaminathan #define	ELX_GROUP_1536		0x04
60*291a2b48SSukumar Swaminathan #define	ELX_GROUP_2048		0x05
61fcf3ce44SJohn Forte 
62fcf3ce44SJohn Forte 
63fcf3ce44SJohn Forte /* AUTH_ELS Code */
64fcf3ce44SJohn Forte #define	ELS_CMD_AUTH_CODE	0x90
65fcf3ce44SJohn Forte 
66fcf3ce44SJohn Forte /* AUTH_ELS Flags */
67fcf3ce44SJohn Forte 
68fcf3ce44SJohn Forte /* state ? */
69fcf3ce44SJohn Forte #define	AUTH_FINISH		0xFF
70fcf3ce44SJohn Forte #define	AUTH_ABORT		0xFE
71fcf3ce44SJohn Forte 
72fcf3ce44SJohn Forte /* auth_msg code for DHCHAP */
73fcf3ce44SJohn Forte #define	AUTH_REJECT		0x0A
74fcf3ce44SJohn Forte #define	AUTH_NEGOTIATE		0x0B
75fcf3ce44SJohn Forte #define	AUTH_DONE		0x0C
76fcf3ce44SJohn Forte #define	DHCHAP_CHALLENGE	0x10
77fcf3ce44SJohn Forte #define	DHCHAP_REPLY		0x11
78fcf3ce44SJohn Forte #define	DHCHAP_SUCCESS		0x12
79fcf3ce44SJohn Forte 
80fcf3ce44SJohn Forte /* BIG ENDIAN and LITTLE ENDIAN */
81fcf3ce44SJohn Forte 
82fcf3ce44SJohn Forte /* authentication protocol identifiers */
83fcf3ce44SJohn Forte #ifdef EMLXS_BIG_ENDIAN
84fcf3ce44SJohn Forte 
85fcf3ce44SJohn Forte #define	AUTH_DHCHAP		0x00000001
86fcf3ce44SJohn Forte #define	AUTH_FCAP		0x00000002
87fcf3ce44SJohn Forte #define	AUTH_FCPAP		0x00000003
88fcf3ce44SJohn Forte #define	AUTH_KERBEROS		0x00000004
89fcf3ce44SJohn Forte 
90fcf3ce44SJohn Forte #define	HASH_LIST_TAG		0x0001
91fcf3ce44SJohn Forte #define	DHGID_LIST_TAG		0x0002
92fcf3ce44SJohn Forte 
93fcf3ce44SJohn Forte /* hash function identifiers */
94fcf3ce44SJohn Forte #define	AUTH_SHA1		0x00000006
95fcf3ce44SJohn Forte #define	AUTH_MD5		0x00000005
96fcf3ce44SJohn Forte 
97fcf3ce44SJohn Forte /* DHCHAP group ids */
98fcf3ce44SJohn Forte #define	GROUP_NULL		0x00000000
99fcf3ce44SJohn Forte #define	GROUP_1024		0x00000001
100fcf3ce44SJohn Forte #define	GROUP_1280		0x00000002
101fcf3ce44SJohn Forte #define	GROUP_1536		0x00000003
102fcf3ce44SJohn Forte #define	GROUP_2048		0x00000004
103fcf3ce44SJohn Forte 
104fcf3ce44SJohn Forte /* Tran_id Mask */
105fcf3ce44SJohn Forte #define	AUTH_TRAN_ID_MASK	0x000000FF
106fcf3ce44SJohn Forte 
107fcf3ce44SJohn Forte #endif	/* EMLXS_BIG_ENDIAN */
108fcf3ce44SJohn Forte 
109fcf3ce44SJohn Forte #ifdef EMLXS_LITTLE_ENDIAN
110fcf3ce44SJohn Forte 
111fcf3ce44SJohn Forte #define	AUTH_DHCHAP		0x01000000
112fcf3ce44SJohn Forte #define	AUTH_FCAP		0x02000000
113fcf3ce44SJohn Forte #define	AUTH_FCPAP		0x03000000
114fcf3ce44SJohn Forte #define	AUTH_KERBEROS		0x04000000
115fcf3ce44SJohn Forte 
116fcf3ce44SJohn Forte #define	HASH_LIST_TAG		0x0100
117fcf3ce44SJohn Forte #define	DHGID_LIST_TAG		0x0200
118fcf3ce44SJohn Forte 
119fcf3ce44SJohn Forte /* hash function identifiers */
120fcf3ce44SJohn Forte #define	AUTH_SHA1		0x06000000
121fcf3ce44SJohn Forte #define	AUTH_MD5		0x05000000
122fcf3ce44SJohn Forte 
123fcf3ce44SJohn Forte /* DHCHAP group ids */
124fcf3ce44SJohn Forte #define	GROUP_NULL		0x00000000
125fcf3ce44SJohn Forte #define	GROUP_1024		0x01000000
126fcf3ce44SJohn Forte #define	GROUP_1280		0x02000000
127fcf3ce44SJohn Forte #define	GROUP_1536		0x03000000
128fcf3ce44SJohn Forte #define	GROUP_2048		0x04000000
129fcf3ce44SJohn Forte 
130fcf3ce44SJohn Forte /* Tran_id Mask */
131fcf3ce44SJohn Forte #define	AUTH_TRAN_ID_MASK	0xFF000000
132fcf3ce44SJohn Forte 
133fcf3ce44SJohn Forte #endif	/* EMLXS_LITTLE_ENDIAN */
134fcf3ce44SJohn Forte 
135fcf3ce44SJohn Forte /* hash funcs hash length in byte */
136fcf3ce44SJohn Forte #define	SHA1_LEN		0x00000014	/* 20 bytes */
137fcf3ce44SJohn Forte #define	MD5_LEN			0x00000010	/* 16 bytes */
138fcf3ce44SJohn Forte 
139fcf3ce44SJohn Forte /*
140fcf3ce44SJohn Forte  * #define	AUTH_IKEv2		 0x04 #define	AUTH_IKEv2_AUTH	 0x05
141fcf3ce44SJohn Forte  */
142fcf3ce44SJohn Forte 
143fcf3ce44SJohn Forte #define	HBA_SECURITY			0x20
144fcf3ce44SJohn Forte 
145fcf3ce44SJohn Forte /* AUTH_Reject Reason Codes */
146fcf3ce44SJohn Forte #define	AUTHRJT_FAILURE			0x01
147fcf3ce44SJohn Forte #define	AUTHRJT_LOGIC_ERR		0x02
148fcf3ce44SJohn Forte 
149fcf3ce44SJohn Forte /* LS_RJT Reason Codes for AUTH_ELS */
150fcf3ce44SJohn Forte #define	LSRJT_AUTH_REQUIRED		0x03
151fcf3ce44SJohn Forte #define	LSRJT_AUTH_LOGICAL_BSY		0x05
152fcf3ce44SJohn Forte #define	LSRJT_AUTH_ELS_NOT_SUPPORTED	0x0B
153fcf3ce44SJohn Forte #define	LSRJT_AUTH_NOT_LOGGED_IN	0x09
154fcf3ce44SJohn Forte 
155fcf3ce44SJohn Forte /* AUTH_Reject Reason Code Explanations */
156*291a2b48SSukumar Swaminathan #define	AUTHEXP_MECH_UNUSABLE		0x01 /* AUTHRJT_LOGIC_ERR */
157*291a2b48SSukumar Swaminathan #define	AUTHEXP_DHGROUP_UNUSABLE	0x02 /* AUTHRJT_LOGIC_ERR */
158*291a2b48SSukumar Swaminathan #define	AUTHEXP_HASHFUNC_UNUSABLE	0x03 /* AUTHRJT_LOGIC_ERR */
159*291a2b48SSukumar Swaminathan #define	AUTHEXP_AUTHTRAN_STARTED	0x04 /* AUTHRJT_LOGIC_ERR */
160*291a2b48SSukumar Swaminathan #define	AUTHEXP_AUTH_FAILED		0x05 /* AUTHRJT_FAILURE */
161*291a2b48SSukumar Swaminathan #define	AUTHEXP_BAD_PAYLOAD		0x06 /* AUTHRJT_FAILURE */
162*291a2b48SSukumar Swaminathan #define	AUTHEXP_BAD_PROTOCOL		0x07 /* AUTHRJT_FAILURE */
163*291a2b48SSukumar Swaminathan #define	AUTHEXP_RESTART_AUTH		0x08 /* AUTHRJT_LOGIC_ERR */
164*291a2b48SSukumar Swaminathan #define	AUTHEXP_CONCAT_UNSUPP		0x09 /* AUTHRJT_LOGIC_ERR */
165*291a2b48SSukumar Swaminathan #define	AUTHEXP_BAD_PROTOVERS		0x0A /* AUTHRJT_LOGIC_ERR */
166fcf3ce44SJohn Forte 
167fcf3ce44SJohn Forte /* LS_RJT Reason Code Explanations for AUTH_ELS */
168fcf3ce44SJohn Forte #define	LSEXP_AUTH_REQUIRED		0x48
169fcf3ce44SJohn Forte #define	LSEXP_AUTH_ELS_NOT_SUPPORTED	0x2C
170fcf3ce44SJohn Forte #define	LSEXP_AUTH_ELS_NOT_LOGGED_IN	0x1E
171fcf3ce44SJohn Forte #define	LSEXP_AUTH_LOGICAL_BUSY		0x00
172fcf3ce44SJohn Forte 
173fcf3ce44SJohn Forte 
174fcf3ce44SJohn Forte #define	MAX_AUTH_MSA_SIZE 1024
175fcf3ce44SJohn Forte 
176fcf3ce44SJohn Forte #define	MAX_AUTH_PID 	0x4	/* Max auth proto identifier list */
177fcf3ce44SJohn Forte 
178fcf3ce44SJohn Forte /* parameter tag */
179fcf3ce44SJohn Forte #define	HASH_LIST	0x0001
180fcf3ce44SJohn Forte #define	DHG_ID_LIST	0x0002
181fcf3ce44SJohn Forte 
182fcf3ce44SJohn Forte /* name tag from Table 13 v1.8 pp 30 */
183fcf3ce44SJohn Forte #ifdef EMLXS_BIG_ENDIAN
184fcf3ce44SJohn Forte #define	AUTH_NAME_ID		0x0001
185fcf3ce44SJohn Forte #define	AUTH_NAME_LEN		0x0008
186fcf3ce44SJohn Forte #define	AUTH_PROTO_NUM		0x00000001
187fcf3ce44SJohn Forte #define	AUTH_NULL_PARA_LEN	0x00000028
188fcf3ce44SJohn Forte #endif	/* EMLXS_BIG_ENDIAN */
189fcf3ce44SJohn Forte 
190fcf3ce44SJohn Forte #ifdef EMLXS_LITTLE_ENDIAN
191fcf3ce44SJohn Forte #define	AUTH_NAME_ID		0x0100
192fcf3ce44SJohn Forte #define	AUTH_NAME_LEN		0x0800
193fcf3ce44SJohn Forte #define	AUTH_PROTO_NUM		0x01000000
194fcf3ce44SJohn Forte #define	AUTH_NULL_PARA_LEN	0x28000000
195fcf3ce44SJohn Forte #endif	/* EMLXS_LITTLE_ENDIAN */
196fcf3ce44SJohn Forte 
197fcf3ce44SJohn Forte /* name tag from Table 103 v 1.8 pp 123 */
198fcf3ce44SJohn Forte #define	AUTH_NODE_NAME		0x0002
199fcf3ce44SJohn Forte #define	AUTH_PORT_NAME		0x0003
200fcf3ce44SJohn Forte 
201fcf3ce44SJohn Forte /*
202fcf3ce44SJohn Forte  * Sysevent support
203fcf3ce44SJohn Forte  */
204fcf3ce44SJohn Forte /* ddi_log_sysevent() vendors */
205fcf3ce44SJohn Forte #define	DDI_VENDOR_EMLX		"EMLXS"
206fcf3ce44SJohn Forte 
207fcf3ce44SJohn Forte /* Class */
208fcf3ce44SJohn Forte #define	EC_EMLXS	"EC_emlxs"
209fcf3ce44SJohn Forte 
210fcf3ce44SJohn Forte /* Subclass */
211fcf3ce44SJohn Forte #define	ESC_EMLXS_01	"ESC_emlxs_issue_auth_negotiate"
212fcf3ce44SJohn Forte #define	ESC_EMLXS_02	"ESC_emlxs_cmpl_auth_negotiate_issue"
213fcf3ce44SJohn Forte 
214fcf3ce44SJohn Forte #define	ESC_EMLXS_03	"ESC_emlxs_rcv_auth_msg_auth_negotiate_issue"
215fcf3ce44SJohn Forte #define	ESC_EMLXS_04	"ESC_emlxs_cmpl_auth_msg_auth_negotiate_issue"
216fcf3ce44SJohn Forte 
217fcf3ce44SJohn Forte #define	ESC_EMLXS_05	"ESC_emlxs_rcv_auth_msg_unmapped_node"
218fcf3ce44SJohn Forte #define	ESC_EMLXS_06	"ESC_emlxs_issue_dhchap_challenge"
219fcf3ce44SJohn Forte #define	ESC_EMLXS_07	"ESC_emlxs_cmpl_dhchap_challenge_issue"
220fcf3ce44SJohn Forte 
221fcf3ce44SJohn Forte #define	ESC_EMLXS_08	"ESC_emlxs_rcv_auth_msg_dhchap_challenge_cmpl_wait4next"
222fcf3ce44SJohn Forte 
223fcf3ce44SJohn Forte #define	ESC_EMLXS_09	"ESC_emlxs_rcv_auth_msg_auth_negotiate_rcv"
224fcf3ce44SJohn Forte #define	ESC_EMLXS_10	"ESC_emlxs_cmpl_auth_msg_auth_negotiate_rcv"
225fcf3ce44SJohn Forte 
226*291a2b48SSukumar Swaminathan #define	ESC_EMLXS_11 	"ESC_emlxs_cmpl_cmpl_dhchap_reply_issue"
227fcf3ce44SJohn Forte #define	ESC_EMLXS_12	"ESC_emlxs_cmpl_dhchap_reply_issue"
228fcf3ce44SJohn Forte #define	ESC_EMLXS_13	"ESC_emlxs_cmpl_auth_msg_dhchap_reply_issue"
229fcf3ce44SJohn Forte 
230fcf3ce44SJohn Forte #define	ESC_EMLXS_14	"ESC_emlxs_cmpl_auth_msg_auth_negotiate_cmpl_wait4next"
231fcf3ce44SJohn Forte 
232fcf3ce44SJohn Forte #define	ESC_EMLXS_15	"ESC_emlxs_issue_dhchap_success"
233fcf3ce44SJohn Forte 
234fcf3ce44SJohn Forte #define	ESC_EMLXS_16	"ESC_emlxs_rcv_auth_msg_dhchap_challenge_issue"
235fcf3ce44SJohn Forte #define	ESC_EMLXS_17	"ESC_emlxs_cmpl_auth_msg_dhchap_challenge_issue"
236fcf3ce44SJohn Forte 
237fcf3ce44SJohn Forte #define	ESC_EMLXS_18	"ESC_emlxs_rcv_auth_msg_dhchap_reply_issue"
238fcf3ce44SJohn Forte 
239*291a2b48SSukumar Swaminathan #define	ESC_EMLXS_19 \
240*291a2b48SSukumar Swaminathan 	"ESC_emlxs_cmpl_auth_msg_dhchap_challenge_cmpl_wait4next"
241fcf3ce44SJohn Forte 
242fcf3ce44SJohn Forte #define	ESC_EMLXS_20	"ESC_emlxs_rcv_auth_msg_dhchap_reply_cmpl_wait4next"
243fcf3ce44SJohn Forte #define	ESC_EMLXS_21	"ESC_emlxs_cmpl_dhchap_success_issue"
244fcf3ce44SJohn Forte #define	ESC_EMLXS_22	"ESC_emlxs_cmpl_auth_msg_dhchap_success_issue"
245fcf3ce44SJohn Forte 
246fcf3ce44SJohn Forte #define	ESC_EMLXS_23	"ESC_emlxs_cmpl_auth_msg_dhchap_reply_cmpl_wait4next"
247fcf3ce44SJohn Forte 
248fcf3ce44SJohn Forte #define	ESC_EMLXS_24	"ESC_emlxs_rcv_auth_msg_dhchap_success_issue_wait4next"
249fcf3ce44SJohn Forte #define	ESC_EMLXS_25	"ESC_emlxs_cmpl_auth_msg_dhchap_success_issue_wait4next"
250fcf3ce44SJohn Forte 
251fcf3ce44SJohn Forte #define	ESC_EMLXS_26	"ESC_emlxs_rcv_auth_msg_dhchap_success_cmpl_wait4next"
252fcf3ce44SJohn Forte #define	ESC_EMLXS_27	"ESC_emlxs_cmpl_auth_msg_dhchap_success_cmpl_wait4next"
253fcf3ce44SJohn Forte 
254fcf3ce44SJohn Forte #define	ESC_EMLXS_28	"ESC_emlxs_issue_auth_reject"
255fcf3ce44SJohn Forte #define	ESC_EMLXS_29	"ESC_emlxs_cmpl_auth_reject_issue"
256fcf3ce44SJohn Forte 
257fcf3ce44SJohn Forte #define	ESC_EMLXS_30	"ESC_emlxs_rcv_auth_msg_npr_node"
258fcf3ce44SJohn Forte 
259fcf3ce44SJohn Forte #define	ESC_EMLXS_31	"ESC_emlxs_dhc_reauth_timeout"
260fcf3ce44SJohn Forte 
261fcf3ce44SJohn Forte #define	ESC_EMLXS_32	"ESC_emlxs_dhc_authrsp_timeout"
262fcf3ce44SJohn Forte 
263fcf3ce44SJohn Forte #define	ESC_EMLXS_33	"ESC_emlxs_ioctl_auth_setcfg"
264fcf3ce44SJohn Forte #define	ESC_EMLXS_34	"ESC_emlxs_ioctl_auth_setpwd"
265fcf3ce44SJohn Forte #define	ESC_EMLXS_35	"ESC_emlxs_ioctl_auth_delcfg"
266fcf3ce44SJohn Forte #define	ESC_EMLXS_36	"ESC_emlxs_ioctl_auth_delpwd"
267fcf3ce44SJohn Forte 
268fcf3ce44SJohn Forte 
269fcf3ce44SJohn Forte /* From HBAnyware dfc lib FC-SP */
270*291a2b48SSukumar Swaminathan typedef struct emlxs_auth_cfg
271*291a2b48SSukumar Swaminathan {
272*291a2b48SSukumar Swaminathan 	NAME_TYPE		local_entity;	/* host wwpn (NPIV support) */
273*291a2b48SSukumar Swaminathan 	NAME_TYPE		remote_entity;	/* switch or target wwpn */
274*291a2b48SSukumar Swaminathan 	uint32_t		authentication_timeout;
275*291a2b48SSukumar Swaminathan 	uint32_t		authentication_mode;
276*291a2b48SSukumar Swaminathan 	uint32_t		bidirectional:1;
277*291a2b48SSukumar Swaminathan 	uint32_t		reserved:31;
278*291a2b48SSukumar Swaminathan 	uint32_t		authentication_type_priority[4];
279*291a2b48SSukumar Swaminathan 	uint32_t		hash_priority[4];
280*291a2b48SSukumar Swaminathan 	uint32_t		dh_group_priority[8];
281*291a2b48SSukumar Swaminathan 	uint32_t		reauthenticate_time_interval;
282*291a2b48SSukumar Swaminathan 
283*291a2b48SSukumar Swaminathan 	dfc_auth_status_t	auth_status;
284*291a2b48SSukumar Swaminathan 	time_t			auth_time;
285*291a2b48SSukumar Swaminathan 	struct emlxs_node	*node;
286*291a2b48SSukumar Swaminathan 
287*291a2b48SSukumar Swaminathan 	struct emlxs_auth_cfg	*prev;
288*291a2b48SSukumar Swaminathan 	struct emlxs_auth_cfg	*next;
289fcf3ce44SJohn Forte } emlxs_auth_cfg_t;
290fcf3ce44SJohn Forte 
291fcf3ce44SJohn Forte 
292*291a2b48SSukumar Swaminathan typedef struct emlxs_auth_key
293*291a2b48SSukumar Swaminathan {
294*291a2b48SSukumar Swaminathan 	NAME_TYPE		local_entity;		/* host wwpn */
295*291a2b48SSukumar Swaminathan 							/* (NPIV support) */
296*291a2b48SSukumar Swaminathan 	NAME_TYPE		remote_entity;		/* switch or target */
297*291a2b48SSukumar Swaminathan 							/* wwpn */
298*291a2b48SSukumar Swaminathan 	uint16_t		local_password_length;
299*291a2b48SSukumar Swaminathan 	uint16_t		local_password_type;
300*291a2b48SSukumar Swaminathan 	uint8_t			local_password[128];	/* hba authenticates */
301*291a2b48SSukumar Swaminathan 							/* to switch  */
302*291a2b48SSukumar Swaminathan 	uint16_t		remote_password_length;
303*291a2b48SSukumar Swaminathan 	uint16_t		remote_password_type;
304*291a2b48SSukumar Swaminathan 	uint8_t			remote_password[128];	/* hba authenticates */
305*291a2b48SSukumar Swaminathan 							/* to switch  */
306*291a2b48SSukumar Swaminathan 
307*291a2b48SSukumar Swaminathan 	struct emlxs_node	*node;
308*291a2b48SSukumar Swaminathan 
309*291a2b48SSukumar Swaminathan 	struct emlxs_auth_key	*prev;
310*291a2b48SSukumar Swaminathan 	struct emlxs_auth_key	*next;
311fcf3ce44SJohn Forte } emlxs_auth_key_t;
312fcf3ce44SJohn Forte 
313fcf3ce44SJohn Forte 
314*291a2b48SSukumar Swaminathan typedef struct emlxs_auth_misc
315*291a2b48SSukumar Swaminathan {
316*291a2b48SSukumar Swaminathan 	uint8_t		bi_cval[20];		/* our challenge for bi-dir */
317*291a2b48SSukumar Swaminathan 						/* auth in reply as initiator */
318*291a2b48SSukumar Swaminathan 	uint32_t	bi_cval_len;		/* 16 for MD5, 20 for SHA1 */
319*291a2b48SSukumar Swaminathan 	uint8_t		pub_key[512];		/* max is 512 bytes value of */
320*291a2b48SSukumar Swaminathan 						/* (g^y mod p) */
321*291a2b48SSukumar Swaminathan 	uint32_t	pubkey_len;		/* real length of the pub key */
322*291a2b48SSukumar Swaminathan 	uint8_t		ses_key[512];		/* session key: value of */
323*291a2b48SSukumar Swaminathan 						/* (g^xy mod p) */
324*291a2b48SSukumar Swaminathan 	uint32_t	seskey_len;		/* real length of the session */
325*291a2b48SSukumar Swaminathan 						/* key */
326fcf3ce44SJohn Forte 
327fcf3ce44SJohn Forte 	/* The following are parameters when host is the responder */
328*291a2b48SSukumar Swaminathan 	uint8_t		hrsp_cval[20];		/* challenge value from host */
329*291a2b48SSukumar Swaminathan 						/* as responder */
330*291a2b48SSukumar Swaminathan 	uint32_t	hrsp_cval_len;		/* host as the responder its */
331*291a2b48SSukumar Swaminathan 						/* challenge value len */
332*291a2b48SSukumar Swaminathan 	uint8_t		hrsp_priv_key[20];	/* the private key generated */
333*291a2b48SSukumar Swaminathan 						/* in host as responder */
334*291a2b48SSukumar Swaminathan 	uint8_t		hrsp_pub_key[512];	/* public key calculated when */
335*291a2b48SSukumar Swaminathan 						/* host as responder */
336*291a2b48SSukumar Swaminathan 	uint32_t	hrsp_pubkey_len;	/* public key length when */
337*291a2b48SSukumar Swaminathan 						/* host is responder */
338*291a2b48SSukumar Swaminathan 	uint8_t		hrsp_ses_key[512];	/* session key computed when */
339*291a2b48SSukumar Swaminathan 						/* host is responder */
340*291a2b48SSukumar Swaminathan 	uint32_t	hrsp_seskey_len;	/* session key length when */
341*291a2b48SSukumar Swaminathan 						/* host is responder */
342fcf3ce44SJohn Forte } emlxs_auth_misc_t;
343fcf3ce44SJohn Forte 
344fcf3ce44SJohn Forte 
345fcf3ce44SJohn Forte /*
346fcf3ce44SJohn Forte  * emlxs_port_dhc struct to be used by emlxs_port_t in emlxs_fc.h
347fcf3ce44SJohn Forte  *
348fcf3ce44SJohn Forte  * This structure contains all the data used by DHCHAP.
349fcf3ce44SJohn Forte  * They are from EMLXSHBA_t in emlxs driver.
350fcf3ce44SJohn Forte  *
351fcf3ce44SJohn Forte  */
352*291a2b48SSukumar Swaminathan typedef struct emlxs_port_dhc
353*291a2b48SSukumar Swaminathan {
354fcf3ce44SJohn Forte 
355*291a2b48SSukumar Swaminathan 	int32_t			state;
356fcf3ce44SJohn Forte #define	ELX_FABRIC_STATE_UNKNOWN	0x00
357fcf3ce44SJohn Forte #define	ELX_FABRIC_AUTH_DISABLED	0x01
358fcf3ce44SJohn Forte #define	ELX_FABRIC_AUTH_FAILED		0x02
359fcf3ce44SJohn Forte #define	ELX_FABRIC_AUTH_SUCCESS		0x03
360fcf3ce44SJohn Forte #define	ELX_FABRIC_IN_AUTH		0x04
361fcf3ce44SJohn Forte #define	ELX_FABRIC_IN_REAUTH		0x05
362fcf3ce44SJohn Forte 
363*291a2b48SSukumar Swaminathan 	dfc_auth_status_t	auth_status;  /* Fabric auth status */
364*291a2b48SSukumar Swaminathan 	time_t			auth_time;
365fcf3ce44SJohn Forte 
366fcf3ce44SJohn Forte } emlxs_port_dhc_t;
367fcf3ce44SJohn Forte 
368fcf3ce44SJohn Forte 
369fcf3ce44SJohn Forte /* Node Events */
370*291a2b48SSukumar Swaminathan #define	NODE_EVENT_DEVICE_RM		0x0	/* Auth response timeout and */
371*291a2b48SSukumar Swaminathan 						/* fail */
372*291a2b48SSukumar Swaminathan #define	NODE_EVENT_DEVICE_RECOVERY	0x1	/* Auth response timeout and */
373*291a2b48SSukumar Swaminathan 						/* recovery */
374fcf3ce44SJohn Forte #define	NODE_EVENT_RCV_AUTH_MSG		0x2	/* Unsolicited Auth received */
375fcf3ce44SJohn Forte #define	NODE_EVENT_CMPL_AUTH_MSG	0x3
376fcf3ce44SJohn Forte #define	NODE_EVENT_MAX_EVENT		0x4
377fcf3ce44SJohn Forte 
378fcf3ce44SJohn Forte /*
379fcf3ce44SJohn Forte  * emlxs_node_dhc struct to be used in emlxs_node_t.
380fcf3ce44SJohn Forte  * They are from emlxs_nodelist_t in emlxs driver.
381fcf3ce44SJohn Forte  */
382*291a2b48SSukumar Swaminathan typedef struct emlxs_node_dhc
383*291a2b48SSukumar Swaminathan {
384*291a2b48SSukumar Swaminathan 	uint16_t		state;		/* used for state machine */
385fcf3ce44SJohn Forte #define	NODE_STATE_UNKNOWN				0x00
386*291a2b48SSukumar Swaminathan #define	NODE_STATE_AUTH_DISABLED 			0x01
387fcf3ce44SJohn Forte #define	NODE_STATE_AUTH_FAILED				0x02
388fcf3ce44SJohn Forte #define	NODE_STATE_AUTH_SUCCESS				0x03
389fcf3ce44SJohn Forte #define	NODE_STATE_AUTH_NEGOTIATE_ISSUE			0x04
390fcf3ce44SJohn Forte #define	NODE_STATE_AUTH_NEGOTIATE_RCV			0x05
391fcf3ce44SJohn Forte #define	NODE_STATE_AUTH_NEGOTIATE_CMPL_WAIT4NEXT	0x06
392fcf3ce44SJohn Forte #define	NODE_STATE_DHCHAP_CHALLENGE_ISSUE		0x07
393fcf3ce44SJohn Forte #define	NODE_STATE_DHCHAP_REPLY_ISSUE			0x08
394fcf3ce44SJohn Forte #define	NODE_STATE_DHCHAP_CHALLENGE_CMPL_WAIT4NEXT	0x09
395fcf3ce44SJohn Forte #define	NODE_STATE_DHCHAP_REPLY_CMPL_WAIT4NEXT		0x0A
396fcf3ce44SJohn Forte #define	NODE_STATE_DHCHAP_SUCCESS_ISSUE			0x0B
397fcf3ce44SJohn Forte #define	NODE_STATE_DHCHAP_SUCCESS_ISSUE_WAIT4NEXT	0x0C
398fcf3ce44SJohn Forte #define	NODE_STATE_DHCHAP_SUCCESS_CMPL_WAIT4NEXT	0x0D
399fcf3ce44SJohn Forte #define	NODE_STATE_NOCHANGE				0xFFFFFFFF
400fcf3ce44SJohn Forte 
401*291a2b48SSukumar Swaminathan 	uint16_t		prev_state;  /* for info only */
402fcf3ce44SJohn Forte 
403*291a2b48SSukumar Swaminathan 	uint32_t		disc_refcnt;
404fcf3ce44SJohn Forte 
405*291a2b48SSukumar Swaminathan 	emlxs_auth_cfg_t	auth_cfg;
406*291a2b48SSukumar Swaminathan 	emlxs_auth_key_t	auth_key;
407fcf3ce44SJohn Forte 
408*291a2b48SSukumar Swaminathan 	uint32_t		nlp_authrsp_tmo;	/* Response timeout */
409*291a2b48SSukumar Swaminathan 	uint32_t		nlp_authrsp_tmocnt;
410fcf3ce44SJohn Forte 
411*291a2b48SSukumar Swaminathan 	uint32_t		nlp_auth_tranid_ini;	/* tran_id when this */
412*291a2b48SSukumar Swaminathan 							/* node is initiator */
413*291a2b48SSukumar Swaminathan 	uint32_t		nlp_auth_tranid_rsp;	/* tran_id when this */
414*291a2b48SSukumar Swaminathan 							/* node is responder */
415fcf3ce44SJohn Forte 
416*291a2b48SSukumar Swaminathan 	uint32_t		nlp_auth_flag;		/* 1:initiator */
417*291a2b48SSukumar Swaminathan 							/* 2:responder */
418*291a2b48SSukumar Swaminathan 	uint32_t		nlp_auth_limit;		/* 1: NULL DHCHAP */
419*291a2b48SSukumar Swaminathan 							/* 2: full support */
420fcf3ce44SJohn Forte 
421fcf3ce44SJohn Forte 	/* information in DHCHAP_Challenge as the auth responder */
422*291a2b48SSukumar Swaminathan 	uint32_t		nlp_auth_hashid;
423*291a2b48SSukumar Swaminathan 	uint32_t		nlp_auth_dhgpid;
424*291a2b48SSukumar Swaminathan 	uint32_t		nlp_auth_bidir;
425*291a2b48SSukumar Swaminathan 	NAME_TYPE		nlp_auth_wwn;
426fcf3ce44SJohn Forte 
427*291a2b48SSukumar Swaminathan 	emlxs_auth_misc_t	nlp_auth_misc;
428fcf3ce44SJohn Forte 
429*291a2b48SSukumar Swaminathan 	uint32_t		nlp_reauth_tmo;
430*291a2b48SSukumar Swaminathan 	uint16_t		nlp_reauth_status;
431fcf3ce44SJohn Forte #define	NLP_HOST_REAUTH_DISABLED	0x0
432fcf3ce44SJohn Forte #define	NLP_HOST_REAUTH_ENABLED		0x1
433fcf3ce44SJohn Forte #define	NLP_HOST_REAUTH_IN_PROGRESS	0x2
434fcf3ce44SJohn Forte 
435*291a2b48SSukumar Swaminathan 	uint32_t		nlp_fb_vendor;
436*291a2b48SSukumar Swaminathan #define	NLP_FABRIC_CISCO	0x1
437*291a2b48SSukumar Swaminathan #define	NLP_FABRIC_OTHERS	0x2
438fcf3ce44SJohn Forte 
439*291a2b48SSukumar Swaminathan 	uint32_t		fc_dhchap_success_expected;
440fcf3ce44SJohn Forte 
441fcf3ce44SJohn Forte 	/* hash_id, dhgp_id are set from responder, host is the initiator */
442*291a2b48SSukumar Swaminathan 	uint32_t		hash_id;		/* 0x05 for MD5 */
443*291a2b48SSukumar Swaminathan 							/* 0x06 for SHA-1 */
444*291a2b48SSukumar Swaminathan 	uint32_t		dhgp_id;		/* DH grp identifier */
445*291a2b48SSukumar Swaminathan 
446*291a2b48SSukumar Swaminathan 	uint8_t			bi_cval[20];		/* our challenge for */
447*291a2b48SSukumar Swaminathan 							/* bi-dir auth in */
448*291a2b48SSukumar Swaminathan 							/* reply as initiator */
449*291a2b48SSukumar Swaminathan 	uint32_t		bi_cval_len;		/* 16 for MD5 */
450*291a2b48SSukumar Swaminathan 							/* 20 for SHA1 */
451*291a2b48SSukumar Swaminathan 	uint8_t			pub_key[512];		/* max is 512 bytes */
452*291a2b48SSukumar Swaminathan 							/* value (g^y mod p) */
453*291a2b48SSukumar Swaminathan 	uint32_t		pubkey_len;		/* real length of the */
454*291a2b48SSukumar Swaminathan 							/* pub key */
455*291a2b48SSukumar Swaminathan 	uint8_t			ses_key[512];		/* session key: */
456*291a2b48SSukumar Swaminathan 							/* value (g^xy mod p) */
457*291a2b48SSukumar Swaminathan 	uint32_t		seskey_len;		/* real length of the */
458*291a2b48SSukumar Swaminathan 							/* session key */
459fcf3ce44SJohn Forte 
460fcf3ce44SJohn Forte 	/* The following are parameters when host is the responder */
461fcf3ce44SJohn Forte 
462*291a2b48SSukumar Swaminathan 	uint8_t			hrsp_cval[20];		/* challenge value */
463*291a2b48SSukumar Swaminathan 	uint32_t		hrsp_cval_len;		/* challenge value */
464*291a2b48SSukumar Swaminathan 							/* length */
465*291a2b48SSukumar Swaminathan 	uint8_t			hrsp_priv_key[20];	/* private key */
466*291a2b48SSukumar Swaminathan 							/* generated */
467*291a2b48SSukumar Swaminathan 	uint8_t			hrsp_pub_key[512];	/* public key */
468*291a2b48SSukumar Swaminathan 							/* computed */
469*291a2b48SSukumar Swaminathan 	uint32_t		hrsp_pubkey_len;	/* public key length */
470*291a2b48SSukumar Swaminathan 	uint8_t			hrsp_ses_key[512];	/* session key */
471*291a2b48SSukumar Swaminathan 							/* computed */
472*291a2b48SSukumar Swaminathan 	uint32_t		hrsp_seskey_len;	/* session key length */
473*291a2b48SSukumar Swaminathan 
474*291a2b48SSukumar Swaminathan 	uint8_t			*deferred_sbp;		/* Pending IO for */
475*291a2b48SSukumar Swaminathan 							/* auth completion */
476*291a2b48SSukumar Swaminathan 	uint8_t			*deferred_ubp;
477*291a2b48SSukumar Swaminathan 
478*291a2b48SSukumar Swaminathan 	uint32_t		flag;
479fcf3ce44SJohn Forte #define	NLP_REMOTE_AUTH			0x00000001
480fcf3ce44SJohn Forte #define	NLP_SET_REAUTH_TIME		0x00000002
481fcf3ce44SJohn Forte 
482*291a2b48SSukumar Swaminathan 	emlxs_auth_cfg_t	*parent_auth_cfg;	/* Original auth_cfg */
483*291a2b48SSukumar Swaminathan 							/* table entry */
484*291a2b48SSukumar Swaminathan 	emlxs_auth_key_t	*parent_auth_key;	/* Original auth_key */
485*291a2b48SSukumar Swaminathan 							/* table entry */
486fcf3ce44SJohn Forte } emlxs_node_dhc_t;
487fcf3ce44SJohn Forte 
488fcf3ce44SJohn Forte 
489fcf3ce44SJohn Forte /* For NULL DHCHAP with MD5 and SHA-1 */
490*291a2b48SSukumar Swaminathan typedef struct _AUTH_NEGOT_PARAMS_1
491*291a2b48SSukumar Swaminathan {
492*291a2b48SSukumar Swaminathan 	uint16_t  name_tag;		/* set to 0x0001 */
493*291a2b48SSukumar Swaminathan 	uint16_t  name_len;		/* set to 0x0008 */
494*291a2b48SSukumar Swaminathan 	NAME_TYPE nodeName;		/* WWPN */
495*291a2b48SSukumar Swaminathan 	uint32_t  proto_num;		/* set to 0x5 */
496*291a2b48SSukumar Swaminathan 	uint32_t  para_len;		/* set to 0x28 i.e., 40 bytes */
497*291a2b48SSukumar Swaminathan 	uint32_t  proto_id;		/* set to HDCHAP */
498*291a2b48SSukumar Swaminathan 	uint16_t  HashList_tag;		/* set to 0x0001 */
499*291a2b48SSukumar Swaminathan 	uint16_t  HashList_wcnt;	/* set to 0x0002 i.e. MD5 and SHA-1 */
500*291a2b48SSukumar Swaminathan 	uint32_t  HashList_value1;	/* set to MD5 or SHA1 ID 0x00000005,6 */
501*291a2b48SSukumar Swaminathan 	uint16_t  DHgIDList_tag;	/* set to 0x0002 */
502*291a2b48SSukumar Swaminathan 	uint16_t  DHgIDList_wnt;	/* set to 0x0005 i.e., Full DH groups */
503*291a2b48SSukumar Swaminathan 	uint32_t  DHgIDList_g0;		/* set to 0x0000 0000 */
504*291a2b48SSukumar Swaminathan 	uint32_t  DHgIDList_g1;		/* set to 0x0000 0001 */
505*291a2b48SSukumar Swaminathan 	uint32_t  DHgIDList_g2;		/* set to 0x0000 0002 */
506*291a2b48SSukumar Swaminathan 	uint32_t  DHgIDList_g3;		/* set to 0x0000 0003 */
507*291a2b48SSukumar Swaminathan 	uint32_t  DHgIDList_g4;		/* set to 0x0000 0004 */
508fcf3ce44SJohn Forte } AUTH_NEGOT_PARAMS_1;
509fcf3ce44SJohn Forte 
510fcf3ce44SJohn Forte 
511*291a2b48SSukumar Swaminathan typedef struct _AUTH_NEGOT_PARAMS_2
512*291a2b48SSukumar Swaminathan {
513*291a2b48SSukumar Swaminathan 	uint16_t  name_tag;		/* set to 0x0001 */
514*291a2b48SSukumar Swaminathan 	uint16_t  name_len;		/* set to 0x0008 */
515*291a2b48SSukumar Swaminathan 	NAME_TYPE nodeName;		/* WWPN */
516*291a2b48SSukumar Swaminathan 	uint32_t  proto_num;		/* set to 0x5 */
517*291a2b48SSukumar Swaminathan 	uint32_t  para_len;		/* set to 0x28 i.e., 40 bytes */
518*291a2b48SSukumar Swaminathan 	uint32_t  proto_id;		/* set to HDCHAP */
519*291a2b48SSukumar Swaminathan 	uint16_t  HashList_tag;		/* set to 0x0001 */
520*291a2b48SSukumar Swaminathan 	uint16_t  HashList_wcnt;	/* set to 0x0002 i.e. MD5 and SHA-1 */
521*291a2b48SSukumar Swaminathan 	uint32_t  HashList_value1;	/* set to MD5's   ID 0x00000005 */
522*291a2b48SSukumar Swaminathan 	uint32_t  HashList_value2;	/* set to SHA-1's ID 0x00000006 */
523*291a2b48SSukumar Swaminathan 	uint16_t  DHgIDList_tag;	/* set to 0x0002 */
524*291a2b48SSukumar Swaminathan 	uint16_t  DHgIDList_wnt;	/* set to 0x0005 i.e., Full DH groups */
525*291a2b48SSukumar Swaminathan 	uint32_t  DHgIDList_g0;		/* set to 0x0000 0000 */
526*291a2b48SSukumar Swaminathan 	uint32_t  DHgIDList_g1;		/* set to 0x0000 0001 */
527*291a2b48SSukumar Swaminathan 	uint32_t  DHgIDList_g2;		/* set to 0x0000 0002 */
528*291a2b48SSukumar Swaminathan 	uint32_t  DHgIDList_g3;		/* set to 0x0000 0003 */
529*291a2b48SSukumar Swaminathan 	uint32_t  DHgIDList_g4;		/* set to 0x0000 0004 */
530fcf3ce44SJohn Forte } AUTH_NEGOT_PARAMS_2;
531fcf3ce44SJohn Forte 
532fcf3ce44SJohn Forte 
533fcf3ce44SJohn Forte /* For NULL DHCHAP with MD5 and SHA-1 */
534*291a2b48SSukumar Swaminathan typedef struct _AUTH_NEGOT_PARAMS
535*291a2b48SSukumar Swaminathan {
536*291a2b48SSukumar Swaminathan 	uint16_t  name_tag;		/* set to 0x0001 */
537*291a2b48SSukumar Swaminathan 	uint16_t  name_len;		/* set to 0x0008 */
538*291a2b48SSukumar Swaminathan 	NAME_TYPE nodeName;		/* WWPN */
539*291a2b48SSukumar Swaminathan 	uint32_t  proto_num;		/* set to 0x5 */
540*291a2b48SSukumar Swaminathan 	uint32_t  para_len;		/* set to 0x28 i.e., 40 bytes */
541*291a2b48SSukumar Swaminathan 	uint32_t  proto_id;		/* set to HDCHAP */
542*291a2b48SSukumar Swaminathan 	uint16_t  HashList_tag;		/* set to 0x0001 */
543*291a2b48SSukumar Swaminathan 	uint16_t  HashList_wcnt;	/* set to 0x0002 i.e. MD5 and SHA-1 */
544*291a2b48SSukumar Swaminathan 	uint32_t  HashList_value1;	/* set to MD5's   ID 0x00000005 */
545*291a2b48SSukumar Swaminathan 	uint32_t  HashList_value2;	/* set to SHA-1's ID 0x00000006 */
546*291a2b48SSukumar Swaminathan 	uint16_t  DHgIDList_tag;	/* set to 0x0002 */
547*291a2b48SSukumar Swaminathan 	uint16_t  DHgIDList_wnt;	/* set to 0x0005 i.e., Full DH groups */
548*291a2b48SSukumar Swaminathan 	uint32_t  DHgIDList_g0;		/* set to 0x0000 0000 */
549*291a2b48SSukumar Swaminathan 	uint32_t  DHgIDList_g1;		/* set to 0x0000 0001 */
550*291a2b48SSukumar Swaminathan 	uint32_t  DHgIDList_g2;		/* set to 0x0000 0002 */
551*291a2b48SSukumar Swaminathan 	uint32_t  DHgIDList_g3;		/* set to 0x0000 0003 */
552*291a2b48SSukumar Swaminathan 	uint32_t  DHgIDList_g4;		/* set to 0x0000 0004 */
553fcf3ce44SJohn Forte } AUTH_NEGOT_PARAMS;
554fcf3ce44SJohn Forte 
555*291a2b48SSukumar Swaminathan typedef struct _AUTH_NEGOT_PARAMS_NULL_1
556*291a2b48SSukumar Swaminathan {
557*291a2b48SSukumar Swaminathan 	uint16_t  name_tag;		/* set to 0x0001 */
558*291a2b48SSukumar Swaminathan 	uint16_t  name_len;		/* set to 0x0008 */
559*291a2b48SSukumar Swaminathan 	NAME_TYPE nodeName;		/* WWPN */
560*291a2b48SSukumar Swaminathan 	uint32_t  proto_num;		/* set to 0x5 */
561*291a2b48SSukumar Swaminathan 	uint32_t  para_len;		/* set to 0x28 i.e., 40 bytes */
562*291a2b48SSukumar Swaminathan 	uint32_t  proto_id;		/* set to HDCHAP */
563*291a2b48SSukumar Swaminathan 	uint16_t  HashList_tag;		/* set to 0x0001 */
564*291a2b48SSukumar Swaminathan 	uint16_t  HashList_wcnt;	/* set to 0x0002 i.e. MD5 and SHA-1 */
565*291a2b48SSukumar Swaminathan 	uint32_t  HashList_value1;	/* set to MD5's   ID 0x00000005 */
566*291a2b48SSukumar Swaminathan 	uint16_t  DHgIDList_tag;	/* set to 0x0002 */
567*291a2b48SSukumar Swaminathan 	uint16_t  DHgIDList_wnt;	/* set to 0x0005 i.e., Full DH groups */
568*291a2b48SSukumar Swaminathan 	uint32_t  DHgIDList_g0;		/* set to 0x0000 0000 */
569fcf3ce44SJohn Forte } AUTH_NEGOT_PARAMS_NULL_1;
570fcf3ce44SJohn Forte 
571*291a2b48SSukumar Swaminathan typedef struct _AUTH_NEGOT_PARAMS_NULL_2
572*291a2b48SSukumar Swaminathan {
573*291a2b48SSukumar Swaminathan 	uint16_t  name_tag;		/* set to 0x0001 */
574*291a2b48SSukumar Swaminathan 	uint16_t  name_len;		/* set to 0x0008 */
575*291a2b48SSukumar Swaminathan 	NAME_TYPE nodeName;		/* WWPN */
576*291a2b48SSukumar Swaminathan 	uint32_t  proto_num;		/* set to 0x5 */
577*291a2b48SSukumar Swaminathan 	uint32_t  para_len;		/* set to 0x28 i.e., 40 bytes */
578*291a2b48SSukumar Swaminathan 	uint32_t  proto_id;		/* set to HDCHAP */
579*291a2b48SSukumar Swaminathan 	uint16_t  HashList_tag;		/* set to 0x0001 */
580*291a2b48SSukumar Swaminathan 	uint16_t  HashList_wcnt;	/* set to 0x0002 i.e. MD5 and SHA-1 */
581*291a2b48SSukumar Swaminathan 	uint32_t  HashList_value1;	/* set to MD5's   ID 0x00000005 */
582*291a2b48SSukumar Swaminathan 	uint32_t  HashList_value2;
583*291a2b48SSukumar Swaminathan 	uint16_t  DHgIDList_tag;	/* set to 0x0002 */
584*291a2b48SSukumar Swaminathan 	uint16_t  DHgIDList_wnt;	/* set to 0x0005 i.e., Full DH groups */
585*291a2b48SSukumar Swaminathan 	uint32_t  DHgIDList_g0;		/* set to 0x0000 0000 */
586fcf3ce44SJohn Forte } AUTH_NEGOT_PARAMS_NULL_2;
587fcf3ce44SJohn Forte 
588fcf3ce44SJohn Forte 
589fcf3ce44SJohn Forte /* Generic AUTH ELS Header */
590*291a2b48SSukumar Swaminathan typedef struct _AUTH_MSG_HDR
591*291a2b48SSukumar Swaminathan {
592fcf3ce44SJohn Forte 	/* 20 bytes in total */
593*291a2b48SSukumar Swaminathan 	uint8_t		auth_els_code;	/* always 0x90h */
594*291a2b48SSukumar Swaminathan 	uint8_t		auth_els_flags;
595*291a2b48SSukumar Swaminathan 	uint8_t		auth_msg_code;	/* see above */
596*291a2b48SSukumar Swaminathan 	uint8_t		proto_version;
597*291a2b48SSukumar Swaminathan 	uint32_t	msg_len;	/* size of msg payload in byte */
598*291a2b48SSukumar Swaminathan 	uint32_t	tran_id;
599*291a2b48SSukumar Swaminathan 	uint16_t	name_tag;	/* set to 0x0001 */
600*291a2b48SSukumar Swaminathan 	uint16_t	name_len;	/* set to 0x0008 */
601*291a2b48SSukumar Swaminathan 	NAME_TYPE	nodeName;	/* WWPN */
602fcf3ce44SJohn Forte } AUTH_MSG_HDR;
603fcf3ce44SJohn Forte 
604fcf3ce44SJohn Forte 
605*291a2b48SSukumar Swaminathan typedef struct _SHA1_CVAL
606*291a2b48SSukumar Swaminathan {
607fcf3ce44SJohn Forte 	uint8_t val[20];
608fcf3ce44SJohn Forte } SHA1_CVAL;
609fcf3ce44SJohn Forte 
610fcf3ce44SJohn Forte 
611*291a2b48SSukumar Swaminathan typedef struct _MD5_CVAL
612*291a2b48SSukumar Swaminathan {
613*291a2b48SSukumar Swaminathan 	uint8_t	val[16];
614fcf3ce44SJohn Forte } MD5_CVAL;
615fcf3ce44SJohn Forte 
616fcf3ce44SJohn Forte 
617*291a2b48SSukumar Swaminathan union challenge_val
618*291a2b48SSukumar Swaminathan {
619*291a2b48SSukumar Swaminathan 	SHA1_CVAL	sha1;
620*291a2b48SSukumar Swaminathan 	MD5_CVAL	md5;
621fcf3ce44SJohn Forte };
622fcf3ce44SJohn Forte 
623fcf3ce44SJohn Forte 
624fcf3ce44SJohn Forte /* DHCHAP_Replay */
625*291a2b48SSukumar Swaminathan typedef struct _DHCHAP_REPLY_HDR
626*291a2b48SSukumar Swaminathan {
627*291a2b48SSukumar Swaminathan 	uint8_t  auth_els_code;	/* always 0x90h */
628*291a2b48SSukumar Swaminathan 	uint8_t  auth_els_flags;
629*291a2b48SSukumar Swaminathan 	uint8_t  auth_msg_code;	/* see above */
630*291a2b48SSukumar Swaminathan 	uint8_t  proto_version;
631fcf3ce44SJohn Forte 	uint32_t msg_len;	/* size of msg payload in byte */
632fcf3ce44SJohn Forte 	uint32_t tran_id;	/* transaction id */
633fcf3ce44SJohn Forte } DHCHAP_REPLY_HDR;
634fcf3ce44SJohn Forte 
635fcf3ce44SJohn Forte 
636fcf3ce44SJohn Forte /* DHCHAP_Challenge */
637*291a2b48SSukumar Swaminathan typedef struct _DHCHAP_CHALL_NULL
638*291a2b48SSukumar Swaminathan {
639*291a2b48SSukumar Swaminathan 	AUTH_MSG_HDR	msg_hdr;
640*291a2b48SSukumar Swaminathan 	uint32_t	hash_id;
641*291a2b48SSukumar Swaminathan 	uint32_t	dhgp_id;
642*291a2b48SSukumar Swaminathan 	uint32_t	cval_len;
643fcf3ce44SJohn Forte } DHCHAP_CHALL_NULL;
644fcf3ce44SJohn Forte 
645*291a2b48SSukumar Swaminathan typedef struct _DHCHAP_CHALL
646*291a2b48SSukumar Swaminathan {
647*291a2b48SSukumar Swaminathan 	DHCHAP_CHALL_NULL	cnul;
648*291a2b48SSukumar Swaminathan 	uint8_t			*dhval;
649fcf3ce44SJohn Forte } DHCHAP_CHALL;
650fcf3ce44SJohn Forte 
651fcf3ce44SJohn Forte /*
652*291a2b48SSukumar Swaminathan  * size of msg_payload is variable based on the different protocol
653*291a2b48SSukumar Swaminathan  * parameters supported in the driver.
654*291a2b48SSukumar Swaminathan  *
655*291a2b48SSukumar Swaminathan  * For DHCHAP we plan to support NULL, group 1, 2, 3, 4.
656fcf3ce44SJohn Forte  *
657fcf3ce44SJohn Forte  * For NULL DHCHAP protocol only: of these protocol identifiers,
658*291a2b48SSukumar Swaminathan  * we need name_tag = 2 bytes name_len_size = 2 bytes name_len = 8 bytes
659*291a2b48SSukumar Swaminathan  * number of usable auth proto = 4 bytes
660fcf3ce44SJohn Forte  *
661fcf3ce44SJohn Forte  * --------- for example for NULL DHCAHP only --------------------
662*291a2b48SSukumar Swaminathan  * auth proto #1 len = 4 bytes #1 ID  = 4 bytes #1 params = 4 + 16 bytes.
663*291a2b48SSukumar Swaminathan  * ------ Total for NULL DHCHAP = (16 + 12 + 16 ) = 44 bytes.
664fcf3ce44SJohn Forte  *
665*291a2b48SSukumar Swaminathan  * If number of usable auth proto is 5, then we should have 5 auth proto params.
666*291a2b48SSukumar Swaminathan  * assume we are using name_tag 0x0001, then auth name in total = 12 bytes.
667fcf3ce44SJohn Forte  *
668fcf3ce44SJohn Forte  * 12 bytes + 4 bytes = 16 bytes. 4 + 4 + 4 = 12 bytes
669*291a2b48SSukumar Swaminathan  * (num of usable auth proto size = 4
670*291a2b48SSukumar Swaminathan  * auth proto params #1 len size = 4
671*291a2b48SSukumar Swaminathan  * auth prot ID for #1 size  = 4
672fcf3ce44SJohn Forte  *
673*291a2b48SSukumar Swaminathan  * For DHCHAP param: HashList	2 param tag size (set to 0x0001 as HashList)
674*291a2b48SSukumar Swaminathan  * 2 param word cnt size (set to 0x0002 as two hash funcs)
675*291a2b48SSukumar Swaminathan  * 8 for hash ids: MD5 and SHA-1 DHgIDList
676*291a2b48SSukumar Swaminathan  * 2 param tag size (set to 0x0002 as DHgIDList)
677*291a2b48SSukumar Swaminathan  * 2 param word cnt size (set to 0x0005 as NULL and 1/2/3/4 groups) 20 for
678*291a2b48SSukumar Swaminathan  * 5 groups 0x0000 0000 0x0000 0001 0x0000 0002 0x0000 0003 0x0000 0004
679*291a2b48SSukumar Swaminathan  * Total for FULL group support (16 + 12 + 12 + 24 ) = 64 bytes.
680fcf3ce44SJohn Forte  *
681fcf3ce44SJohn Forte  */
682fcf3ce44SJohn Forte 
683*291a2b48SSukumar Swaminathan typedef struct _AUTH_MSG_NEGOT_1 { /* in Big Endian format */
684*291a2b48SSukumar Swaminathan 	uint8_t			auth_els_code;  /* always 0x90h */
685*291a2b48SSukumar Swaminathan 	uint8_t			auth_els_flags;
686*291a2b48SSukumar Swaminathan 	uint8_t			auth_msg_code;  /* see above */
687*291a2b48SSukumar Swaminathan 	uint8_t			proto_version;
688*291a2b48SSukumar Swaminathan 	uint32_t		msg_len;	/* size of msg payload */
689*291a2b48SSukumar Swaminathan 						/* in byte */
690*291a2b48SSukumar Swaminathan 	uint32_t		tran_id;	/* transaction identifier */
691fcf3ce44SJohn Forte 
692fcf3ce44SJohn Forte 	/* anything else is variable in size (bytes) */
693fcf3ce44SJohn Forte 	/* uint8_t   msg_payload[MAX_AUTH_MSG_SIZE]; */
694*291a2b48SSukumar Swaminathan 	AUTH_NEGOT_PARAMS_1	params;
695fcf3ce44SJohn Forte } AUTH_MSG_NEGOT_1, *PAUTH_MSG_NEGOT_1;
696fcf3ce44SJohn Forte 
697fcf3ce44SJohn Forte 
698*291a2b48SSukumar Swaminathan typedef struct _AUTH_MSG_NEGOT_2 { /* in Big Endian format */
699*291a2b48SSukumar Swaminathan 	uint8_t			auth_els_code;  /* always 0x90h */
700*291a2b48SSukumar Swaminathan 	uint8_t			auth_els_flags;
701*291a2b48SSukumar Swaminathan 	uint8_t			auth_msg_code;  /* see above */
702*291a2b48SSukumar Swaminathan 	uint8_t			proto_version;
703*291a2b48SSukumar Swaminathan 	uint32_t		msg_len;	/* size of msg payload */
704*291a2b48SSukumar Swaminathan 						/* in byte */
705*291a2b48SSukumar Swaminathan 	uint32_t		tran_id;	/* transaction identifier */
706fcf3ce44SJohn Forte 
707fcf3ce44SJohn Forte 	/* anything else is variable in size (bytes) */
708fcf3ce44SJohn Forte 	/* uint8_t   msg_payload[MAX_AUTH_MSG_SIZE]; */
709*291a2b48SSukumar Swaminathan 	AUTH_NEGOT_PARAMS_2	params;
710fcf3ce44SJohn Forte } AUTH_MSG_NEGOT_2, *PAUTH_MSG_NEGOT_2;
711fcf3ce44SJohn Forte 
712fcf3ce44SJohn Forte 
713*291a2b48SSukumar Swaminathan typedef struct _AUTH_MSG_NEGOT
714*291a2b48SSukumar Swaminathan {
715*291a2b48SSukumar Swaminathan 	/* in Big Endian format */
716*291a2b48SSukumar Swaminathan 	uint8_t			auth_els_code;	/* always 0x90h */
717*291a2b48SSukumar Swaminathan 	uint8_t			auth_els_flags;
718*291a2b48SSukumar Swaminathan 	uint8_t			auth_msg_code;	/* see above */
719*291a2b48SSukumar Swaminathan 	uint8_t			proto_version;
720*291a2b48SSukumar Swaminathan 	uint32_t		msg_len;	/* size of msg payload */
721*291a2b48SSukumar Swaminathan 						/* in byte */
722*291a2b48SSukumar Swaminathan 	uint32_t		tran_id;	/* transaction identifier */
723fcf3ce44SJohn Forte 
724fcf3ce44SJohn Forte 	/* anything else is variable in size (bytes) */
725fcf3ce44SJohn Forte 	/* uint8_t	msg_payload[MAX_AUTH_MSG_SIZE]; */
726*291a2b48SSukumar Swaminathan 	AUTH_NEGOT_PARAMS	params;
727fcf3ce44SJohn Forte } AUTH_MSG_NEGOT, *PAUTH_MSG_NEGOT;
728fcf3ce44SJohn Forte 
729fcf3ce44SJohn Forte 
730fcf3ce44SJohn Forte /* AUTH_Negotiate msg for NULL DH support only */
731*291a2b48SSukumar Swaminathan typedef struct _AUTH_MSG_NEGOT_NULL
732*291a2b48SSukumar Swaminathan {
733*291a2b48SSukumar Swaminathan 	uint8_t  auth_els_code;
734*291a2b48SSukumar Swaminathan 	uint8_t  auth_els_flags;
735*291a2b48SSukumar Swaminathan 	uint8_t  auth_msg_code;
736*291a2b48SSukumar Swaminathan 	uint8_t  proto_version;
737fcf3ce44SJohn Forte 	uint32_t msg_len;
738fcf3ce44SJohn Forte 	uint32_t tran_id;
739fcf3ce44SJohn Forte } AUTH_MSG_NEGOT_NULL, *PAUTH_MSG_NEGOT_NULL;
740fcf3ce44SJohn Forte 
741*291a2b48SSukumar Swaminathan typedef struct _AUTH_MSG_NEGOT_NULL_1
742*291a2b48SSukumar Swaminathan {
743*291a2b48SSukumar Swaminathan 	uint8_t				auth_els_code;
744*291a2b48SSukumar Swaminathan 	uint8_t				auth_els_flags;
745*291a2b48SSukumar Swaminathan 	uint8_t				auth_msg_code;
746*291a2b48SSukumar Swaminathan 	uint8_t				proto_version;
747*291a2b48SSukumar Swaminathan 	uint32_t			msg_len;
748*291a2b48SSukumar Swaminathan 	uint32_t			tran_id;
749fcf3ce44SJohn Forte 
750*291a2b48SSukumar Swaminathan 	AUTH_NEGOT_PARAMS_NULL_1	params;
751fcf3ce44SJohn Forte 
752fcf3ce44SJohn Forte } AUTH_MSG_NEGOT_NULL_1, *PAUTH_MSG_NEGOT_NULL_1;
753fcf3ce44SJohn Forte 
754*291a2b48SSukumar Swaminathan typedef struct _AUTH_MSG_NEGOT_NULL_2
755*291a2b48SSukumar Swaminathan {
756*291a2b48SSukumar Swaminathan 	uint8_t				auth_els_code;
757*291a2b48SSukumar Swaminathan 	uint8_t				auth_els_flags;
758*291a2b48SSukumar Swaminathan 	uint8_t				auth_msg_code;
759*291a2b48SSukumar Swaminathan 	uint8_t				proto_version;
760*291a2b48SSukumar Swaminathan 	uint32_t			msg_len;
761*291a2b48SSukumar Swaminathan 	uint32_t			tran_id;
762fcf3ce44SJohn Forte 
763*291a2b48SSukumar Swaminathan 	AUTH_NEGOT_PARAMS_NULL_2	params;
764fcf3ce44SJohn Forte 
765fcf3ce44SJohn Forte } AUTH_MSG_NEGOT_NULL_2, *PAUTH_MSG_NEGOT_NULL_2;
766fcf3ce44SJohn Forte 
767fcf3ce44SJohn Forte 
768fcf3ce44SJohn Forte /* auth_els_flags */
769fcf3ce44SJohn Forte #define	AUTH_ELS_FLAGS_MASK	0x0f;
770fcf3ce44SJohn Forte 
771fcf3ce44SJohn Forte 
772*291a2b48SSukumar Swaminathan typedef struct _AUTH_RJT
773*291a2b48SSukumar Swaminathan {
774*291a2b48SSukumar Swaminathan 	uint8_t  auth_els_code;	/* always 0x90h */
775*291a2b48SSukumar Swaminathan 	uint8_t  auth_els_flags;
776*291a2b48SSukumar Swaminathan 	uint8_t  auth_msg_code;	/* see above */
777*291a2b48SSukumar Swaminathan 	uint8_t  proto_version;
778fcf3ce44SJohn Forte 	uint32_t msg_len;	/* size of msg payload in byte */
779fcf3ce44SJohn Forte 	uint32_t tran_id;	/* transaction identifier */
780fcf3ce44SJohn Forte 
781*291a2b48SSukumar Swaminathan 	uint8_t  ReasonCode;
782*291a2b48SSukumar Swaminathan 	uint8_t  ReasonCodeExplanation;
783fcf3ce44SJohn Forte 	uint16_t Reserved;
784fcf3ce44SJohn Forte } AUTH_RJT, *PAUTH_RJT;
785fcf3ce44SJohn Forte 
786*291a2b48SSukumar Swaminathan typedef struct _DHCHAP_SUCCESS_HDR
787*291a2b48SSukumar Swaminathan {
788*291a2b48SSukumar Swaminathan 	uint8_t  auth_els_code;	/* always 0x90h */
789*291a2b48SSukumar Swaminathan 	uint8_t  auth_els_flags;
790*291a2b48SSukumar Swaminathan 	uint8_t  auth_msg_code;	/* see above */
791*291a2b48SSukumar Swaminathan 	uint8_t  proto_version;
792fcf3ce44SJohn Forte 	uint32_t msg_len;	/* size of msg payload in byte */
793fcf3ce44SJohn Forte 	uint32_t tran_id;	/* transaction identifier */
794fcf3ce44SJohn Forte 
795fcf3ce44SJohn Forte 	uint32_t RspVal_len;
796fcf3ce44SJohn Forte } DHCHAP_SUCCESS_HDR, *PDHCHAP_SUCCESS_HDR;
797fcf3ce44SJohn Forte 
798fcf3ce44SJohn Forte 
799*291a2b48SSukumar Swaminathan typedef struct dh_group_st
800*291a2b48SSukumar Swaminathan {
801*291a2b48SSukumar Swaminathan 	unsigned long   groupid;
802*291a2b48SSukumar Swaminathan 	unsigned long   length;
803*291a2b48SSukumar Swaminathan 	unsigned char   value[256];
804fcf3ce44SJohn Forte } DH_GROUP, *PDH_GROUP;
805fcf3ce44SJohn Forte 
806*291a2b48SSukumar Swaminathan static char *emlxs_local_pwd  = "11223344556677881122334455667788";
807fcf3ce44SJohn Forte static char *emlxs_remote_pwd = "aabbccddeeffgghhaabbccddeeffgghh";
808fcf3ce44SJohn Forte 
809*291a2b48SSukumar Swaminathan static uint8_t emlxs_null_wwn[8] =
810*291a2b48SSukumar Swaminathan 	{0, 0, 0, 0, 0, 0, 0, 0};
811*291a2b48SSukumar Swaminathan static uint8_t emlxs_fabric_wwn[8] =
812*291a2b48SSukumar Swaminathan 	{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
813fcf3ce44SJohn Forte 
814fcf3ce44SJohn Forte #pragma weak random_get_pseudo_bytes
815fcf3ce44SJohn Forte 
816fcf3ce44SJohn Forte 
817fcf3ce44SJohn Forte #endif	/* DHCHAP_SUPPORT */
818fcf3ce44SJohn Forte 
819fcf3ce44SJohn Forte #ifdef	__cplusplus
820fcf3ce44SJohn Forte }
821fcf3ce44SJohn Forte #endif
822fcf3ce44SJohn Forte 
823fcf3ce44SJohn Forte #endif	/* _EMLXS_DHCHAP_H */
824