2 Implementation of EFI TLS Configuration Protocol Interfaces.
4 Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>
6 This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php.
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
18 EFI_TLS_CONFIGURATION_PROTOCOL mTlsConfigurationProtocol
= {
19 TlsConfigurationSetData
,
20 TlsConfigurationGetData
24 Set TLS configuration data.
26 The SetData() function sets TLS configuration to non-volatile storage or volatile
29 @param[in] This Pointer to the EFI_TLS_CONFIGURATION_PROTOCOL instance.
30 @param[in] DataType Configuration data type.
31 @param[in] Data Pointer to configuration data.
32 @param[in] DataSize Total size of configuration data.
34 @retval EFI_SUCCESS The TLS configuration data is set successfully.
35 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
39 @retval EFI_UNSUPPORTED The DataType is unsupported.
40 @retval EFI_OUT_OF_RESOURCES Required system resources could not be allocated.
45 TlsConfigurationSetData (
46 IN EFI_TLS_CONFIGURATION_PROTOCOL
*This
,
47 IN EFI_TLS_CONFIG_DATA_TYPE DataType
,
53 TLS_INSTANCE
*Instance
;
58 if (This
== NULL
|| Data
== NULL
|| DataSize
== 0) {
59 return EFI_INVALID_PARAMETER
;
62 OldTpl
= gBS
->RaiseTPL (TPL_CALLBACK
);
64 Instance
= TLS_INSTANCE_FROM_CONFIGURATION (This
);
67 case EfiTlsConfigDataTypeCACertificate
:
68 Status
= TlsSetCaCertificate (Instance
->TlsConn
, Data
, DataSize
);
70 case EfiTlsConfigDataTypeHostPublicCert
:
71 Status
= TlsSetHostPublicCert (Instance
->TlsConn
, Data
, DataSize
);
73 case EfiTlsConfigDataTypeHostPrivateKey
:
74 Status
= TlsSetHostPrivateKey (Instance
->TlsConn
, Data
, DataSize
);
76 case EfiTlsConfigDataTypeCertRevocationList
:
77 Status
= TlsSetCertRevocationList (Data
, DataSize
);
80 Status
= EFI_UNSUPPORTED
;
83 gBS
->RestoreTPL (OldTpl
);
88 Get TLS configuration data.
90 The GetData() function gets TLS configuration.
92 @param[in] This Pointer to the EFI_TLS_CONFIGURATION_PROTOCOL instance.
93 @param[in] DataType Configuration data type.
94 @param[in, out] Data Pointer to configuration data.
95 @param[in, out] DataSize Total size of configuration data. On input, it means
96 the size of Data buffer. On output, it means the size
97 of copied Data buffer if EFI_SUCCESS, and means the
98 size of desired Data buffer if EFI_BUFFER_TOO_SMALL.
100 @retval EFI_SUCCESS The TLS configuration data is got successfully.
101 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
104 Data is NULL if *DataSize is not zero.
105 @retval EFI_UNSUPPORTED The DataType is unsupported.
106 @retval EFI_NOT_FOUND The TLS configuration data is not found.
107 @retval EFI_BUFFER_TOO_SMALL The buffer is too small to hold the data.
111 TlsConfigurationGetData (
112 IN EFI_TLS_CONFIGURATION_PROTOCOL
*This
,
113 IN EFI_TLS_CONFIG_DATA_TYPE DataType
,
114 IN OUT VOID
*Data
, OPTIONAL
115 IN OUT UINTN
*DataSize
119 TLS_INSTANCE
*Instance
;
123 Status
= EFI_SUCCESS
;
125 if (This
== NULL
|| DataSize
== NULL
|| (Data
== NULL
&& *DataSize
!= 0)) {
126 return EFI_INVALID_PARAMETER
;
129 OldTpl
= gBS
->RaiseTPL (TPL_CALLBACK
);
131 Instance
= TLS_INSTANCE_FROM_CONFIGURATION (This
);
134 case EfiTlsConfigDataTypeCACertificate
:
135 Status
= TlsGetCaCertificate (Instance
->TlsConn
, Data
, DataSize
);
137 case EfiTlsConfigDataTypeHostPublicCert
:
138 Status
= TlsGetHostPublicCert (Instance
->TlsConn
, Data
, DataSize
);
140 case EfiTlsConfigDataTypeHostPrivateKey
:
141 Status
= TlsGetHostPrivateKey (Instance
->TlsConn
, Data
, DataSize
);
143 case EfiTlsConfigDataTypeCertRevocationList
:
144 Status
= TlsGetCertRevocationList (Data
, DataSize
);
147 Status
= EFI_UNSUPPORTED
;
150 gBS
->RestoreTPL (OldTpl
);