]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Universal/Network/IScsiDxe/IScsiCHAP.h
cce7e5a3248a793dc42a36f887ecf2951869150d
[mirror_edk2.git] / MdeModulePkg / Universal / Network / IScsiDxe / IScsiCHAP.h
1 /** @file
2 The header file of CHAP configuration.
3
4 Copyright (c) 2004 - 2007, Intel Corporation.<BR>
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
9
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12
13 **/
14
15 #ifndef _ISCSI_CHAP_H_
16 #define _ISCSI_CHAP_H_
17
18 #define ISCSI_CHAP_AUTH_INFO_GUID \
19 { \
20 0x786ec0ac, 0x65ae, 0x4d1b, {0xb1, 0x37, 0xd, 0x11, 0xa, 0x48, 0x37, 0x97} \
21 }
22
23 extern EFI_GUID mIScsiCHAPAuthInfoGuid;
24
25 #define ISCSI_AUTH_METHOD_CHAP "CHAP"
26
27 #define ISCSI_KEY_CHAP_ALGORITHM "CHAP_A"
28 #define ISCSI_KEY_CHAP_IDENTIFIER "CHAP_I"
29 #define ISCSI_KEY_CHAP_CHALLENGE "CHAP_C"
30 #define ISCSI_KEY_CHAP_NAME "CHAP_N"
31 #define ISCSI_KEY_CHAP_RESPONSE "CHAP_R"
32
33 #define ISCSI_CHAP_ALGORITHM_MD5 5
34
35 #define ISCSI_CHAP_AUTH_MAX_LEN 1024
36 ///
37 /// MD5_HASHSIZE
38 ///
39 #define ISCSI_CHAP_RSP_LEN 16
40 typedef enum {
41 ISCSI_CHAP_INITIAL,
42 ISCSI_CHAP_STEP_ONE,
43 ISCSI_CHAP_STEP_TWO,
44 ISCSI_CHAP_STEP_THREE,
45 ISCSI_CHAP_STEP_FOUR
46 } ISCSI_CHAP_STEP;
47
48 #pragma pack(1)
49
50 typedef struct _ISCSI_CHAP_AUTH_CONFIG_NVDATA {
51 UINT8 CHAPType;
52 CHAR8 CHAPName[ISCSI_CHAP_NAME_MAX_LEN];
53 CHAR8 CHAPSecret[ISCSI_CHAP_SECRET_STORAGE];
54 CHAR8 ReverseCHAPName[ISCSI_CHAP_NAME_MAX_LEN];
55 CHAR8 ReverseCHAPSecret[ISCSI_CHAP_SECRET_STORAGE];
56 } ISCSI_CHAP_AUTH_CONFIG_NVDATA;
57
58 #pragma pack()
59
60 ///
61 /// ISCSI CHAP Authentication Data
62 ///
63 typedef struct _ISCSI_CHAP_AUTH_DATA {
64 ISCSI_CHAP_AUTH_CONFIG_NVDATA AuthConfig;
65 UINT32 InIdentifier;
66 UINT8 InChallenge[ISCSI_CHAP_AUTH_MAX_LEN];
67 UINT32 InChallengeLength;
68 //
69 // Calculated CHAP Response (CHAP_R) value
70 //
71 UINT8 CHAPResponse[ISCSI_CHAP_RSP_LEN];
72
73 //
74 // Auth-data to be sent out for mutual authentication
75 //
76 UINT32 OutIdentifier;
77 UINT8 OutChallenge[ISCSI_CHAP_AUTH_MAX_LEN];
78 UINT32 OutChallengeLength;
79 } ISCSI_CHAP_AUTH_DATA;
80
81 /**
82 This function checks the received iSCSI Login Response during the security
83 negotiation stage.
84
85 @param[in] Conn The iSCSI connection.
86
87 @retval EFI_SUCCESS The Login Response passed the CHAP validation.
88 @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.
89 @retval EFI_PROTOCOL_ERROR Some kind of protocol error happend.
90 @retval Others Other errors as indicated.
91 **/
92 EFI_STATUS
93 IScsiCHAPOnRspReceived (
94 IN ISCSI_CONNECTION *Conn
95 );
96 /**
97 This function fills the CHAP authentication information into the login PDU
98 during the security negotiation stage in the iSCSI connection login.
99
100 @param[in] Conn The iSCSI connection.
101 @param[in, out] Pdu The PDU to send out.
102
103 @retval EFI_SUCCESS All check passed and the phase-related CHAP
104 authentication info is filled into the iSCSI PDU.
105 @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.
106 @retval EFI_PROTOCOL_ERROR Some kind of protocol error happend.
107 **/
108 EFI_STATUS
109 IScsiCHAPToSendReq (
110 IN ISCSI_CONNECTION *Conn,
111 IN OUT NET_BUF *Pdu
112 );
113
114 #endif