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