2 The header files of miscellaneous routines specific to Https for HttpDxe driver.
4 Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15 #ifndef __EFI_HTTPS_SUPPORT_H__
16 #define __EFI_HTTPS_SUPPORT_H__
18 #define HTTPS_DEFAULT_PORT 443
20 #define HTTPS_FLAG "https://"
23 Check whether the Url is from Https.
25 @param[in] Url The pointer to a HTTP or HTTPS URL string.
27 @retval TRUE The Url is from HTTPS.
28 @retval FALSE The Url is from HTTP.
37 Creates a Tls child handle, open EFI_TLS_PROTOCOL and EFI_TLS_CONFIGURATION_PROTOCOL.
39 @param[in] ImageHandle The firmware allocated handle for the UEFI image.
40 @param[out] TlsProto Pointer to the EFI_TLS_PROTOCOL instance.
41 @param[out] TlsConfiguration Pointer to the EFI_TLS_CONFIGURATION_PROTOCOL instance.
43 @return The child handle with opened EFI_TLS_PROTOCOL and EFI_TLS_CONFIGURATION_PROTOCOL.
49 IN EFI_HANDLE ImageHandle
,
50 OUT EFI_TLS_PROTOCOL
**TlsProto
,
51 OUT EFI_TLS_CONFIGURATION_PROTOCOL
**TlsConfiguration
55 Create event for the TLS receive and transmit tokens which are used to receive and
56 transmit TLS related messages.
58 @param[in, out] HttpInstance Pointer to HTTP_PROTOCOL structure.
60 @retval EFI_SUCCESS The events are created successfully.
61 @retval others Other error as indicated.
67 IN OUT HTTP_PROTOCOL
*HttpInstance
71 Close events in the TlsTxToken and TlsRxToken.
73 @param[in] HttpInstance Pointer to HTTP_PROTOCOL structure.
79 IN HTTP_PROTOCOL
*HttpInstance
83 Read the TlsCaCertificate variable and configure it.
85 @param[in, out] HttpInstance The HTTP instance private data.
87 @retval EFI_SUCCESS TlsCaCertificate is configured.
88 @retval EFI_OUT_OF_RESOURCES Can't allocate memory resources.
89 @retval EFI_NOT_FOUND Fail to get "TlsCaCertificate" variable.
90 @retval Others Other error as indicated.
94 TlsConfigCertificate (
95 IN OUT HTTP_PROTOCOL
*HttpInstance
99 Configure TLS session data.
101 @param[in, out] HttpInstance The HTTP instance private data.
103 @retval EFI_SUCCESS TLS session data is configured.
104 @retval Others Other error as indicated.
109 TlsConfigureSession (
110 IN OUT HTTP_PROTOCOL
*HttpInstance
114 Transmit the Packet by processing the associated HTTPS token.
116 @param[in, out] HttpInstance Pointer to HTTP_PROTOCOL structure.
117 @param[in] Packet The packet to transmit.
119 @retval EFI_SUCCESS The packet is transmitted.
120 @retval EFI_INVALID_PARAMETER HttpInstance is NULL or Packet is NULL.
121 @retval EFI_OUT_OF_RESOURCES Can't allocate memory resources.
122 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
123 @retval Others Other errors as indicated.
129 IN OUT HTTP_PROTOCOL
*HttpInstance
,
134 Receive the Packet by processing the associated HTTPS token.
136 @param[in, out] HttpInstance Pointer to HTTP_PROTOCOL structure.
137 @param[in] Packet The packet to transmit.
138 @param[in] Timeout The time to wait for connection done.
140 @retval EFI_SUCCESS The Packet is received.
141 @retval EFI_INVALID_PARAMETER HttpInstance is NULL or Packet is NULL.
142 @retval EFI_OUT_OF_RESOURCES Can't allocate memory resources.
143 @retval EFI_TIMEOUT The operation is time out.
144 @retval Others Other error as indicated.
150 IN OUT HTTP_PROTOCOL
*HttpInstance
,
156 Receive one TLS PDU. An TLS PDU contains an TLS record header and it's
157 corresponding record data. These two parts will be put into two blocks of buffers in the
160 @param[in, out] HttpInstance Pointer to HTTP_PROTOCOL structure.
161 @param[out] Pdu The received TLS PDU.
162 @param[in] Timeout The time to wait for connection done.
164 @retval EFI_SUCCESS An TLS PDU is received.
165 @retval EFI_OUT_OF_RESOURCES Can't allocate memory resources.
166 @retval EFI_PROTOCOL_ERROR An unexpected TLS packet was received.
167 @retval Others Other errors as indicated.
173 IN OUT HTTP_PROTOCOL
*HttpInstance
,
179 Connect one TLS session by finishing the TLS handshake process.
181 @param[in] HttpInstance The HTTP instance private data.
182 @param[in] Timeout The time to wait for connection done.
184 @retval EFI_SUCCESS The TLS session is established.
185 @retval EFI_OUT_OF_RESOURCES Can't allocate memory resources.
186 @retval EFI_ABORTED TLS session state is incorrect.
187 @retval Others Other error as indicated.
193 IN HTTP_PROTOCOL
*HttpInstance
,
198 Close the TLS session and send out the close notification message.
200 @param[in] HttpInstance The HTTP instance private data.
202 @retval EFI_SUCCESS The TLS session is closed.
203 @retval EFI_INVALID_PARAMETER HttpInstance is NULL or Packet is NULL.
204 @retval EFI_OUT_OF_RESOURCES Can't allocate memory resources.
205 @retval Others Other error as indicated.
211 IN HTTP_PROTOCOL
*HttpInstance
215 Process one message according to the CryptMode.
217 @param[in] HttpInstance Pointer to HTTP_PROTOCOL structure.
218 @param[in] Message Pointer to the message buffer needed to processed.
219 @param[in] MessageSize Pointer to the message buffer size.
220 @param[in] ProcessMode Process mode.
221 @param[in, out] Fragment Only one Fragment returned after the Message is
222 processed successfully.
224 @retval EFI_SUCCESS Message is processed successfully.
225 @retval EFI_OUT_OF_RESOURCES Can't allocate memory resources.
226 @retval Others Other errors as indicated.
232 IN HTTP_PROTOCOL
*HttpInstance
,
234 IN UINTN MessageSize
,
235 IN EFI_TLS_CRYPT_MODE ProcessMode
,
236 IN OUT NET_FRAGMENT
*Fragment
240 Receive one fragment decrypted from one TLS record.
242 @param[in] HttpInstance Pointer to HTTP_PROTOCOL structure.
243 @param[in, out] Fragment The received Fragment.
244 @param[in] Timeout The time to wait for connection done.
246 @retval EFI_SUCCESS One fragment is received.
247 @retval EFI_OUT_OF_RESOURCES Can't allocate memory resources.
248 @retval EFI_ABORTED Something wrong decryption the message.
249 @retval Others Other errors as indicated.
255 IN HTTP_PROTOCOL
*HttpInstance
,
256 IN OUT NET_FRAGMENT
*Fragment
,