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