]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Universal/Network/IScsiDxe/IScsiCHAP.h
sync comments, fix function header, rename variable name to follow coding style.
[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
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 Module Name:
14
15 IScsiCHAP.h
16
17 Abstract:
18 the header file for CHAP
19 **/
20
21 #ifndef _ISCSI_CHAP_H_
22 #define _ISCSI_CHAP_H_
23
24 #define ISCSI_CHAP_AUTH_INFO_GUID \
25 { \
26 0x786ec0ac, 0x65ae, 0x4d1b, {0xb1, 0x37, 0xd, 0x11, 0xa, 0x48, 0x37, 0x97} \
27 }
28
29 extern EFI_GUID mIScsiCHAPAuthInfoGuid;
30
31 #define ISCSI_AUTH_METHOD_CHAP "CHAP"
32
33 #define ISCSI_KEY_CHAP_ALGORITHM "CHAP_A"
34 #define ISCSI_KEY_CHAP_IDENTIFIER "CHAP_I"
35 #define ISCSI_KEY_CHAP_CHALLENGE "CHAP_C"
36 #define ISCSI_KEY_CHAP_NAME "CHAP_N"
37 #define ISCSI_KEY_CHAP_RESPONSE "CHAP_R"
38
39 #define ISCSI_CHAP_ALGORITHM_MD5 5
40
41 #define ISCSI_CHAP_AUTH_MAX_LEN 1024
42 #define ISCSI_CHAP_RSP_LEN 16 // == MD5_HASHSIZE
43 typedef enum {
44 ISCSI_CHAP_INITIAL,
45 ISCSI_CHAP_STEP_ONE,
46 ISCSI_CHAP_STEP_TWO,
47 ISCSI_CHAP_STEP_THREE,
48 ISCSI_CHAP_STEP_FOUR
49 } ISCSI_CHAP_STEP;
50
51 #pragma pack(1)
52
53 typedef struct _ISCSI_CHAP_AUTH_CONFIG_NVDATA {
54 UINT8 CHAPType;
55 CHAR8 CHAPName[ISCSI_CHAP_NAME_MAX_LEN];
56 CHAR8 CHAPSecret[ISCSI_CHAP_SECRET_MAX_LEN];
57 CHAR8 ReverseCHAPName[ISCSI_CHAP_NAME_MAX_LEN];
58 CHAR8 ReverseCHAPSecret[ISCSI_CHAP_SECRET_MAX_LEN];
59 } ISCSI_CHAP_AUTH_CONFIG_NVDATA;
60
61 #pragma pack()
62
63 //
64 // ISCSI CHAP Authentication Data
65 //
66 typedef struct _ISCSI_CHAP_AUTH_DATA {
67 ISCSI_CHAP_AUTH_CONFIG_NVDATA AuthConfig;
68 UINT32 InIdentifier;
69 UINT8 InChallenge[ISCSI_CHAP_AUTH_MAX_LEN];
70 UINT32 InChallengeLength;
71 //
72 // Calculated CHAP Response (CHAP_R) value
73 //
74 UINT8 CHAPResponse[ISCSI_CHAP_RSP_LEN];
75
76 //
77 // Auth-data to be sent out for mutual authentication
78 //
79 UINT32 OutIdentifier;
80 UINT8 OutChallenge[ISCSI_CHAP_AUTH_MAX_LEN];
81 UINT32 OutChallengeLength;
82 } ISCSI_CHAP_AUTH_DATA;
83
84 /**
85 This function checks the received iSCSI Login Response during the security
86 negotiation stage.
87
88 @param Conn[in] The iSCSI connection.
89
90 @param Transit[in] The transit flag of the latest iSCSI Login Response.
91
92 @retval EFI_SUCCESS The Login Response passed the CHAP validation.
93
94 @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.
95
96 @retval EFI_PROTOCOL_ERROR Some kind of protocol error happend.
97
98 **/
99 EFI_STATUS
100 IScsiCHAPOnRspReceived (
101 IN ISCSI_CONNECTION *Conn,
102 IN BOOLEAN Transit
103 );
104
105 /**
106 This function fills the CHAP authentication information into the login PDU
107 during the security negotiation stage in the iSCSI connection login.
108
109 @param Conn[in] The iSCSI connection.
110
111 @param Pdu[in] The PDU to send out.
112
113 @retval EFI_SUCCESS All check passed and the phase-related CHAP
114 authentication info is filled into the iSCSI PDU.
115
116 @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.
117
118 @retval EFI_PROTOCOL_ERROR Some kind of protocol error happend.
119
120 **/
121 EFI_STATUS
122 IScsiCHAPToSendReq (
123 IN ISCSI_CONNECTION *Conn,
124 IN NET_BUF *Pdu
125 );
126
127 #endif