1 | /** @file
|
---|
2 | Header file of the Driver Binding and Service Binding Protocol for TlsDxe driver.
|
---|
3 |
|
---|
4 | Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>
|
---|
5 |
|
---|
6 | SPDX-License-Identifier: BSD-2-Clause-Patent
|
---|
7 |
|
---|
8 | **/
|
---|
9 |
|
---|
10 | #ifndef __EFI_TLS_DRIVER_H__
|
---|
11 | #define __EFI_TLS_DRIVER_H__
|
---|
12 |
|
---|
13 | #include <Uefi.h>
|
---|
14 |
|
---|
15 | //
|
---|
16 | // Driver Protocols
|
---|
17 | //
|
---|
18 | #include <Protocol/ServiceBinding.h>
|
---|
19 |
|
---|
20 | //
|
---|
21 | // Driver Version
|
---|
22 | //
|
---|
23 | #define TLS_VERSION 0x00000000
|
---|
24 |
|
---|
25 | #define TLS_SERVICE_SIGNATURE SIGNATURE_32 ('T', 'L', 'S', 'S')
|
---|
26 |
|
---|
27 | #define TLS_INSTANCE_SIGNATURE SIGNATURE_32 ('T', 'L', 'S', 'I')
|
---|
28 |
|
---|
29 | ///
|
---|
30 | /// TLS Service Data
|
---|
31 | ///
|
---|
32 | typedef struct _TLS_SERVICE TLS_SERVICE;
|
---|
33 |
|
---|
34 | ///
|
---|
35 | /// TLS Instance Data
|
---|
36 | ///
|
---|
37 | typedef struct _TLS_INSTANCE TLS_INSTANCE;
|
---|
38 |
|
---|
39 |
|
---|
40 | struct _TLS_SERVICE {
|
---|
41 | UINT32 Signature;
|
---|
42 | EFI_SERVICE_BINDING_PROTOCOL ServiceBinding;
|
---|
43 |
|
---|
44 | UINT16 TlsChildrenNum;
|
---|
45 | LIST_ENTRY TlsChildrenList;
|
---|
46 |
|
---|
47 | //
|
---|
48 | // Handle to install TlsServiceBinding protocol.
|
---|
49 | //
|
---|
50 | EFI_HANDLE Handle;
|
---|
51 | EFI_HANDLE ImageHandle;
|
---|
52 |
|
---|
53 | //
|
---|
54 | // Main SSL Context object which is created by a server or client once per program
|
---|
55 | // life-time and which holds mainly default values for the SSL object which are later
|
---|
56 | // created for the connections.
|
---|
57 | //
|
---|
58 | VOID *TlsCtx;
|
---|
59 | };
|
---|
60 |
|
---|
61 | struct _TLS_INSTANCE {
|
---|
62 | UINT32 Signature;
|
---|
63 | LIST_ENTRY Link;
|
---|
64 |
|
---|
65 | BOOLEAN InDestroy;
|
---|
66 |
|
---|
67 | TLS_SERVICE *Service;
|
---|
68 | EFI_HANDLE ChildHandle;
|
---|
69 |
|
---|
70 | EFI_TLS_PROTOCOL Tls;
|
---|
71 | EFI_TLS_CONFIGURATION_PROTOCOL TlsConfig;
|
---|
72 |
|
---|
73 | EFI_TLS_SESSION_STATE TlsSessionState;
|
---|
74 |
|
---|
75 | //
|
---|
76 | // Main SSL Connection which is created by a server or a client
|
---|
77 | // per established connection.
|
---|
78 | //
|
---|
79 | VOID *TlsConn;
|
---|
80 | };
|
---|
81 |
|
---|
82 |
|
---|
83 | #define TLS_SERVICE_FROM_THIS(a) \
|
---|
84 | CR (a, TLS_SERVICE, ServiceBinding, TLS_SERVICE_SIGNATURE)
|
---|
85 |
|
---|
86 | #define TLS_INSTANCE_FROM_PROTOCOL(a) \
|
---|
87 | CR (a, TLS_INSTANCE, Tls, TLS_INSTANCE_SIGNATURE)
|
---|
88 |
|
---|
89 | #define TLS_INSTANCE_FROM_CONFIGURATION(a) \
|
---|
90 | CR (a, TLS_INSTANCE, TlsConfig, TLS_INSTANCE_SIGNATURE)
|
---|
91 |
|
---|
92 |
|
---|
93 | /**
|
---|
94 | Release all the resources used by the TLS instance.
|
---|
95 |
|
---|
96 | @param[in] Instance The TLS instance data.
|
---|
97 |
|
---|
98 | **/
|
---|
99 | VOID
|
---|
100 | TlsCleanInstance (
|
---|
101 | IN TLS_INSTANCE *Instance
|
---|
102 | );
|
---|
103 |
|
---|
104 | /**
|
---|
105 | Create the TLS instance and initialize it.
|
---|
106 |
|
---|
107 | @param[in] Service The pointer to the TLS service.
|
---|
108 | @param[out] Instance The pointer to the TLS instance.
|
---|
109 |
|
---|
110 | @retval EFI_OUT_OF_RESOURCES Failed to allocate resources.
|
---|
111 | @retval EFI_SUCCESS The TLS instance is created.
|
---|
112 |
|
---|
113 | **/
|
---|
114 | EFI_STATUS
|
---|
115 | TlsCreateInstance (
|
---|
116 | IN TLS_SERVICE *Service,
|
---|
117 | OUT TLS_INSTANCE **Instance
|
---|
118 | );
|
---|
119 |
|
---|
120 | /**
|
---|
121 | Release all the resources used by the TLS service binding instance.
|
---|
122 |
|
---|
123 | @param[in] Service The TLS service data.
|
---|
124 |
|
---|
125 | **/
|
---|
126 | VOID
|
---|
127 | TlsCleanService (
|
---|
128 | IN TLS_SERVICE *Service
|
---|
129 | );
|
---|
130 |
|
---|
131 | /**
|
---|
132 | Create then initialize a TLS service.
|
---|
133 |
|
---|
134 | @param[in] Image ImageHandle of the TLS driver
|
---|
135 | @param[out] Service The service for TLS driver
|
---|
136 |
|
---|
137 | @retval EFI_OUT_OF_RESOURCES Failed to allocate resource to create the service.
|
---|
138 | @retval EFI_SUCCESS The service is created for the driver.
|
---|
139 |
|
---|
140 | **/
|
---|
141 | EFI_STATUS
|
---|
142 | TlsCreateService (
|
---|
143 | IN EFI_HANDLE Image,
|
---|
144 | OUT TLS_SERVICE **Service
|
---|
145 | );
|
---|
146 |
|
---|
147 | /**
|
---|
148 | Unloads an image.
|
---|
149 |
|
---|
150 | @param[in] ImageHandle Handle that identifies the image to be unloaded.
|
---|
151 |
|
---|
152 | @retval EFI_SUCCESS The image has been unloaded.
|
---|
153 | @retval EFI_INVALID_PARAMETER ImageHandle is not a valid image handle.
|
---|
154 |
|
---|
155 | **/
|
---|
156 | EFI_STATUS
|
---|
157 | EFIAPI
|
---|
158 | TlsUnload (
|
---|
159 | IN EFI_HANDLE ImageHandle
|
---|
160 | );
|
---|
161 |
|
---|
162 | /**
|
---|
163 | This is the declaration of an EFI image entry point. This entry point is
|
---|
164 | the same for UEFI Applications, UEFI OS Loaders, and UEFI Drivers including
|
---|
165 | both device drivers and bus drivers.
|
---|
166 |
|
---|
167 | @param ImageHandle The firmware allocated handle for the UEFI image.
|
---|
168 | @param SystemTable A pointer to the EFI System Table.
|
---|
169 |
|
---|
170 | @retval EFI_SUCCESS The operation completed successfully.
|
---|
171 | @retval Others An unexpected error occurred.
|
---|
172 | **/
|
---|
173 | EFI_STATUS
|
---|
174 | EFIAPI
|
---|
175 | TlsDriverEntryPoint (
|
---|
176 | IN EFI_HANDLE ImageHandle,
|
---|
177 | IN EFI_SYSTEM_TABLE *SystemTable
|
---|
178 | );
|
---|
179 |
|
---|
180 | /**
|
---|
181 | Creates a child handle and installs a protocol.
|
---|
182 |
|
---|
183 | The CreateChild() function installs a protocol on ChildHandle.
|
---|
184 | If ChildHandle is a pointer to NULL, then a new handle is created and returned in ChildHandle.
|
---|
185 | If ChildHandle is not a pointer to NULL, then the protocol installs on the existing ChildHandle.
|
---|
186 |
|
---|
187 | @param[in] This Pointer to the EFI_SERVICE_BINDING_PROTOCOL instance.
|
---|
188 | @param[in] ChildHandle Pointer to the handle of the child to create. If it is NULL,
|
---|
189 | then a new handle is created. If it is a pointer to an existing UEFI handle,
|
---|
190 | then the protocol is added to the existing UEFI handle.
|
---|
191 |
|
---|
192 | @retval EFI_SUCCESS The protocol was added to ChildHandle.
|
---|
193 | @retval EFI_INVALID_PARAMETER ChildHandle is NULL.
|
---|
194 | @retval EFI_OUT_OF_RESOURCES There are not enough resources available to create
|
---|
195 | the child.
|
---|
196 | @retval other The child handle was not created.
|
---|
197 |
|
---|
198 | **/
|
---|
199 | EFI_STATUS
|
---|
200 | EFIAPI
|
---|
201 | TlsServiceBindingCreateChild (
|
---|
202 | IN EFI_SERVICE_BINDING_PROTOCOL *This,
|
---|
203 | IN EFI_HANDLE *ChildHandle
|
---|
204 | );
|
---|
205 |
|
---|
206 | /**
|
---|
207 | Destroys a child handle with a protocol installed on it.
|
---|
208 |
|
---|
209 | The DestroyChild() function does the opposite of CreateChild(). It removes a protocol
|
---|
210 | that was installed by CreateChild() from ChildHandle. If the removed protocol is the
|
---|
211 | last protocol on ChildHandle, then ChildHandle is destroyed.
|
---|
212 |
|
---|
213 | @param This Pointer to the EFI_SERVICE_BINDING_PROTOCOL instance.
|
---|
214 | @param ChildHandle Handle of the child to destroy.
|
---|
215 |
|
---|
216 | @retval EFI_SUCCESS The protocol was removed from ChildHandle.
|
---|
217 | @retval EFI_UNSUPPORTED ChildHandle does not support the protocol that is being removed.
|
---|
218 | @retval EFI_INVALID_PARAMETER Child handle is NULL.
|
---|
219 | @retval EFI_ACCESS_DENIED The protocol could not be removed from the ChildHandle
|
---|
220 | because its services are being used.
|
---|
221 | @retval other The child handle was not destroyed.
|
---|
222 |
|
---|
223 | **/
|
---|
224 | EFI_STATUS
|
---|
225 | EFIAPI
|
---|
226 | TlsServiceBindingDestroyChild (
|
---|
227 | IN EFI_SERVICE_BINDING_PROTOCOL *This,
|
---|
228 | IN EFI_HANDLE ChildHandle
|
---|
229 | );
|
---|
230 |
|
---|
231 | #endif
|
---|
232 |
|
---|