]>
Commit | Line | Data |
---|---|---|
7618784b HW |
1 | /** @file\r |
2 | The header files of miscellaneous routines specific to Https for HttpDxe driver.\r | |
3 | \r | |
4 | Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>\r | |
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 | |
40 | @param[out] TlsProto Pointer to the EFI_TLS_PROTOCOL instance.\r | |
41 | @param[out] TlsConfiguration Pointer to the EFI_TLS_CONFIGURATION_PROTOCOL instance.\r | |
42 | \r | |
43 | @return The child handle with opened EFI_TLS_PROTOCOL and EFI_TLS_CONFIGURATION_PROTOCOL.\r | |
44 | \r | |
45 | **/\r | |
46 | EFI_HANDLE\r | |
47 | EFIAPI\r | |
48 | TlsCreateChild (\r | |
49 | IN EFI_HANDLE ImageHandle,\r | |
50 | OUT EFI_TLS_PROTOCOL **TlsProto,\r | |
51 | OUT EFI_TLS_CONFIGURATION_PROTOCOL **TlsConfiguration\r | |
52 | );\r | |
53 | \r | |
54 | /**\r | |
55 | Create event for the TLS receive and transmit tokens which are used to receive and\r | |
56 | transmit TLS related messages.\r | |
57 | \r | |
58 | @param[in, out] HttpInstance Pointer to HTTP_PROTOCOL structure.\r | |
59 | \r | |
60 | @retval EFI_SUCCESS The events are created successfully.\r | |
61 | @retval others Other error as indicated.\r | |
62 | \r | |
63 | **/\r | |
64 | EFI_STATUS\r | |
65 | EFIAPI\r | |
66 | TlsCreateTxRxEvent (\r | |
67 | IN OUT HTTP_PROTOCOL *HttpInstance\r | |
68 | );\r | |
69 | \r | |
70 | /**\r | |
71 | Close events in the TlsTxToken and TlsRxToken.\r | |
72 | \r | |
73 | @param[in] HttpInstance Pointer to HTTP_PROTOCOL structure.\r | |
74 | \r | |
75 | **/\r | |
76 | VOID\r | |
77 | EFIAPI\r | |
78 | TlsCloseTxRxEvent (\r | |
79 | IN HTTP_PROTOCOL *HttpInstance\r | |
80 | );\r | |
81 | \r | |
82 | /**\r | |
83 | Read the TlsCaCertificate variable and configure it.\r | |
84 | \r | |
85 | @param[in, out] HttpInstance The HTTP instance private data.\r | |
86 | \r | |
87 | @retval EFI_SUCCESS TlsCaCertificate is configured.\r | |
88 | @retval EFI_OUT_OF_RESOURCES Can't allocate memory resources.\r | |
89 | @retval EFI_NOT_FOUND Fail to get "TlsCaCertificate" variable.\r | |
90 | @retval Others Other error as indicated.\r | |
91 | \r | |
92 | **/\r | |
93 | EFI_STATUS\r | |
94 | TlsConfigCertificate (\r | |
95 | IN OUT HTTP_PROTOCOL *HttpInstance\r | |
96 | );\r | |
97 | \r | |
98 | /**\r | |
99 | Configure TLS session data.\r | |
100 | \r | |
101 | @param[in, out] HttpInstance The HTTP instance private data.\r | |
102 | \r | |
103 | @retval EFI_SUCCESS TLS session data is configured.\r | |
104 | @retval Others Other error as indicated.\r | |
105 | \r | |
106 | **/\r | |
107 | EFI_STATUS\r | |
108 | EFIAPI\r | |
109 | TlsConfigureSession (\r | |
110 | IN OUT HTTP_PROTOCOL *HttpInstance\r | |
111 | );\r | |
112 | \r | |
113 | /**\r | |
114 | Transmit the Packet by processing the associated HTTPS token.\r | |
115 | \r | |
116 | @param[in, out] HttpInstance Pointer to HTTP_PROTOCOL structure.\r | |
117 | @param[in] Packet The packet to transmit.\r | |
118 | \r | |
119 | @retval EFI_SUCCESS The packet is transmitted.\r | |
120 | @retval EFI_INVALID_PARAMETER HttpInstance is NULL or Packet is NULL.\r | |
121 | @retval EFI_OUT_OF_RESOURCES Can't allocate memory resources.\r | |
122 | @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.\r | |
123 | @retval Others Other errors as indicated.\r | |
124 | \r | |
125 | **/\r | |
126 | EFI_STATUS\r | |
127 | EFIAPI\r | |
128 | TlsCommonTransmit (\r | |
129 | IN OUT HTTP_PROTOCOL *HttpInstance,\r | |
130 | IN NET_BUF *Packet\r | |
131 | );\r | |
132 | \r | |
133 | /**\r | |
134 | Receive the Packet by processing the associated HTTPS token.\r | |
135 | \r | |
136 | @param[in, out] HttpInstance Pointer to HTTP_PROTOCOL structure.\r | |
137 | @param[in] Packet The packet to transmit.\r | |
138 | @param[in] Timeout The time to wait for connection done.\r | |
139 | \r | |
140 | @retval EFI_SUCCESS The Packet is received.\r | |
141 | @retval EFI_INVALID_PARAMETER HttpInstance is NULL or Packet is NULL.\r | |
142 | @retval EFI_OUT_OF_RESOURCES Can't allocate memory resources.\r | |
143 | @retval EFI_TIMEOUT The operation is time out.\r | |
144 | @retval Others Other error as indicated.\r | |
145 | \r | |
146 | **/\r | |
147 | EFI_STATUS\r | |
148 | EFIAPI\r | |
149 | TlsCommonReceive (\r | |
150 | IN OUT HTTP_PROTOCOL *HttpInstance,\r | |
151 | IN NET_BUF *Packet,\r | |
152 | IN EFI_EVENT Timeout\r | |
153 | );\r | |
154 | \r | |
155 | /**\r | |
156 | Receive one TLS PDU. An TLS PDU contains an TLS record header and it's\r | |
157 | corresponding record data. These two parts will be put into two blocks of buffers in the\r | |
158 | net buffer.\r | |
159 | \r | |
160 | @param[in, out] HttpInstance Pointer to HTTP_PROTOCOL structure.\r | |
161 | @param[out] Pdu The received TLS PDU.\r | |
162 | @param[in] Timeout The time to wait for connection done.\r | |
163 | \r | |
164 | @retval EFI_SUCCESS An TLS PDU is received.\r | |
165 | @retval EFI_OUT_OF_RESOURCES Can't allocate memory resources.\r | |
166 | @retval EFI_PROTOCOL_ERROR An unexpected TLS packet was received.\r | |
167 | @retval Others Other errors as indicated.\r | |
168 | \r | |
169 | **/\r | |
170 | EFI_STATUS\r | |
171 | EFIAPI\r | |
172 | TlsReceiveOnePdu (\r | |
173 | IN OUT HTTP_PROTOCOL *HttpInstance,\r | |
174 | OUT NET_BUF **Pdu,\r | |
175 | IN EFI_EVENT Timeout\r | |
176 | );\r | |
177 | \r | |
178 | /**\r | |
179 | Connect one TLS session by finishing the TLS handshake process.\r | |
180 | \r | |
181 | @param[in] HttpInstance The HTTP instance private data.\r | |
182 | @param[in] Timeout The time to wait for connection done.\r | |
183 | \r | |
184 | @retval EFI_SUCCESS The TLS session is established.\r | |
185 | @retval EFI_OUT_OF_RESOURCES Can't allocate memory resources.\r | |
186 | @retval EFI_ABORTED TLS session state is incorrect.\r | |
187 | @retval Others Other error as indicated.\r | |
188 | \r | |
189 | **/\r | |
190 | EFI_STATUS\r | |
191 | EFIAPI\r | |
192 | TlsConnectSession (\r | |
193 | IN HTTP_PROTOCOL *HttpInstance,\r | |
194 | IN EFI_EVENT Timeout\r | |
195 | );\r | |
196 | \r | |
197 | /**\r | |
198 | Close the TLS session and send out the close notification message.\r | |
199 | \r | |
200 | @param[in] HttpInstance The HTTP instance private data.\r | |
201 | \r | |
202 | @retval EFI_SUCCESS The TLS session is closed.\r | |
203 | @retval EFI_INVALID_PARAMETER HttpInstance is NULL or Packet is NULL.\r | |
204 | @retval EFI_OUT_OF_RESOURCES Can't allocate memory resources.\r | |
205 | @retval Others Other error as indicated.\r | |
206 | \r | |
207 | **/\r | |
208 | EFI_STATUS\r | |
209 | EFIAPI\r | |
210 | TlsCloseSession (\r | |
211 | IN HTTP_PROTOCOL *HttpInstance\r | |
212 | );\r | |
213 | \r | |
214 | /**\r | |
215 | Process one message according to the CryptMode.\r | |
216 | \r | |
217 | @param[in] HttpInstance Pointer to HTTP_PROTOCOL structure.\r | |
218 | @param[in] Message Pointer to the message buffer needed to processed.\r | |
219 | @param[in] MessageSize Pointer to the message buffer size.\r | |
220 | @param[in] ProcessMode Process mode.\r | |
221 | @param[in, out] Fragment Only one Fragment returned after the Message is\r | |
222 | processed successfully.\r | |
223 | \r | |
224 | @retval EFI_SUCCESS Message is processed successfully.\r | |
225 | @retval EFI_OUT_OF_RESOURCES Can't allocate memory resources.\r | |
226 | @retval Others Other errors as indicated.\r | |
227 | \r | |
228 | **/\r | |
229 | EFI_STATUS\r | |
230 | EFIAPI\r | |
231 | TlsProcessMessage (\r | |
232 | IN HTTP_PROTOCOL *HttpInstance,\r | |
233 | IN UINT8 *Message,\r | |
234 | IN UINTN MessageSize,\r | |
235 | IN EFI_TLS_CRYPT_MODE ProcessMode,\r | |
236 | IN OUT NET_FRAGMENT *Fragment\r | |
237 | );\r | |
238 | \r | |
239 | /**\r | |
240 | Receive one fragment decrypted from one TLS record.\r | |
241 | \r | |
242 | @param[in] HttpInstance Pointer to HTTP_PROTOCOL structure.\r | |
243 | @param[in, out] Fragment The received Fragment.\r | |
244 | @param[in] Timeout The time to wait for connection done.\r | |
245 | \r | |
246 | @retval EFI_SUCCESS One fragment is received.\r | |
247 | @retval EFI_OUT_OF_RESOURCES Can't allocate memory resources.\r | |
248 | @retval EFI_ABORTED Something wrong decryption the message.\r | |
249 | @retval Others Other errors as indicated.\r | |
250 | \r | |
251 | **/\r | |
252 | EFI_STATUS\r | |
253 | EFIAPI\r | |
254 | HttpsReceive (\r | |
255 | IN HTTP_PROTOCOL *HttpInstance,\r | |
256 | IN OUT NET_FRAGMENT *Fragment,\r | |
257 | IN EFI_EVENT Timeout\r | |
258 | );\r | |
259 | \r | |
260 | #endif\r | |
261 | \r |