VirtualBox

source: vbox/trunk/src/VBox/Devices/EFI/FirmwareNew/NetworkPkg/TlsDxe/TlsConfigProtocol.c@ 80721

Last change on this file since 80721 was 80721, checked in by vboxsync, 5 years ago

Devices/EFI/FirmwareNew: Start upgrade process to edk2-stable201908 (compiles on Windows and works to some extent), bugref:4643

  • Property svn:eol-style set to native
File size: 4.7 KB
Line 
1/** @file
2 Implementation of EFI TLS Configuration Protocol Interfaces.
3
4 Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>
5
6 SPDX-License-Identifier: BSD-2-Clause-Patent
7
8**/
9
10#include "TlsImpl.h"
11
12EFI_TLS_CONFIGURATION_PROTOCOL mTlsConfigurationProtocol = {
13 TlsConfigurationSetData,
14 TlsConfigurationGetData
15};
16
17/**
18 Set TLS configuration data.
19
20 The SetData() function sets TLS configuration to non-volatile storage or volatile
21 storage.
22
23 @param[in] This Pointer to the EFI_TLS_CONFIGURATION_PROTOCOL instance.
24 @param[in] DataType Configuration data type.
25 @param[in] Data Pointer to configuration data.
26 @param[in] DataSize Total size of configuration data.
27
28 @retval EFI_SUCCESS The TLS configuration data is set successfully.
29 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
30 This is NULL.
31 Data is NULL.
32 DataSize is 0.
33 @retval EFI_UNSUPPORTED The DataType is unsupported.
34 @retval EFI_OUT_OF_RESOURCES Required system resources could not be allocated.
35
36**/
37EFI_STATUS
38EFIAPI
39TlsConfigurationSetData (
40 IN EFI_TLS_CONFIGURATION_PROTOCOL *This,
41 IN EFI_TLS_CONFIG_DATA_TYPE DataType,
42 IN VOID *Data,
43 IN UINTN DataSize
44 )
45{
46 EFI_STATUS Status;
47 TLS_INSTANCE *Instance;
48 EFI_TPL OldTpl;
49
50 Status = EFI_SUCCESS;
51
52 if (This == NULL || Data == NULL || DataSize == 0) {
53 return EFI_INVALID_PARAMETER;
54 }
55
56 OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
57
58 Instance = TLS_INSTANCE_FROM_CONFIGURATION (This);
59
60 switch (DataType) {
61 case EfiTlsConfigDataTypeCACertificate:
62 Status = TlsSetCaCertificate (Instance->TlsConn, Data, DataSize);
63 break;
64 case EfiTlsConfigDataTypeHostPublicCert:
65 Status = TlsSetHostPublicCert (Instance->TlsConn, Data, DataSize);
66 break;
67 case EfiTlsConfigDataTypeHostPrivateKey:
68 Status = TlsSetHostPrivateKey (Instance->TlsConn, Data, DataSize);
69 break;
70 case EfiTlsConfigDataTypeCertRevocationList:
71 Status = TlsSetCertRevocationList (Data, DataSize);
72 break;
73 default:
74 Status = EFI_UNSUPPORTED;
75 }
76
77 gBS->RestoreTPL (OldTpl);
78 return Status;
79}
80
81/**
82 Get TLS configuration data.
83
84 The GetData() function gets TLS configuration.
85
86 @param[in] This Pointer to the EFI_TLS_CONFIGURATION_PROTOCOL instance.
87 @param[in] DataType Configuration data type.
88 @param[in, out] Data Pointer to configuration data.
89 @param[in, out] DataSize Total size of configuration data. On input, it means
90 the size of Data buffer. On output, it means the size
91 of copied Data buffer if EFI_SUCCESS, and means the
92 size of desired Data buffer if EFI_BUFFER_TOO_SMALL.
93
94 @retval EFI_SUCCESS The TLS configuration data is got successfully.
95 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
96 This is NULL.
97 DataSize is NULL.
98 Data is NULL if *DataSize is not zero.
99 @retval EFI_UNSUPPORTED The DataType is unsupported.
100 @retval EFI_NOT_FOUND The TLS configuration data is not found.
101 @retval EFI_BUFFER_TOO_SMALL The buffer is too small to hold the data.
102**/
103EFI_STATUS
104EFIAPI
105TlsConfigurationGetData (
106 IN EFI_TLS_CONFIGURATION_PROTOCOL *This,
107 IN EFI_TLS_CONFIG_DATA_TYPE DataType,
108 IN OUT VOID *Data, OPTIONAL
109 IN OUT UINTN *DataSize
110 )
111{
112 EFI_STATUS Status;
113 TLS_INSTANCE *Instance;
114
115 EFI_TPL OldTpl;
116
117 Status = EFI_SUCCESS;
118
119 if (This == NULL || DataSize == NULL || (Data == NULL && *DataSize != 0)) {
120 return EFI_INVALID_PARAMETER;
121 }
122
123 OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
124
125 Instance = TLS_INSTANCE_FROM_CONFIGURATION (This);
126
127 switch (DataType) {
128 case EfiTlsConfigDataTypeCACertificate:
129 Status = TlsGetCaCertificate (Instance->TlsConn, Data, DataSize);
130 break;
131 case EfiTlsConfigDataTypeHostPublicCert:
132 Status = TlsGetHostPublicCert (Instance->TlsConn, Data, DataSize);
133 break;
134 case EfiTlsConfigDataTypeHostPrivateKey:
135 Status = TlsGetHostPrivateKey (Instance->TlsConn, Data, DataSize);
136 break;
137 case EfiTlsConfigDataTypeCertRevocationList:
138 Status = TlsGetCertRevocationList (Data, DataSize);
139 break;
140 default:
141 Status = EFI_UNSUPPORTED;
142 }
143
144 gBS->RestoreTPL (OldTpl);
145 return Status;
146}
147
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette