]>
Commit | Line | Data |
---|---|---|
7618784b HW |
1 | /** @file\r |
2 | The header files of miscellaneous routines specific to Https for HttpDxe driver.\r | |
3 | \r | |
45ea8a0c | 4 | Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.<BR>\r |
7618784b HW |
5 | This program and the accompanying materials\r |
6 | are licensed and made available under the terms and conditions of the BSD License\r | |
7 | which accompanies this distribution. The full text of the license may be found at\r | |
8 | http://opensource.org/licenses/bsd-license.php\r | |
9 | \r | |
10 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
11 | WITHOUT 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 | |
31 | BOOLEAN\r | |
32 | IsHttpsUrl (\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 | |
47 | EFI_HANDLE\r | |
48 | EFIAPI\r | |
49 | TlsCreateChild (\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 | |
66 | EFI_STATUS\r | |
67 | EFIAPI\r | |
68 | TlsCreateTxRxEvent (\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 | |
78 | VOID\r | |
79 | EFIAPI\r | |
80 | TlsCloseTxRxEvent (\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 | |
95 | EFI_STATUS\r | |
96 | TlsConfigCertificate (\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 | |
109 | EFI_STATUS\r | |
110 | EFIAPI\r | |
111 | TlsConfigureSession (\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 | |
128 | EFI_STATUS\r | |
129 | EFIAPI\r | |
130 | TlsCommonTransmit (\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 | |
149 | EFI_STATUS\r | |
150 | EFIAPI\r | |
151 | TlsCommonReceive (\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 | |
172 | EFI_STATUS\r | |
173 | EFIAPI\r | |
174 | TlsReceiveOnePdu (\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 | |
192 | EFI_STATUS\r | |
193 | EFIAPI\r | |
194 | TlsConnectSession (\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 | |
210 | EFI_STATUS\r | |
211 | EFIAPI\r | |
212 | TlsCloseSession (\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 | |
220 | @param[in] Message Pointer to the message buffer needed to processed.\r | |
221 | @param[in] MessageSize Pointer to the message buffer size.\r | |
222 | @param[in] ProcessMode Process mode.\r | |
223 | @param[in, out] Fragment Only one Fragment returned after the Message is\r | |
224 | processed successfully.\r | |
225 | \r | |
226 | @retval EFI_SUCCESS Message is processed successfully.\r | |
227 | @retval EFI_OUT_OF_RESOURCES Can't allocate memory resources.\r | |
228 | @retval Others Other errors as indicated.\r | |
229 | \r | |
230 | **/\r | |
231 | EFI_STATUS\r | |
232 | EFIAPI\r | |
233 | TlsProcessMessage (\r | |
234 | IN HTTP_PROTOCOL *HttpInstance,\r | |
235 | IN UINT8 *Message,\r | |
236 | IN UINTN MessageSize,\r | |
237 | IN EFI_TLS_CRYPT_MODE ProcessMode,\r | |
238 | IN OUT NET_FRAGMENT *Fragment\r | |
239 | );\r | |
240 | \r | |
241 | /**\r | |
242 | Receive one fragment decrypted from one TLS record.\r | |
243 | \r | |
244 | @param[in] HttpInstance Pointer to HTTP_PROTOCOL structure.\r | |
245 | @param[in, out] Fragment The received Fragment.\r | |
246 | @param[in] Timeout The time to wait for connection done.\r | |
247 | \r | |
248 | @retval EFI_SUCCESS One fragment is received.\r | |
249 | @retval EFI_OUT_OF_RESOURCES Can't allocate memory resources.\r | |
250 | @retval EFI_ABORTED Something wrong decryption the message.\r | |
251 | @retval Others Other errors as indicated.\r | |
252 | \r | |
253 | **/\r | |
254 | EFI_STATUS\r | |
255 | EFIAPI\r | |
256 | HttpsReceive (\r | |
257 | IN HTTP_PROTOCOL *HttpInstance,\r | |
258 | IN OUT NET_FRAGMENT *Fragment,\r | |
259 | IN EFI_EVENT Timeout\r | |
260 | );\r | |
261 | \r | |
262 | #endif\r | |
263 | \r |