]> git.proxmox.com Git - mirror_edk2.git/blame - NetworkPkg/HttpDxe/HttpsSupport.h
BaseTools/Capsule: Do not support -o with --dump-info
[mirror_edk2.git] / NetworkPkg / HttpDxe / HttpsSupport.h
CommitLineData
7618784b
HW
1/** @file\r
2 The header files of miscellaneous routines specific to Https for HttpDxe driver.\r
3\r
07bd82d4 4Copyright (c) 2016 - 2018, Intel Corporation. All rights reserved.<BR>\r
7618784b
HW
5This program and the accompanying materials\r
6are licensed and made available under the terms and conditions of the BSD License\r
7which accompanies this distribution. The full text of the license may be found at\r
8http://opensource.org/licenses/bsd-license.php\r
9\r
10THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12\r
13**/\r
14\r
15#ifndef __EFI_HTTPS_SUPPORT_H__\r
16#define __EFI_HTTPS_SUPPORT_H__\r
17\r
18#define HTTPS_DEFAULT_PORT 443\r
19\r
20#define HTTPS_FLAG "https://"\r
21\r
22/**\r
23 Check whether the Url is from Https.\r
24\r
25 @param[in] Url The pointer to a HTTP or HTTPS URL string.\r
26\r
27 @retval TRUE The Url is from HTTPS.\r
28 @retval FALSE The Url is from HTTP.\r
29\r
30**/\r
31BOOLEAN\r
32IsHttpsUrl (\r
33 IN CHAR8 *Url\r
34 );\r
35\r
36/**\r
37 Creates a Tls child handle, open EFI_TLS_PROTOCOL and EFI_TLS_CONFIGURATION_PROTOCOL.\r
38\r
39 @param[in] ImageHandle The firmware allocated handle for the UEFI image.\r
45ea8a0c 40 @param[out] TlsSb Pointer to the TLS SERVICE_BINDING_PROTOCOL.\r
7618784b
HW
41 @param[out] TlsProto Pointer to the EFI_TLS_PROTOCOL instance.\r
42 @param[out] TlsConfiguration Pointer to the EFI_TLS_CONFIGURATION_PROTOCOL instance.\r
43\r
44 @return The child handle with opened EFI_TLS_PROTOCOL and EFI_TLS_CONFIGURATION_PROTOCOL.\r
45\r
46**/\r
47EFI_HANDLE\r
48EFIAPI\r
49TlsCreateChild (\r
50 IN EFI_HANDLE ImageHandle,\r
45ea8a0c 51 OUT EFI_SERVICE_BINDING_PROTOCOL **TlsSb,\r
7618784b
HW
52 OUT EFI_TLS_PROTOCOL **TlsProto,\r
53 OUT EFI_TLS_CONFIGURATION_PROTOCOL **TlsConfiguration\r
54 );\r
55\r
56/**\r
57 Create event for the TLS receive and transmit tokens which are used to receive and\r
58 transmit TLS related messages.\r
59\r
60 @param[in, out] HttpInstance Pointer to HTTP_PROTOCOL structure.\r
61\r
62 @retval EFI_SUCCESS The events are created successfully.\r
63 @retval others Other error as indicated.\r
64\r
65**/\r
66EFI_STATUS\r
67EFIAPI\r
68TlsCreateTxRxEvent (\r
69 IN OUT HTTP_PROTOCOL *HttpInstance\r
70 );\r
71\r
72/**\r
73 Close events in the TlsTxToken and TlsRxToken.\r
74\r
75 @param[in] HttpInstance Pointer to HTTP_PROTOCOL structure.\r
76\r
77**/\r
78VOID\r
79EFIAPI\r
80TlsCloseTxRxEvent (\r
81 IN HTTP_PROTOCOL *HttpInstance\r
82 );\r
83\r
84/**\r
85 Read the TlsCaCertificate variable and configure it.\r
86\r
87 @param[in, out] HttpInstance The HTTP instance private data.\r
88\r
89 @retval EFI_SUCCESS TlsCaCertificate is configured.\r
90 @retval EFI_OUT_OF_RESOURCES Can't allocate memory resources.\r
91 @retval EFI_NOT_FOUND Fail to get "TlsCaCertificate" variable.\r
92 @retval Others Other error as indicated.\r
93\r
94**/\r
95EFI_STATUS\r
96TlsConfigCertificate (\r
97 IN OUT HTTP_PROTOCOL *HttpInstance\r
98 );\r
99\r
100/**\r
101 Configure TLS session data.\r
102\r
103 @param[in, out] HttpInstance The HTTP instance private data.\r
104\r
105 @retval EFI_SUCCESS TLS session data is configured.\r
106 @retval Others Other error as indicated.\r
107\r
108**/\r
109EFI_STATUS\r
110EFIAPI\r
111TlsConfigureSession (\r
112 IN OUT HTTP_PROTOCOL *HttpInstance\r
113 );\r
114\r
115/**\r
116 Transmit the Packet by processing the associated HTTPS token.\r
117\r
118 @param[in, out] HttpInstance Pointer to HTTP_PROTOCOL structure.\r
119 @param[in] Packet The packet to transmit.\r
120\r
121 @retval EFI_SUCCESS The packet is transmitted.\r
122 @retval EFI_INVALID_PARAMETER HttpInstance is NULL or Packet is NULL.\r
123 @retval EFI_OUT_OF_RESOURCES Can't allocate memory resources.\r
124 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.\r
125 @retval Others Other errors as indicated.\r
126\r
127**/\r
128EFI_STATUS\r
129EFIAPI\r
130TlsCommonTransmit (\r
131 IN OUT HTTP_PROTOCOL *HttpInstance,\r
132 IN NET_BUF *Packet\r
133 );\r
134\r
135/**\r
136 Receive the Packet by processing the associated HTTPS token.\r
137\r
138 @param[in, out] HttpInstance Pointer to HTTP_PROTOCOL structure.\r
139 @param[in] Packet The packet to transmit.\r
140 @param[in] Timeout The time to wait for connection done.\r
141\r
142 @retval EFI_SUCCESS The Packet is received.\r
143 @retval EFI_INVALID_PARAMETER HttpInstance is NULL or Packet is NULL.\r
144 @retval EFI_OUT_OF_RESOURCES Can't allocate memory resources.\r
145 @retval EFI_TIMEOUT The operation is time out.\r
146 @retval Others Other error as indicated.\r
147\r
148**/\r
149EFI_STATUS\r
150EFIAPI\r
151TlsCommonReceive (\r
152 IN OUT HTTP_PROTOCOL *HttpInstance,\r
153 IN NET_BUF *Packet,\r
154 IN EFI_EVENT Timeout\r
155 );\r
156\r
157/**\r
158 Receive one TLS PDU. An TLS PDU contains an TLS record header and it's\r
159 corresponding record data. These two parts will be put into two blocks of buffers in the\r
160 net buffer.\r
161\r
162 @param[in, out] HttpInstance Pointer to HTTP_PROTOCOL structure.\r
163 @param[out] Pdu The received TLS PDU.\r
164 @param[in] Timeout The time to wait for connection done.\r
165\r
166 @retval EFI_SUCCESS An TLS PDU is received.\r
167 @retval EFI_OUT_OF_RESOURCES Can't allocate memory resources.\r
168 @retval EFI_PROTOCOL_ERROR An unexpected TLS packet was received.\r
169 @retval Others Other errors as indicated.\r
170\r
171**/\r
172EFI_STATUS\r
173EFIAPI\r
174TlsReceiveOnePdu (\r
175 IN OUT HTTP_PROTOCOL *HttpInstance,\r
176 OUT NET_BUF **Pdu,\r
177 IN EFI_EVENT Timeout\r
178 );\r
179\r
180/**\r
181 Connect one TLS session by finishing the TLS handshake process.\r
182\r
183 @param[in] HttpInstance The HTTP instance private data.\r
184 @param[in] Timeout The time to wait for connection done.\r
185\r
186 @retval EFI_SUCCESS The TLS session is established.\r
187 @retval EFI_OUT_OF_RESOURCES Can't allocate memory resources.\r
188 @retval EFI_ABORTED TLS session state is incorrect.\r
189 @retval Others Other error as indicated.\r
190\r
191**/\r
192EFI_STATUS\r
193EFIAPI\r
194TlsConnectSession (\r
195 IN HTTP_PROTOCOL *HttpInstance,\r
196 IN EFI_EVENT Timeout\r
197 );\r
198\r
199/**\r
200 Close the TLS session and send out the close notification message.\r
201\r
202 @param[in] HttpInstance The HTTP instance private data.\r
203\r
204 @retval EFI_SUCCESS The TLS session is closed.\r
205 @retval EFI_INVALID_PARAMETER HttpInstance is NULL or Packet is NULL.\r
206 @retval EFI_OUT_OF_RESOURCES Can't allocate memory resources.\r
207 @retval Others Other error as indicated.\r
208\r
209**/\r
210EFI_STATUS\r
211EFIAPI\r
212TlsCloseSession (\r
213 IN HTTP_PROTOCOL *HttpInstance\r
214 );\r
215\r
216/**\r
217 Process one message according to the CryptMode.\r
218\r
219 @param[in] HttpInstance Pointer to HTTP_PROTOCOL structure.\r
f75a7f56 220 @param[in] Message Pointer to the message buffer needed to processed.\r
07bd82d4
JW
221 If ProcessMode is EfiTlsEncrypt, the message contain the TLS\r
222 header and plain text TLS APP payload.\r
f75a7f56 223 If ProcessMode is EfiTlsDecrypt, the message contain the TLS\r
07bd82d4 224 header and cipher text TLS APP payload.\r
7618784b
HW
225 @param[in] MessageSize Pointer to the message buffer size.\r
226 @param[in] ProcessMode Process mode.\r
227 @param[in, out] Fragment Only one Fragment returned after the Message is\r
228 processed successfully.\r
f75a7f56 229 If ProcessMode is EfiTlsEncrypt, the fragment contain the TLS\r
07bd82d4 230 header and cipher text TLS APP payload.\r
f75a7f56 231 If ProcessMode is EfiTlsDecrypt, the fragment contain the TLS\r
07bd82d4 232 header and plain text TLS APP payload.\r
7618784b
HW
233\r
234 @retval EFI_SUCCESS Message is processed successfully.\r
235 @retval EFI_OUT_OF_RESOURCES Can't allocate memory resources.\r
236 @retval Others Other errors as indicated.\r
237\r
238**/\r
239EFI_STATUS\r
240EFIAPI\r
241TlsProcessMessage (\r
242 IN HTTP_PROTOCOL *HttpInstance,\r
243 IN UINT8 *Message,\r
244 IN UINTN MessageSize,\r
245 IN EFI_TLS_CRYPT_MODE ProcessMode,\r
246 IN OUT NET_FRAGMENT *Fragment\r
247 );\r
248\r
249/**\r
250 Receive one fragment decrypted from one TLS record.\r
251\r
252 @param[in] HttpInstance Pointer to HTTP_PROTOCOL structure.\r
253 @param[in, out] Fragment The received Fragment.\r
254 @param[in] Timeout The time to wait for connection done.\r
255\r
256 @retval EFI_SUCCESS One fragment is received.\r
257 @retval EFI_OUT_OF_RESOURCES Can't allocate memory resources.\r
258 @retval EFI_ABORTED Something wrong decryption the message.\r
259 @retval Others Other errors as indicated.\r
260\r
261**/\r
262EFI_STATUS\r
263EFIAPI\r
264HttpsReceive (\r
265 IN HTTP_PROTOCOL *HttpInstance,\r
266 IN OUT NET_FRAGMENT *Fragment,\r
267 IN EFI_EVENT Timeout\r
268 );\r
269\r
270#endif\r
271\r