]>
Commit | Line | Data |
---|---|---|
4c5a5e0c | 1 | /** @file\r |
2 | The header file of CHAP configuration.\r | |
3 | \r | |
f75a7f56 | 4 | Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>\r |
ecf98fbc | 5 | SPDX-License-Identifier: BSD-2-Clause-Patent\r |
4c5a5e0c | 6 | \r |
7 | **/\r | |
8 | \r | |
9 | #ifndef _ISCSI_CHAP_H_\r | |
10 | #define _ISCSI_CHAP_H_\r | |
11 | \r | |
7eba9f69 | 12 | #define ISCSI_AUTH_METHOD_CHAP "CHAP"\r |
4c5a5e0c | 13 | \r |
7eba9f69 LE |
14 | #define ISCSI_KEY_CHAP_ALGORITHM "CHAP_A"\r |
15 | #define ISCSI_KEY_CHAP_IDENTIFIER "CHAP_I"\r | |
16 | #define ISCSI_KEY_CHAP_CHALLENGE "CHAP_C"\r | |
17 | #define ISCSI_KEY_CHAP_NAME "CHAP_N"\r | |
18 | #define ISCSI_KEY_CHAP_RESPONSE "CHAP_R"\r | |
4c5a5e0c | 19 | \r |
7eba9f69 | 20 | #define ISCSI_CHAP_ALGORITHM_MD5 5\r |
4c5a5e0c | 21 | \r |
4c5a5e0c | 22 | ///\r |
23 | /// MD5_HASHSIZE\r | |
24 | ///\r | |
7eba9f69 | 25 | #define ISCSI_CHAP_RSP_LEN 16\r |
4c5a5e0c | 26 | \r |
7eba9f69 LE |
27 | #define ISCSI_CHAP_STEP_ONE 1\r |
28 | #define ISCSI_CHAP_STEP_TWO 2\r | |
29 | #define ISCSI_CHAP_STEP_THREE 3\r | |
30 | #define ISCSI_CHAP_STEP_FOUR 4\r | |
4c5a5e0c | 31 | \r |
32 | \r | |
33 | #pragma pack(1)\r | |
34 | \r | |
35 | typedef struct _ISCSI_CHAP_AUTH_CONFIG_NVDATA {\r | |
36 | UINT8 CHAPType;\r | |
37 | CHAR8 CHAPName[ISCSI_CHAP_NAME_STORAGE];\r | |
38 | CHAR8 CHAPSecret[ISCSI_CHAP_SECRET_STORAGE];\r | |
39 | CHAR8 ReverseCHAPName[ISCSI_CHAP_NAME_STORAGE];\r | |
40 | CHAR8 ReverseCHAPSecret[ISCSI_CHAP_SECRET_STORAGE];\r | |
41 | } ISCSI_CHAP_AUTH_CONFIG_NVDATA;\r | |
42 | \r | |
43 | #pragma pack()\r | |
44 | \r | |
45 | ///\r | |
46 | /// ISCSI CHAP Authentication Data\r | |
47 | ///\r | |
48 | typedef struct _ISCSI_CHAP_AUTH_DATA {\r | |
49 | ISCSI_CHAP_AUTH_CONFIG_NVDATA *AuthConfig;\r | |
50 | UINT32 InIdentifier;\r | |
29cab43b | 51 | UINT8 InChallenge[1024];\r |
4c5a5e0c | 52 | UINT32 InChallengeLength;\r |
53 | //\r | |
54 | // Calculated CHAP Response (CHAP_R) value.\r | |
55 | //\r | |
56 | UINT8 CHAPResponse[ISCSI_CHAP_RSP_LEN];\r | |
57 | \r | |
58 | //\r | |
59 | // Auth-data to be sent out for mutual authentication.\r | |
60 | //\r | |
95616b86 LE |
61 | // While the challenge size is technically independent of the hashing\r |
62 | // algorithm, it is good practice to avoid hashing *fewer bytes* than the\r | |
63 | // digest size. In other words, it's good practice to feed *at least as many\r | |
64 | // bytes* to the hashing algorithm as the hashing algorithm will output.\r | |
65 | //\r | |
4c5a5e0c | 66 | UINT32 OutIdentifier;\r |
95616b86 | 67 | UINT8 OutChallenge[ISCSI_CHAP_RSP_LEN];\r |
4c5a5e0c | 68 | } ISCSI_CHAP_AUTH_DATA;\r |
69 | \r | |
70 | /**\r | |
71 | This function checks the received iSCSI Login Response during the security\r | |
72 | negotiation stage.\r | |
73 | \r | |
74 | @param[in] Conn The iSCSI connection.\r | |
75 | \r | |
76 | @retval EFI_SUCCESS The Login Response passed the CHAP validation.\r | |
77 | @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.\r | |
78 | @retval EFI_PROTOCOL_ERROR Some kind of protocol error occurred.\r | |
79 | @retval Others Other errors as indicated.\r | |
80 | \r | |
81 | **/\r | |
82 | EFI_STATUS\r | |
83 | IScsiCHAPOnRspReceived (\r | |
84 | IN ISCSI_CONNECTION *Conn\r | |
85 | );\r | |
86 | /**\r | |
87 | This function fills the CHAP authentication information into the login PDU\r | |
88 | during the security negotiation stage in the iSCSI connection login.\r | |
89 | \r | |
90 | @param[in] Conn The iSCSI connection.\r | |
91 | @param[in, out] Pdu The PDU to send out.\r | |
92 | \r | |
93 | @retval EFI_SUCCESS All check passed and the phase-related CHAP\r | |
83761337 LE |
94 | authentication info is filled into the iSCSI\r |
95 | PDU.\r | |
4c5a5e0c | 96 | @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.\r |
97 | @retval EFI_PROTOCOL_ERROR Some kind of protocol error occurred.\r | |
98 | \r | |
99 | **/\r | |
100 | EFI_STATUS\r | |
101 | IScsiCHAPToSendReq (\r | |
102 | IN ISCSI_CONNECTION *Conn,\r | |
103 | IN OUT NET_BUF *Pdu\r | |
104 | );\r | |
105 | \r | |
106 | #endif\r |