2 The Miscellaneous Routines for TlsAuthConfigDxe driver.
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.
16 #include "TlsAuthConfigImpl.h"
18 VOID
*mStartOpCodeHandle
= NULL
;
19 VOID
*mEndOpCodeHandle
= NULL
;
20 EFI_IFR_GUID_LABEL
*mStartLabel
= NULL
;
21 EFI_IFR_GUID_LABEL
*mEndLabel
= NULL
;
24 CHAR16 mTlsAuthConfigStorageName
[] = L
"TLS_AUTH_CONFIG_IFR_NVDATA";
26 TLS_AUTH_CONFIG_PRIVATE_DATA
*mTlsAuthPrivateData
= NULL
;
28 HII_VENDOR_DEVICE_PATH mTlsAuthConfigHiiVendorDevicePath
= {
34 (UINT8
) (sizeof (VENDOR_DEVICE_PATH
)),
35 (UINT8
) ((sizeof (VENDOR_DEVICE_PATH
)) >> 8)
42 END_ENTIRE_DEVICE_PATH_SUBTYPE
,
44 (UINT8
) (END_DEVICE_PATH_LENGTH
),
45 (UINT8
) ((END_DEVICE_PATH_LENGTH
) >> 8)
51 // Possible DER-encoded certificate file suffixes, end with NULL pointer.
53 CHAR16
* mDerPemEncodedSuffix
[] = {
62 This code checks if the FileSuffix is one of the possible DER/PEM-encoded certificate suffix.
64 @param[in] FileSuffix The suffix of the input certificate file
66 @retval TRUE It's a DER/PEM-encoded certificate.
67 @retval FALSE It's NOT a DER/PEM-encoded certificate.
71 IsDerPemEncodeCertificate (
72 IN CONST CHAR16
*FileSuffix
76 for (Index
= 0; mDerPemEncodedSuffix
[Index
] != NULL
; Index
++) {
77 if (StrCmp (FileSuffix
, mDerPemEncodedSuffix
[Index
]) == 0) {
85 Worker function that prints an EFI_GUID into specified Buffer.
87 @param[in] Guid Pointer to GUID to print.
88 @param[in] Buffer Buffer to print Guid into.
89 @param[in] BufferSize Size of Buffer.
91 @retval Number of characters printed.
101 return UnicodeSPrint (
110 Convert a String to Guid Value.
112 @param[in] Str Specifies the String to be converted.
113 @param[in] StrLen Number of Unicode Characters of String (exclusive \0)
114 @param[out] Guid Return the result Guid value.
116 @retval EFI_SUCCESS The operation is finished successfully.
117 @retval EFI_NOT_FOUND Invalid string.
134 Buffer
= (CHAR16
*) AllocateZeroPool (sizeof (CHAR16
) * (StrLen
+ 1));
135 if (Buffer
== NULL
) {
136 return EFI_OUT_OF_RESOURCES
;
139 StrCpyS (Buffer
, (StrLen
+ 1), Str
);
145 PtrPosition
= PtrBuffer
;
146 while (*PtrBuffer
!= L
'\0') {
147 if (*PtrBuffer
== L
'-') {
152 if (*PtrBuffer
== L
'\0') {
154 return EFI_NOT_FOUND
;
158 Data
= StrHexToUintn (PtrPosition
);
159 Guid
->Data1
= (UINT32
)Data
;
165 PtrPosition
= PtrBuffer
;
166 while (*PtrBuffer
!= L
'\0') {
167 if (*PtrBuffer
== L
'-') {
172 if (*PtrBuffer
== L
'\0') {
174 return EFI_NOT_FOUND
;
177 Data
= StrHexToUintn (PtrPosition
);
178 Guid
->Data2
= (UINT16
)Data
;
184 PtrPosition
= PtrBuffer
;
185 while (*PtrBuffer
!= L
'\0') {
186 if (*PtrBuffer
== L
'-') {
191 if (*PtrBuffer
== L
'\0') {
193 return EFI_NOT_FOUND
;
196 Data
= StrHexToUintn (PtrPosition
);
197 Guid
->Data3
= (UINT16
)Data
;
202 for ( Index
= 0 ; Index
< 2 ; Index
++) {
204 if ((*PtrBuffer
== L
'\0') || ( *(PtrBuffer
+ 1) == L
'\0')) {
206 return EFI_NOT_FOUND
;
208 Digits
[0] = *PtrBuffer
;
210 Digits
[1] = *PtrBuffer
;
212 Data
= StrHexToUintn (Digits
);
213 Guid
->Data4
[Index
] = (UINT8
)Data
;
220 if ((*PtrBuffer
!= L
'-' ) || ( *PtrBuffer
== L
'\0')) {
221 return EFI_NOT_FOUND
;
227 for ( ; Index
< 8; Index
++) {
229 if ((*PtrBuffer
== L
'\0') || ( *(PtrBuffer
+ 1) == L
'\0')) {
231 return EFI_NOT_FOUND
;
233 Digits
[0] = *PtrBuffer
;
235 Digits
[1] = *PtrBuffer
;
237 Data
= StrHexToUintn (Digits
);
238 Guid
->Data4
[Index
] = (UINT8
)Data
;
248 List all cert in specified database by GUID in the page
249 for user to select and delete as needed.
251 @param[in] PrivateData Module's private data.
252 @param[in] VariableName The variable name of the vendor's signature database.
253 @param[in] VendorGuid A unique identifier for the vendor.
254 @param[in] LabelNumber Label number to insert opcodes.
255 @param[in] FormId Form ID of current page.
256 @param[in] QuestionIdBase Base question id of the signature list.
258 @retval EFI_SUCCESS Success to update the signature list page
259 @retval EFI_OUT_OF_RESOURCES Unable to allocate required resources.
264 IN TLS_AUTH_CONFIG_PRIVATE_DATA
*Private
,
265 IN CHAR16
*VariableName
,
266 IN EFI_GUID
*VendorGuid
,
267 IN UINT16 LabelNumber
,
268 IN EFI_FORM_ID FormId
,
269 IN EFI_QUESTION_ID QuestionIdBase
276 VOID
*StartOpCodeHandle
;
277 VOID
*EndOpCodeHandle
;
278 EFI_IFR_GUID_LABEL
*StartLabel
;
279 EFI_IFR_GUID_LABEL
*EndLabel
;
282 EFI_SIGNATURE_LIST
*CertList
;
283 EFI_SIGNATURE_DATA
*Cert
;
286 EFI_STRING_ID GuidID
;
293 StartOpCodeHandle
= NULL
;
294 EndOpCodeHandle
= NULL
;
297 // Initialize the container for dynamic opcodes.
299 StartOpCodeHandle
= HiiAllocateOpCodeHandle ();
300 if (StartOpCodeHandle
== NULL
) {
301 Status
= EFI_OUT_OF_RESOURCES
;
305 EndOpCodeHandle
= HiiAllocateOpCodeHandle ();
306 if (EndOpCodeHandle
== NULL
) {
307 Status
= EFI_OUT_OF_RESOURCES
;
312 // Create Hii Extend Label OpCode.
314 StartLabel
= (EFI_IFR_GUID_LABEL
*) HiiCreateGuidOpCode (
318 sizeof (EFI_IFR_GUID_LABEL
)
320 StartLabel
->ExtendOpCode
= EFI_IFR_EXTEND_OP_LABEL
;
321 StartLabel
->Number
= LabelNumber
;
323 EndLabel
= (EFI_IFR_GUID_LABEL
*) HiiCreateGuidOpCode (
327 sizeof (EFI_IFR_GUID_LABEL
)
329 EndLabel
->ExtendOpCode
= EFI_IFR_EXTEND_OP_LABEL
;
330 EndLabel
->Number
= LABEL_END
;
336 Status
= gRT
->GetVariable (VariableName
, VendorGuid
, NULL
, &DataSize
, Data
);
337 if (EFI_ERROR (Status
) && Status
!= EFI_BUFFER_TOO_SMALL
) {
341 Data
= (UINT8
*) AllocateZeroPool (DataSize
);
343 Status
= EFI_OUT_OF_RESOURCES
;
347 Status
= gRT
->GetVariable (VariableName
, VendorGuid
, NULL
, &DataSize
, Data
);
348 if (EFI_ERROR (Status
)) {
352 GuidStr
= AllocateZeroPool (100);
353 if (GuidStr
== NULL
) {
354 Status
= EFI_OUT_OF_RESOURCES
;
359 // Enumerate all data.
361 ItemDataSize
= (UINT32
) DataSize
;
362 CertList
= (EFI_SIGNATURE_LIST
*) Data
;
365 while ((ItemDataSize
> 0) && (ItemDataSize
>= CertList
->SignatureListSize
)) {
367 if (CompareGuid (&CertList
->SignatureType
, &gEfiCertX509Guid
)) {
368 Help
= STRING_TOKEN (STR_CERT_TYPE_PCKS_GUID
);
371 // The signature type is not supported in current implementation.
373 ItemDataSize
-= CertList
->SignatureListSize
;
374 CertList
= (EFI_SIGNATURE_LIST
*) ((UINT8
*) CertList
+ CertList
->SignatureListSize
);
378 CertCount
= (CertList
->SignatureListSize
- sizeof (EFI_SIGNATURE_LIST
) - CertList
->SignatureHeaderSize
) / CertList
->SignatureSize
;
379 for (Index
= 0; Index
< CertCount
; Index
++) {
380 Cert
= (EFI_SIGNATURE_DATA
*) ((UINT8
*) CertList
381 + sizeof (EFI_SIGNATURE_LIST
)
382 + CertList
->SignatureHeaderSize
383 + Index
* CertList
->SignatureSize
);
385 // Display GUID and help
387 GuidToString (&Cert
->SignatureOwner
, GuidStr
, 100);
388 GuidID
= HiiSetString (Private
->RegisteredHandle
, 0, GuidStr
, NULL
);
389 HiiCreateCheckBoxOpCode (
391 (EFI_QUESTION_ID
) (QuestionIdBase
+ GuidIndex
++),
396 EFI_IFR_FLAG_CALLBACK
,
402 ItemDataSize
-= CertList
->SignatureListSize
;
403 CertList
= (EFI_SIGNATURE_LIST
*) ((UINT8
*) CertList
+ CertList
->SignatureListSize
);
408 Private
->RegisteredHandle
,
415 if (StartOpCodeHandle
!= NULL
) {
416 HiiFreeOpCodeHandle (StartOpCodeHandle
);
419 if (EndOpCodeHandle
!= NULL
) {
420 HiiFreeOpCodeHandle (EndOpCodeHandle
);
427 if (GuidStr
!= NULL
) {
435 Delete one entry from cert database.
437 @param[in] PrivateData Module's private data.
438 @param[in] VariableName The variable name of the database.
439 @param[in] VendorGuid A unique identifier for the vendor.
440 @param[in] LabelNumber Label number to insert opcodes.
441 @param[in] FormId Form ID of current page.
442 @param[in] QuestionIdBase Base question id of the cert list.
443 @param[in] DeleteIndex Cert index to delete.
445 @retval EFI_SUCCESS Delete siganture successfully.
446 @retval EFI_NOT_FOUND Can't find the signature item,
447 @retval EFI_OUT_OF_RESOURCES Could not allocate needed resources.
451 IN TLS_AUTH_CONFIG_PRIVATE_DATA
*Private
,
452 IN CHAR16
*VariableName
,
453 IN EFI_GUID
*VendorGuid
,
454 IN UINT16 LabelNumber
,
455 IN EFI_FORM_ID FormId
,
456 IN EFI_QUESTION_ID QuestionIdBase
,
466 EFI_SIGNATURE_LIST
*CertList
;
467 EFI_SIGNATURE_LIST
*NewCertList
;
468 EFI_SIGNATURE_DATA
*Cert
;
482 // Get original signature list data.
485 Status
= gRT
->GetVariable (VariableName
, VendorGuid
, NULL
, &DataSize
, NULL
);
486 if (EFI_ERROR (Status
) && Status
!= EFI_BUFFER_TOO_SMALL
) {
490 OldData
= (UINT8
*) AllocateZeroPool (DataSize
);
491 if (OldData
== NULL
) {
492 Status
= EFI_OUT_OF_RESOURCES
;
496 Status
= gRT
->GetVariable (VariableName
, VendorGuid
, &Attr
, &DataSize
, OldData
);
497 if (EFI_ERROR(Status
)) {
502 // Allocate space for new variable.
504 Data
= (UINT8
*) AllocateZeroPool (DataSize
);
506 Status
= EFI_OUT_OF_RESOURCES
;
511 // Enumerate all data and erasing the target item.
514 ItemDataSize
= (UINT32
) DataSize
;
515 CertList
= (EFI_SIGNATURE_LIST
*) OldData
;
518 while ((ItemDataSize
> 0) && (ItemDataSize
>= CertList
->SignatureListSize
)) {
519 if (CompareGuid (&CertList
->SignatureType
, &gEfiCertX509Guid
)) {
521 // Copy EFI_SIGNATURE_LIST header then calculate the signature count in this list.
523 CopyMem (Data
+ Offset
, CertList
, (sizeof(EFI_SIGNATURE_LIST
) + CertList
->SignatureHeaderSize
));
524 NewCertList
= (EFI_SIGNATURE_LIST
*) (Data
+ Offset
);
525 Offset
+= (sizeof(EFI_SIGNATURE_LIST
) + CertList
->SignatureHeaderSize
);
526 Cert
= (EFI_SIGNATURE_DATA
*) ((UINT8
*) CertList
+ sizeof (EFI_SIGNATURE_LIST
) + CertList
->SignatureHeaderSize
);
527 CertCount
= (CertList
->SignatureListSize
- sizeof (EFI_SIGNATURE_LIST
) - CertList
->SignatureHeaderSize
) / CertList
->SignatureSize
;
528 for (Index
= 0; Index
< CertCount
; Index
++) {
529 if (GuidIndex
== DeleteIndex
) {
533 NewCertList
->SignatureListSize
-= CertList
->SignatureSize
;
537 // This item doesn't match. Copy it to the Data buffer.
539 CopyMem (Data
+ Offset
, (UINT8
*)(Cert
), CertList
->SignatureSize
);
540 Offset
+= CertList
->SignatureSize
;
543 Cert
= (EFI_SIGNATURE_DATA
*) ((UINT8
*) Cert
+ CertList
->SignatureSize
);
547 // This List doesn't match. Just copy it to the Data buffer.
549 CopyMem (Data
+ Offset
, (UINT8
*)(CertList
), CertList
->SignatureListSize
);
550 Offset
+= CertList
->SignatureListSize
;
553 ItemDataSize
-= CertList
->SignatureListSize
;
554 CertList
= (EFI_SIGNATURE_LIST
*) ((UINT8
*) CertList
+ CertList
->SignatureListSize
);
559 // Doesn't find the signature Item!
561 Status
= EFI_NOT_FOUND
;
566 // Delete the EFI_SIGNATURE_LIST header if there is no signature in the list.
568 ItemDataSize
= Offset
;
569 CertList
= (EFI_SIGNATURE_LIST
*) Data
;
571 ZeroMem (OldData
, ItemDataSize
);
572 while ((ItemDataSize
> 0) && (ItemDataSize
>= CertList
->SignatureListSize
)) {
573 CertCount
= (CertList
->SignatureListSize
- sizeof (EFI_SIGNATURE_LIST
) - CertList
->SignatureHeaderSize
) / CertList
->SignatureSize
;
574 DEBUG ((DEBUG_INFO
, " CertCount = %x\n", CertCount
));
575 if (CertCount
!= 0) {
576 CopyMem (OldData
+ Offset
, (UINT8
*)(CertList
), CertList
->SignatureListSize
);
577 Offset
+= CertList
->SignatureListSize
;
579 ItemDataSize
-= CertList
->SignatureListSize
;
580 CertList
= (EFI_SIGNATURE_LIST
*) ((UINT8
*) CertList
+ CertList
->SignatureListSize
);
585 Status
= gRT
->SetVariable(
592 if (EFI_ERROR (Status
)) {
593 DEBUG ((DEBUG_ERROR
, "Failed to set variable, Status = %r\n", Status
));
602 if (OldData
!= NULL
) {
606 return UpdateDeletePage (
618 Close an open file handle.
620 @param[in] FileHandle The file handle to close.
625 IN EFI_FILE_HANDLE FileHandle
628 if (FileHandle
!= NULL
) {
629 FileHandle
->Close (FileHandle
);
634 Read file content into BufferPtr, the size of the allocate buffer
635 is *FileSize plus AddtionAllocateSize.
637 @param[in] FileHandle The file to be read.
638 @param[in, out] BufferPtr Pointers to the pointer of allocated buffer.
639 @param[out] FileSize Size of input file
640 @param[in] AddtionAllocateSize Addtion size the buffer need to be allocated.
641 In case the buffer need to contain others besides the file content.
643 @retval EFI_SUCCESS The file was read into the buffer.
644 @retval EFI_INVALID_PARAMETER A parameter was invalid.
645 @retval EFI_OUT_OF_RESOURCES A memory allocation failed.
646 @retval others Unexpected error.
651 IN EFI_FILE_HANDLE FileHandle
,
652 IN OUT VOID
**BufferPtr
,
654 IN UINTN AddtionAllocateSize
659 UINT64 SourceFileSize
;
663 if ((FileHandle
== NULL
) || (FileSize
== NULL
)) {
664 return EFI_INVALID_PARAMETER
;
672 Status
= FileHandle
->SetPosition (FileHandle
, (UINT64
) -1);
673 if (EFI_ERROR (Status
)) {
677 Status
= FileHandle
->GetPosition (FileHandle
, &SourceFileSize
);
678 if (EFI_ERROR (Status
)) {
682 Status
= FileHandle
->SetPosition (FileHandle
, 0);
683 if (EFI_ERROR (Status
)) {
687 BufferSize
= (UINTN
) SourceFileSize
+ AddtionAllocateSize
;
688 Buffer
= AllocateZeroPool(BufferSize
);
689 if (Buffer
== NULL
) {
690 return EFI_OUT_OF_RESOURCES
;
693 BufferSize
= (UINTN
) SourceFileSize
;
694 *FileSize
= BufferSize
;
696 Status
= FileHandle
->Read (FileHandle
, &BufferSize
, Buffer
);
697 if (EFI_ERROR (Status
) || BufferSize
!= *FileSize
) {
700 Status
= EFI_BAD_BUFFER_SIZE
;
711 This function will open a file or directory referenced by DevicePath.
713 This function opens a file with the open mode according to the file path. The
714 Attributes is valid only for EFI_FILE_MODE_CREATE.
716 @param[in, out] FilePath On input, the device path to the file.
717 On output, the remaining device path.
718 @param[out] FileHandle Pointer to the file handle.
719 @param[in] OpenMode The mode to open the file with.
720 @param[in] Attributes The file's file attributes.
722 @retval EFI_SUCCESS The information was set.
723 @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value.
724 @retval EFI_UNSUPPORTED Could not open the file path.
725 @retval EFI_NOT_FOUND The specified file could not be found on the
726 device or the file system could not be found on
728 @retval EFI_NO_MEDIA The device has no medium.
729 @retval EFI_MEDIA_CHANGED The device has a different medium in it or the
730 medium is no longer supported.
731 @retval EFI_DEVICE_ERROR The device reported an error.
732 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
733 @retval EFI_WRITE_PROTECTED The file or medium is write protected.
734 @retval EFI_ACCESS_DENIED The file was opened read only.
735 @retval EFI_OUT_OF_RESOURCES Not enough resources were available to open the
737 @retval EFI_VOLUME_FULL The volume is full.
741 OpenFileByDevicePath (
742 IN OUT EFI_DEVICE_PATH_PROTOCOL
**FilePath
,
743 OUT EFI_FILE_HANDLE
*FileHandle
,
749 EFI_SIMPLE_FILE_SYSTEM_PROTOCOL
*EfiSimpleFileSystemProtocol
;
750 EFI_FILE_PROTOCOL
*Handle1
;
751 EFI_FILE_PROTOCOL
*Handle2
;
752 EFI_HANDLE DeviceHandle
;
754 if ((FilePath
== NULL
|| FileHandle
== NULL
)) {
755 return EFI_INVALID_PARAMETER
;
758 Status
= gBS
->LocateDevicePath (
759 &gEfiSimpleFileSystemProtocolGuid
,
763 if (EFI_ERROR (Status
)) {
767 Status
= gBS
->OpenProtocol(
769 &gEfiSimpleFileSystemProtocolGuid
,
770 (VOID
**)&EfiSimpleFileSystemProtocol
,
773 EFI_OPEN_PROTOCOL_GET_PROTOCOL
775 if (EFI_ERROR (Status
)) {
779 Status
= EfiSimpleFileSystemProtocol
->OpenVolume(EfiSimpleFileSystemProtocol
, &Handle1
);
780 if (EFI_ERROR (Status
)) {
786 // go down directories one node at a time.
788 while (!IsDevicePathEnd (*FilePath
)) {
790 // For file system access each node should be a file path component
792 if (DevicePathType (*FilePath
) != MEDIA_DEVICE_PATH
||
793 DevicePathSubType (*FilePath
) != MEDIA_FILEPATH_DP
796 return (EFI_INVALID_PARAMETER
);
799 // Open this file path node
805 // Try to test opening an existing file
807 Status
= Handle2
->Open (
810 ((FILEPATH_DEVICE_PATH
*)*FilePath
)->PathName
,
811 OpenMode
&~EFI_FILE_MODE_CREATE
,
816 // see if the error was that it needs to be created
818 if ((EFI_ERROR (Status
)) && (OpenMode
!= (OpenMode
&~EFI_FILE_MODE_CREATE
))) {
819 Status
= Handle2
->Open (
822 ((FILEPATH_DEVICE_PATH
*)*FilePath
)->PathName
,
828 // Close the last node
830 Handle2
->Close (Handle2
);
832 if (EFI_ERROR(Status
)) {
839 *FilePath
= NextDevicePathNode (*FilePath
);
843 // This is a weak spot since if the undefined SHELL_FILE_HANDLE format changes this must change also!
845 *FileHandle
= (VOID
*)Handle1
;
850 This function converts an input device structure to a Unicode string.
852 @param[in] DevPath A pointer to the device path structure.
854 @return A new allocated Unicode string that represents the device path.
860 IN EFI_DEVICE_PATH_PROTOCOL
*DevPath
863 return ConvertDevicePathToText (
872 Extract filename from device path. The returned buffer is allocated using AllocateCopyPool.
873 The caller is responsible for freeing the allocated buffer using FreePool(). If return NULL
874 means not enough memory resource.
876 @param DevicePath Device path.
878 @retval NULL Not enough memory resourece for AllocateCopyPool.
879 @retval Other A new allocated string that represents the file name.
883 ExtractFileNameFromDevicePath (
884 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
893 ASSERT(DevicePath
!= NULL
);
895 String
= DevicePathToStr(DevicePath
);
896 MatchString
= String
;
900 while(MatchString
!= NULL
){
901 LastMatch
= MatchString
+ 1;
902 MatchString
= StrStr(LastMatch
,L
"\\");
905 Length
= StrLen(LastMatch
);
906 FileName
= AllocateCopyPool ((Length
+ 1) * sizeof(CHAR16
), LastMatch
);
907 if (FileName
!= NULL
) {
908 *(FileName
+ Length
) = 0;
917 Enroll a new X509 certificate into Variable.
919 @param[in] PrivateData The module's private data.
920 @param[in] VariableName Variable name of CA database.
922 @retval EFI_SUCCESS New X509 is enrolled successfully.
923 @retval EFI_OUT_OF_RESOURCES Could not allocate needed resources.
927 EnrollX509toVariable (
928 IN TLS_AUTH_CONFIG_PRIVATE_DATA
*Private
,
929 IN CHAR16
*VariableName
935 EFI_SIGNATURE_LIST
*CACert
;
936 EFI_SIGNATURE_DATA
*CACertData
;
950 Status
= ReadFileContent (
951 Private
->FileContext
->FHandle
,
956 if (EFI_ERROR (Status
)) {
959 ASSERT (X509Data
!= NULL
);
961 SigDataSize
= sizeof(EFI_SIGNATURE_LIST
) + sizeof(EFI_SIGNATURE_DATA
) - 1 + X509DataSize
;
963 Data
= AllocateZeroPool (SigDataSize
);
965 Status
= EFI_OUT_OF_RESOURCES
;
970 // Fill Certificate Database parameters.
972 CACert
= (EFI_SIGNATURE_LIST
*) Data
;
973 CACert
->SignatureListSize
= (UINT32
) SigDataSize
;
974 CACert
->SignatureHeaderSize
= 0;
975 CACert
->SignatureSize
= (UINT32
) (sizeof(EFI_SIGNATURE_DATA
) - 1 + X509DataSize
);
976 CopyGuid (&CACert
->SignatureType
, &gEfiCertX509Guid
);
978 CACertData
= (EFI_SIGNATURE_DATA
*) ((UINT8
* ) CACert
+ sizeof (EFI_SIGNATURE_LIST
));
979 CopyGuid (&CACertData
->SignatureOwner
, Private
->CertGuid
);
980 CopyMem ((UINT8
* ) (CACertData
->SignatureData
), X509Data
, X509DataSize
);
983 // Check if signature database entry has been already existed.
984 // If true, use EFI_VARIABLE_APPEND_WRITE attribute to append the
985 // new signature data to original variable
987 Attr
= TLS_AUTH_CONFIG_VAR_BASE_ATTR
;
989 Status
= gRT
->GetVariable(
991 &gEfiTlsCaCertificateGuid
,
996 if (Status
== EFI_BUFFER_TOO_SMALL
) {
997 Attr
|= EFI_VARIABLE_APPEND_WRITE
;
998 } else if (Status
!= EFI_NOT_FOUND
) {
1002 Status
= gRT
->SetVariable(
1004 &gEfiTlsCaCertificateGuid
,
1009 if (EFI_ERROR (Status
)) {
1015 CloseFile (Private
->FileContext
->FHandle
);
1016 if (Private
->FileContext
->FileName
!= NULL
) {
1017 FreePool(Private
->FileContext
->FileName
);
1018 Private
->FileContext
->FileName
= NULL
;
1021 Private
->FileContext
->FHandle
= NULL
;
1023 if (Private
->CertGuid
!= NULL
) {
1024 FreePool (Private
->CertGuid
);
1025 Private
->CertGuid
= NULL
;
1032 if (X509Data
!= NULL
) {
1033 FreePool (X509Data
);
1040 Enroll Cert into TlsCaCertificate. The GUID will be Private->CertGuid.
1042 @param[in] PrivateData The module's private data.
1043 @param[in] VariableName Variable name of signature database.
1045 @retval EFI_SUCCESS New Cert enrolled successfully.
1046 @retval EFI_INVALID_PARAMETER The parameter is invalid.
1047 @retval EFI_UNSUPPORTED The Cert file is unsupported type.
1048 @retval others Fail to enroll Cert data.
1052 EnrollCertDatabase (
1053 IN TLS_AUTH_CONFIG_PRIVATE_DATA
*Private
,
1054 IN CHAR16
*VariableName
1057 UINT16
* FilePostFix
;
1060 if ((Private
->FileContext
->FileName
== NULL
) || (Private
->FileContext
->FHandle
== NULL
) || (Private
->CertGuid
== NULL
)) {
1061 return EFI_INVALID_PARAMETER
;
1065 // Parse the file's postfix.
1067 NameLength
= StrLen (Private
->FileContext
->FileName
);
1068 if (NameLength
<= 4) {
1069 return EFI_INVALID_PARAMETER
;
1071 FilePostFix
= Private
->FileContext
->FileName
+ NameLength
- 4;
1073 if (IsDerPemEncodeCertificate (FilePostFix
)) {
1075 // Supports DER-encoded X509 certificate.
1077 return EnrollX509toVariable (Private
, VariableName
);
1080 return EFI_UNSUPPORTED
;
1084 Refresh the global UpdateData structure.
1093 // Free current updated date
1095 if (mStartOpCodeHandle
!= NULL
) {
1096 HiiFreeOpCodeHandle (mStartOpCodeHandle
);
1100 // Create new OpCode Handle
1102 mStartOpCodeHandle
= HiiAllocateOpCodeHandle ();
1105 // Create Hii Extend Label OpCode as the start opcode
1107 mStartLabel
= (EFI_IFR_GUID_LABEL
*) HiiCreateGuidOpCode (
1111 sizeof (EFI_IFR_GUID_LABEL
)
1113 mStartLabel
->ExtendOpCode
= EFI_IFR_EXTEND_OP_LABEL
;
1117 Clean up the dynamic opcode at label and form specified by both LabelId.
1119 @param[in] LabelId It is both the Form ID and Label ID for opcode deletion.
1120 @param[in] PrivateData Module private data.
1126 IN TLS_AUTH_CONFIG_PRIVATE_DATA
*PrivateData
1129 RefreshUpdateData ();
1132 // Remove all op-codes from dynamic page
1134 mStartLabel
->Number
= LabelId
;
1136 PrivateData
->RegisteredHandle
,
1137 &gTlsAuthConfigGuid
,
1139 mStartOpCodeHandle
, // Label LabelId
1140 mEndOpCodeHandle
// LABEL_END
1145 Update the form base on the selected file.
1147 @param FilePath Point to the file path.
1148 @param FormId The form need to display.
1150 @retval TRUE Exit caller function.
1151 @retval FALSE Not exit caller function.
1156 IN EFI_DEVICE_PATH_PROTOCOL
*FilePath
,
1157 IN EFI_FORM_ID FormId
1161 EFI_STRING_ID StringToken
;
1165 if (FilePath
!= NULL
) {
1166 FileName
= ExtractFileNameFromDevicePath(FilePath
);
1168 if (FileName
== NULL
) {
1170 // FileName = NULL has two case:
1171 // 1. FilePath == NULL, not select file.
1172 // 2. FilePath != NULL, but ExtractFileNameFromDevicePath return NULL not enough memory resource.
1173 // In these two case, no need to update the form, and exit the caller function.
1177 StringToken
= HiiSetString (mTlsAuthPrivateData
->RegisteredHandle
, 0, FileName
, NULL
);
1179 mTlsAuthPrivateData
->FileContext
->FileName
= FileName
;
1181 OpenFileByDevicePath (
1183 &mTlsAuthPrivateData
->FileContext
->FHandle
,
1188 // Create Subtitle op-code for the display string of the option.
1190 RefreshUpdateData ();
1191 mStartLabel
->Number
= FormId
;
1193 HiiCreateSubTitleOpCode (
1202 mTlsAuthPrivateData
->RegisteredHandle
,
1203 &gTlsAuthConfigGuid
,
1205 mStartOpCodeHandle
, /// Label FormId
1206 mEndOpCodeHandle
/// LABEL_END
1213 Update the form base on the input file path info.
1215 @param FilePath Point to the file path.
1217 @retval TRUE Exit caller function.
1218 @retval FALSE Not exit caller function.
1223 IN EFI_DEVICE_PATH_PROTOCOL
*FilePath
1226 return UpdatePage(FilePath
, TLS_AUTH_CONFIG_FORMID4_FORM
);
1230 Unload the configuration form, this includes: delete all the configuration
1231 entries, uninstall the form callback protocol, and free the resources used.
1233 @param[in] Private Pointer to the driver private data.
1235 @retval EFI_SUCCESS The configuration form is unloaded.
1236 @retval Others Failed to unload the form.
1240 TlsAuthConfigFormUnload (
1241 IN TLS_AUTH_CONFIG_PRIVATE_DATA
*Private
1244 if (Private
->DriverHandle
!= NULL
) {
1246 // Uninstall EFI_HII_CONFIG_ACCESS_PROTOCOL
1248 gBS
->UninstallMultipleProtocolInterfaces (
1249 Private
->DriverHandle
,
1250 &gEfiDevicePathProtocolGuid
,
1251 &mTlsAuthConfigHiiVendorDevicePath
,
1252 &gEfiHiiConfigAccessProtocolGuid
,
1253 &Private
->ConfigAccess
,
1256 Private
->DriverHandle
= NULL
;
1259 if (Private
->RegisteredHandle
!= NULL
) {
1261 // Remove HII package list
1263 HiiRemovePackages (Private
->RegisteredHandle
);
1264 Private
->RegisteredHandle
= NULL
;
1267 if (Private
->CertGuid
!= NULL
) {
1268 FreePool (Private
->CertGuid
);
1271 if (Private
->FileContext
!= NULL
) {
1272 FreePool (Private
->FileContext
);
1277 if (mStartOpCodeHandle
!= NULL
) {
1278 HiiFreeOpCodeHandle (mStartOpCodeHandle
);
1281 if (mEndOpCodeHandle
!= NULL
) {
1282 HiiFreeOpCodeHandle (mEndOpCodeHandle
);
1290 Initialize the configuration form.
1292 @param[in] Private Pointer to the driver private data.
1294 @retval EFI_SUCCESS The configuration form is initialized.
1295 @retval EFI_OUT_OF_RESOURCES Failed to allocate memory.
1299 TlsAuthConfigFormInit (
1300 IN TLS_AUTH_CONFIG_PRIVATE_DATA
*Private
1305 Private
->Signature
= TLS_AUTH_CONFIG_PRIVATE_DATA_SIGNATURE
;
1307 Private
->ConfigAccess
.ExtractConfig
= TlsAuthConfigAccessExtractConfig
;
1308 Private
->ConfigAccess
.RouteConfig
= TlsAuthConfigAccessRouteConfig
;
1309 Private
->ConfigAccess
.Callback
= TlsAuthConfigAccessCallback
;
1312 // Install Device Path Protocol and Config Access protocol to driver handle.
1314 Status
= gBS
->InstallMultipleProtocolInterfaces (
1315 &Private
->DriverHandle
,
1316 &gEfiDevicePathProtocolGuid
,
1317 &mTlsAuthConfigHiiVendorDevicePath
,
1318 &gEfiHiiConfigAccessProtocolGuid
,
1319 &Private
->ConfigAccess
,
1322 if (EFI_ERROR (Status
)) {
1327 // Publish our HII data.
1329 Private
->RegisteredHandle
= HiiAddPackages (
1330 &gTlsAuthConfigGuid
,
1331 Private
->DriverHandle
,
1332 TlsAuthConfigDxeStrings
,
1333 TlsAuthConfigVfrBin
,
1336 if (Private
->RegisteredHandle
== NULL
) {
1337 Status
= EFI_OUT_OF_RESOURCES
;
1341 Private
->FileContext
= AllocateZeroPool (sizeof (TLS_AUTH_CONFIG_FILE_CONTEXT
));
1342 if (Private
->FileContext
== NULL
) {
1343 Status
= EFI_OUT_OF_RESOURCES
;
1348 // Init OpCode Handle and Allocate space for creation of Buffer
1350 mStartOpCodeHandle
= HiiAllocateOpCodeHandle ();
1351 if (mStartOpCodeHandle
== NULL
) {
1352 Status
= EFI_OUT_OF_RESOURCES
;
1356 mEndOpCodeHandle
= HiiAllocateOpCodeHandle ();
1357 if (mEndOpCodeHandle
== NULL
) {
1358 Status
= EFI_OUT_OF_RESOURCES
;
1363 // Create Hii Extend Label OpCode as the start opcode
1365 mStartLabel
= (EFI_IFR_GUID_LABEL
*) HiiCreateGuidOpCode (
1369 sizeof (EFI_IFR_GUID_LABEL
)
1371 mStartLabel
->ExtendOpCode
= EFI_IFR_EXTEND_OP_LABEL
;
1374 // Create Hii Extend Label OpCode as the end opcode
1376 mEndLabel
= (EFI_IFR_GUID_LABEL
*) HiiCreateGuidOpCode (
1380 sizeof (EFI_IFR_GUID_LABEL
)
1382 mEndLabel
->ExtendOpCode
= EFI_IFR_EXTEND_OP_LABEL
;
1383 mEndLabel
->Number
= LABEL_END
;
1388 TlsAuthConfigFormUnload (Private
);
1394 This function allows the caller to request the current
1395 configuration for one or more named elements. The resulting
1396 string is in <ConfigAltResp> format. Any and all alternative
1397 configuration strings shall also be appended to the end of the
1398 current configuration string. If they are, they must appear
1399 after the current configuration. They must contain the same
1400 routing (GUID, NAME, PATH) as the current configuration string.
1401 They must have an additional description indicating the type of
1402 alternative configuration the string represents,
1403 "ALTCFG=<StringToken>". That <StringToken> (when
1404 converted from Hex UNICODE to binary) is a reference to a
1405 string in the associated string pack.
1407 @param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
1409 @param Request A null-terminated Unicode string in
1410 <ConfigRequest> format. Note that this
1411 includes the routing information as well as
1412 the configurable name / value pairs. It is
1413 invalid for this string to be in
1414 <MultiConfigRequest> format.
1415 If a NULL is passed in for the Request field,
1416 all of the settings being abstracted by this function
1417 will be returned in the Results field. In addition,
1418 if a ConfigHdr is passed in with no request elements,
1419 all of the settings being abstracted for that particular
1420 ConfigHdr reference will be returned in the Results Field.
1422 @param Progress On return, points to a character in the
1423 Request string. Points to the string's null
1424 terminator if request was successful. Points
1425 to the most recent "&" before the first
1426 failing name / value pair (or the beginning
1427 of the string if the failure is in the first
1428 name / value pair) if the request was not
1431 @param Results A null-terminated Unicode string in
1432 <MultiConfigAltResp> format which has all values
1433 filled in for the names in the Request string.
1434 String to be allocated by the called function.
1436 @retval EFI_SUCCESS The Results string is filled with the
1437 values corresponding to all requested
1440 @retval EFI_OUT_OF_RESOURCES Not enough memory to store the
1441 parts of the results that must be
1442 stored awaiting possible future
1445 @retval EFI_NOT_FOUND Routing data doesn't match any
1446 known driver. Progress set to the
1447 first character in the routing header.
1448 Note: There is no requirement that the
1449 driver validate the routing data. It
1450 must skip the <ConfigHdr> in order to
1453 @retval EFI_INVALID_PARAMETER Illegal syntax. Progress set
1454 to most recent "&" before the
1455 error or the beginning of the
1458 @retval EFI_INVALID_PARAMETER Unknown name. Progress points
1459 to the & before the name in
1465 TlsAuthConfigAccessExtractConfig (
1466 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL
*This
,
1467 IN CONST EFI_STRING Request
,
1468 OUT EFI_STRING
*Progress
,
1469 OUT EFI_STRING
*Results
1475 EFI_STRING ConfigRequest
;
1476 EFI_STRING ConfigRequestHdr
;
1477 TLS_AUTH_CONFIG_PRIVATE_DATA
*Private
;
1478 BOOLEAN AllocatedRequest
;
1480 if (Progress
== NULL
|| Results
== NULL
) {
1481 return EFI_INVALID_PARAMETER
;
1484 AllocatedRequest
= FALSE
;
1485 ConfigRequestHdr
= NULL
;
1486 ConfigRequest
= NULL
;
1489 Private
= TLS_AUTH_CONFIG_PRIVATE_FROM_THIS (This
);
1491 BufferSize
= sizeof (TLS_AUTH_CONFIG_IFR_NVDATA
);
1492 ZeroMem (&Private
->TlsAuthConfigNvData
, BufferSize
);
1494 *Progress
= Request
;
1496 if ((Request
!= NULL
) && !HiiIsConfigHdrMatch (Request
, &gTlsAuthConfigGuid
, mTlsAuthConfigStorageName
)) {
1497 return EFI_NOT_FOUND
;
1500 ConfigRequest
= Request
;
1501 if ((Request
== NULL
) || (StrStr (Request
, L
"OFFSET") == NULL
)) {
1503 // Request is set to NULL or OFFSET is NULL, construct full request string.
1505 // Allocate and fill a buffer large enough to hold the <ConfigHdr> template
1506 // followed by "&OFFSET=0&WIDTH=WWWWWWWWWWWWWWWW" followed by a Null-terminator
1508 ConfigRequestHdr
= HiiConstructConfigHdr (&gTlsAuthConfigGuid
, mTlsAuthConfigStorageName
, Private
->DriverHandle
);
1509 Size
= (StrLen (ConfigRequestHdr
) + 32 + 1) * sizeof (CHAR16
);
1510 ConfigRequest
= AllocateZeroPool (Size
);
1511 ASSERT (ConfigRequest
!= NULL
);
1512 AllocatedRequest
= TRUE
;
1513 UnicodeSPrint (ConfigRequest
, Size
, L
"%s&OFFSET=0&WIDTH=%016LX", ConfigRequestHdr
, (UINT64
)BufferSize
);
1514 FreePool (ConfigRequestHdr
);
1515 ConfigRequestHdr
= NULL
;
1518 Status
= gHiiConfigRouting
->BlockToConfig (
1521 (UINT8
*) &Private
->TlsAuthConfigNvData
,
1528 // Free the allocated config request string.
1530 if (AllocatedRequest
) {
1531 FreePool (ConfigRequest
);
1535 // Set Progress string to the original request string.
1537 if (Request
== NULL
) {
1539 } else if (StrStr (Request
, L
"OFFSET") == NULL
) {
1540 *Progress
= Request
+ StrLen (Request
);
1548 This function applies changes in a driver's configuration.
1549 Input is a Configuration, which has the routing data for this
1550 driver followed by name / value configuration pairs. The driver
1551 must apply those pairs to its configurable storage. If the
1552 driver's configuration is stored in a linear block of data
1553 and the driver's name / value pairs are in <BlockConfig>
1554 format, it may use the ConfigToBlock helper function (above) to
1557 @param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
1559 @param Configuration A null-terminated Unicode string in
1560 <ConfigString> format.
1562 @param Progress A pointer to a string filled in with the
1563 offset of the most recent '&' before the
1564 first failing name / value pair (or the
1565 beginn ing of the string if the failure
1566 is in the first name / value pair) or
1567 the terminating NULL if all was
1570 @retval EFI_SUCCESS The results have been distributed or are
1571 awaiting distribution.
1573 @retval EFI_OUT_OF_RESOURCES Not enough memory to store the
1574 parts of the results that must be
1575 stored awaiting possible future
1578 @retval EFI_INVALID_PARAMETERS Passing in a NULL for the
1579 Results parameter would result
1580 in this type of error.
1582 @retval EFI_NOT_FOUND Target for the specified routing data
1588 TlsAuthConfigAccessRouteConfig (
1589 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL
*This
,
1590 IN CONST EFI_STRING Configuration
,
1591 OUT EFI_STRING
*Progress
1596 TLS_AUTH_CONFIG_PRIVATE_DATA
*Private
;
1598 if (Progress
== NULL
) {
1599 return EFI_INVALID_PARAMETER
;
1601 *Progress
= Configuration
;
1603 if (Configuration
== NULL
) {
1604 return EFI_INVALID_PARAMETER
;
1608 // Check routing data in <ConfigHdr>.
1609 // Note: there is no name for Name/Value storage, only GUID will be checked
1611 if (!HiiIsConfigHdrMatch (Configuration
, &gTlsAuthConfigGuid
, mTlsAuthConfigStorageName
)) {
1612 return EFI_NOT_FOUND
;
1615 Private
= TLS_AUTH_CONFIG_PRIVATE_FROM_THIS (This
);
1617 BufferSize
= sizeof (TLS_AUTH_CONFIG_IFR_NVDATA
);
1618 ZeroMem (&Private
->TlsAuthConfigNvData
, BufferSize
);
1620 Status
= gHiiConfigRouting
->ConfigToBlock (
1623 (UINT8
*) &Private
->TlsAuthConfigNvData
,
1627 if (EFI_ERROR (Status
)) {
1636 This function is called to provide results data to the driver.
1637 This data consists of a unique key that is used to identify
1638 which data is either being passed back or being asked for.
1640 @param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
1641 @param Action Specifies the type of action taken by the browser.
1642 @param QuestionId A unique value which is sent to the original
1643 exporting driver so that it can identify the type
1644 of data to expect. The format of the data tends to
1645 vary based on the opcode that generated the callback.
1646 @param Type The type of value for the question.
1647 @param Value A pointer to the data being sent to the original
1649 @param ActionRequest On return, points to the action requested by the
1652 @retval EFI_SUCCESS The callback successfully handled the action.
1653 @retval EFI_OUT_OF_RESOURCES Not enough storage is available to hold the
1654 variable and its data.
1655 @retval EFI_DEVICE_ERROR The variable could not be saved.
1656 @retval EFI_UNSUPPORTED The specified Action is not supported by the
1661 TlsAuthConfigAccessCallback (
1662 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL
*This
,
1663 IN EFI_BROWSER_ACTION Action
,
1664 IN EFI_QUESTION_ID QuestionId
,
1666 IN OUT EFI_IFR_TYPE_VALUE
*Value
,
1667 OUT EFI_BROWSER_ACTION_REQUEST
*ActionRequest
1672 TLS_AUTH_CONFIG_PRIVATE_DATA
*Private
;
1674 TLS_AUTH_CONFIG_IFR_NVDATA
*IfrNvData
;
1676 EFI_DEVICE_PATH_PROTOCOL
*File
;
1678 Status
= EFI_SUCCESS
;
1681 if ((This
== NULL
) || (Value
== NULL
) || (ActionRequest
== NULL
)) {
1682 return EFI_INVALID_PARAMETER
;
1685 Private
= TLS_AUTH_CONFIG_PRIVATE_FROM_THIS (This
);
1687 mTlsAuthPrivateData
= Private
;
1690 // Retrieve uncommitted data from Browser
1692 BufferSize
= sizeof (TLS_AUTH_CONFIG_IFR_NVDATA
);
1693 IfrNvData
= AllocateZeroPool (BufferSize
);
1694 if (IfrNvData
== NULL
) {
1695 return EFI_OUT_OF_RESOURCES
;
1698 HiiGetBrowserData (&gTlsAuthConfigGuid
, mTlsAuthConfigStorageName
, BufferSize
, (UINT8
*) IfrNvData
);
1700 if ((Action
!= EFI_BROWSER_ACTION_CHANGED
) &&
1701 (Action
!= EFI_BROWSER_ACTION_CHANGING
)) {
1702 Status
= EFI_UNSUPPORTED
;
1706 if (Action
== EFI_BROWSER_ACTION_CHANGING
) {
1707 switch (QuestionId
) {
1708 case KEY_TLS_AUTH_CONFIG_CLIENT_CERT
:
1709 case KEY_TLS_AUTH_CONFIG_SERVER_CA
:
1713 ZeroMem (IfrNvData
->CertGuid
, sizeof (IfrNvData
->CertGuid
));
1714 if (Private
->CertGuid
== NULL
) {
1715 Private
->CertGuid
= (EFI_GUID
*) AllocateZeroPool (sizeof (EFI_GUID
));
1716 if (Private
->CertGuid
== NULL
) {
1717 return EFI_OUT_OF_RESOURCES
;
1720 if (QuestionId
== KEY_TLS_AUTH_CONFIG_CLIENT_CERT
) {
1721 LabelId
= TLS_AUTH_CONFIG_FORMID3_FORM
;
1723 LabelId
= TLS_AUTH_CONFIG_FORMID4_FORM
;
1727 // Refresh selected file.
1729 CleanUpPage (LabelId
, Private
);
1731 case KEY_TLS_AUTH_CONFIG_ENROLL_CERT_FROM_FILE
:
1732 ChooseFile( NULL
, NULL
, UpdateCAFromFile
, &File
);
1735 case KEY_TLS_AUTH_CONFIG_VALUE_SAVE_AND_EXIT
:
1736 Status
= EnrollCertDatabase (Private
, EFI_TLS_CA_CERTIFICATE_VARIABLE
);
1737 if (EFI_ERROR (Status
)) {
1739 EFI_LIGHTGRAY
| EFI_BACKGROUND_BLUE
,
1741 L
"ERROR: Enroll Cert Failure!",
1747 case KEY_TLS_AUTH_CONFIG_VALUE_NO_SAVE_AND_EXIT
:
1748 if (Private
->FileContext
->FHandle
!= NULL
) {
1749 CloseFile (Private
->FileContext
->FHandle
);
1750 Private
->FileContext
->FHandle
= NULL
;
1751 if (Private
->FileContext
->FileName
!= NULL
){
1752 FreePool(Private
->FileContext
->FileName
);
1753 Private
->FileContext
->FileName
= NULL
;
1757 if (Private
->CertGuid
!= NULL
) {
1758 FreePool (Private
->CertGuid
);
1759 Private
->CertGuid
= NULL
;
1763 case KEY_TLS_AUTH_CONFIG_DELETE_CERT
:
1766 EFI_TLS_CA_CERTIFICATE_VARIABLE
,
1767 &gEfiTlsCaCertificateGuid
,
1769 TLS_AUTH_CONFIG_FORMID5_FORM
,
1770 OPTION_DEL_CA_ESTION_ID
1775 if ((QuestionId
>= OPTION_DEL_CA_ESTION_ID
) &&
1776 (QuestionId
< (OPTION_DEL_CA_ESTION_ID
+ OPTION_CONFIG_RANGE
))) {
1779 EFI_TLS_CA_CERTIFICATE_VARIABLE
,
1780 &gEfiTlsCaCertificateGuid
,
1782 TLS_AUTH_CONFIG_FORMID5_FORM
,
1783 OPTION_DEL_CA_ESTION_ID
,
1784 QuestionId
- OPTION_DEL_CA_ESTION_ID
1789 } else if (Action
== EFI_BROWSER_ACTION_CHANGED
) {
1790 switch (QuestionId
) {
1791 case KEY_TLS_AUTH_CONFIG_CERT_GUID
:
1792 ASSERT (Private
->CertGuid
!= NULL
);
1793 Status
= StringToGuid (
1794 IfrNvData
->CertGuid
,
1795 StrLen (IfrNvData
->CertGuid
),
1798 if (EFI_ERROR (Status
)) {
1802 *ActionRequest
= EFI_BROWSER_ACTION_REQUEST_FORM_APPLY
;
1811 if (!EFI_ERROR (Status
)) {
1812 BufferSize
= sizeof (TLS_AUTH_CONFIG_IFR_NVDATA
);
1813 HiiSetBrowserData (&gTlsAuthConfigGuid
, mTlsAuthConfigStorageName
, BufferSize
, (UINT8
*) IfrNvData
, NULL
);
1816 FreePool (IfrNvData
);