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