summaryrefslogtreecommitdiffstats
path: root/NetworkPkg/TlsAuthConfigDxe
diff options
context:
space:
mode:
authorMichael Kubacki <michael.kubacki@microsoft.com>2021-12-05 14:54:07 -0800
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2021-12-07 17:24:28 +0000
commitd1050b9dff1cace252aff86630bfdb59dff5f507 (patch)
tree77f796143980742d97a883f62ce339a270474801 /NetworkPkg/TlsAuthConfigDxe
parent2f88bd3a1296c522317f1c21377876de63de5be7 (diff)
downloadedk2-d1050b9dff1cace252aff86630bfdb59dff5f507.tar.gz
edk2-d1050b9dff1cace252aff86630bfdb59dff5f507.tar.bz2
edk2-d1050b9dff1cace252aff86630bfdb59dff5f507.zip
NetworkPkg: Apply uncrustify changes
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3737 Apply uncrustify changes to .c/.h files in the NetworkPkg package Cc: Andrew Fish <afish@apple.com> Cc: Leif Lindholm <leif@nuviainc.com> Cc: Michael D Kinney <michael.d.kinney@intel.com> Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com> Reviewed-by: Maciej Rabeda <maciej.rabeda@linux.intel.com>
Diffstat (limited to 'NetworkPkg/TlsAuthConfigDxe')
-rw-r--r--NetworkPkg/TlsAuthConfigDxe/TlsAuthConfigDxe.c9
-rw-r--r--NetworkPkg/TlsAuthConfigDxe/TlsAuthConfigImpl.c712
-rw-r--r--NetworkPkg/TlsAuthConfigDxe/TlsAuthConfigImpl.h38
-rw-r--r--NetworkPkg/TlsAuthConfigDxe/TlsAuthConfigNvData.h48
4 files changed, 405 insertions, 402 deletions
diff --git a/NetworkPkg/TlsAuthConfigDxe/TlsAuthConfigDxe.c b/NetworkPkg/TlsAuthConfigDxe/TlsAuthConfigDxe.c
index c0870ab997..5cf8b0d838 100644
--- a/NetworkPkg/TlsAuthConfigDxe/TlsAuthConfigDxe.c
+++ b/NetworkPkg/TlsAuthConfigDxe/TlsAuthConfigDxe.c
@@ -24,13 +24,13 @@ TlsAuthConfigDxeUnload (
IN EFI_HANDLE ImageHandle
)
{
- EFI_STATUS Status;
- TLS_AUTH_CONFIG_PRIVATE_DATA *PrivateData;
+ EFI_STATUS Status;
+ TLS_AUTH_CONFIG_PRIVATE_DATA *PrivateData;
Status = gBS->HandleProtocol (
ImageHandle,
&gEfiCallerIdGuid,
- (VOID **) &PrivateData
+ (VOID **)&PrivateData
);
if (EFI_ERROR (Status)) {
return Status;
@@ -70,7 +70,7 @@ TlsAuthConfigDxeDriverEntryPoint (
{
EFI_STATUS Status;
- TLS_AUTH_CONFIG_PRIVATE_DATA *PrivateData;
+ TLS_AUTH_CONFIG_PRIVATE_DATA *PrivateData;
PrivateData = NULL;
@@ -125,4 +125,3 @@ ON_ERROR:
return Status;
}
-
diff --git a/NetworkPkg/TlsAuthConfigDxe/TlsAuthConfigImpl.c b/NetworkPkg/TlsAuthConfigDxe/TlsAuthConfigImpl.c
index 110fe87145..745155e6d7 100644
--- a/NetworkPkg/TlsAuthConfigDxe/TlsAuthConfigImpl.c
+++ b/NetworkPkg/TlsAuthConfigDxe/TlsAuthConfigImpl.c
@@ -9,15 +9,14 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include "TlsAuthConfigImpl.h"
-VOID *mStartOpCodeHandle = NULL;
-VOID *mEndOpCodeHandle = NULL;
-EFI_IFR_GUID_LABEL *mStartLabel = NULL;
-EFI_IFR_GUID_LABEL *mEndLabel = NULL;
+VOID *mStartOpCodeHandle = NULL;
+VOID *mEndOpCodeHandle = NULL;
+EFI_IFR_GUID_LABEL *mStartLabel = NULL;
+EFI_IFR_GUID_LABEL *mEndLabel = NULL;
+CHAR16 mTlsAuthConfigStorageName[] = L"TLS_AUTH_CONFIG_IFR_NVDATA";
-CHAR16 mTlsAuthConfigStorageName[] = L"TLS_AUTH_CONFIG_IFR_NVDATA";
-
-TLS_AUTH_CONFIG_PRIVATE_DATA *mTlsAuthPrivateData = NULL;
+TLS_AUTH_CONFIG_PRIVATE_DATA *mTlsAuthPrivateData = NULL;
HII_VENDOR_DEVICE_PATH mTlsAuthConfigHiiVendorDevicePath = {
{
@@ -25,8 +24,8 @@ HII_VENDOR_DEVICE_PATH mTlsAuthConfigHiiVendorDevicePath = {
HARDWARE_DEVICE_PATH,
HW_VENDOR_DP,
{
- (UINT8) (sizeof (VENDOR_DEVICE_PATH)),
- (UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8)
+ (UINT8)(sizeof (VENDOR_DEVICE_PATH)),
+ (UINT8)((sizeof (VENDOR_DEVICE_PATH)) >> 8)
}
},
TLS_AUTH_CONFIG_GUID
@@ -35,8 +34,8 @@ HII_VENDOR_DEVICE_PATH mTlsAuthConfigHiiVendorDevicePath = {
END_DEVICE_PATH_TYPE,
END_ENTIRE_DEVICE_PATH_SUBTYPE,
{
- (UINT8) (END_DEVICE_PATH_LENGTH),
- (UINT8) ((END_DEVICE_PATH_LENGTH) >> 8)
+ (UINT8)(END_DEVICE_PATH_LENGTH),
+ (UINT8)((END_DEVICE_PATH_LENGTH) >> 8)
}
}
};
@@ -44,7 +43,7 @@ HII_VENDOR_DEVICE_PATH mTlsAuthConfigHiiVendorDevicePath = {
//
// Possible DER-encoded certificate file suffixes, end with NULL pointer.
//
-CHAR16* mDerPemEncodedSuffix[] = {
+CHAR16 *mDerPemEncodedSuffix[] = {
L".cer",
L".der",
L".crt",
@@ -63,15 +62,17 @@ CHAR16* mDerPemEncodedSuffix[] = {
**/
BOOLEAN
IsDerPemEncodeCertificate (
- IN CONST CHAR16 *FileSuffix
-)
+ IN CONST CHAR16 *FileSuffix
+ )
{
- UINTN Index;
+ UINTN Index;
+
for (Index = 0; mDerPemEncodedSuffix[Index] != NULL; Index++) {
if (StrCmp (FileSuffix, mDerPemEncodedSuffix[Index]) == 0) {
return TRUE;
}
}
+
return FALSE;
}
@@ -117,35 +118,35 @@ GuidToString (
**/
EFI_STATUS
UpdateDeletePage (
- IN TLS_AUTH_CONFIG_PRIVATE_DATA *Private,
- IN CHAR16 *VariableName,
- IN EFI_GUID *VendorGuid,
- IN UINT16 LabelNumber,
- IN EFI_FORM_ID FormId,
- IN EFI_QUESTION_ID QuestionIdBase
+ IN TLS_AUTH_CONFIG_PRIVATE_DATA *Private,
+ IN CHAR16 *VariableName,
+ IN EFI_GUID *VendorGuid,
+ IN UINT16 LabelNumber,
+ IN EFI_FORM_ID FormId,
+ IN EFI_QUESTION_ID QuestionIdBase
)
{
- EFI_STATUS Status;
- UINT32 Index;
- UINTN CertCount;
- UINTN GuidIndex;
- VOID *StartOpCodeHandle;
- VOID *EndOpCodeHandle;
- EFI_IFR_GUID_LABEL *StartLabel;
- EFI_IFR_GUID_LABEL *EndLabel;
- UINTN DataSize;
- UINT8 *Data;
- EFI_SIGNATURE_LIST *CertList;
- EFI_SIGNATURE_DATA *Cert;
- UINT32 ItemDataSize;
- CHAR16 *GuidStr;
- EFI_STRING_ID GuidID;
- EFI_STRING_ID Help;
-
- Data = NULL;
- CertList = NULL;
- Cert = NULL;
- GuidStr = NULL;
+ EFI_STATUS Status;
+ UINT32 Index;
+ UINTN CertCount;
+ UINTN GuidIndex;
+ VOID *StartOpCodeHandle;
+ VOID *EndOpCodeHandle;
+ EFI_IFR_GUID_LABEL *StartLabel;
+ EFI_IFR_GUID_LABEL *EndLabel;
+ UINTN DataSize;
+ UINT8 *Data;
+ EFI_SIGNATURE_LIST *CertList;
+ EFI_SIGNATURE_DATA *Cert;
+ UINT32 ItemDataSize;
+ CHAR16 *GuidStr;
+ EFI_STRING_ID GuidID;
+ EFI_STRING_ID Help;
+
+ Data = NULL;
+ CertList = NULL;
+ Cert = NULL;
+ GuidStr = NULL;
StartOpCodeHandle = NULL;
EndOpCodeHandle = NULL;
@@ -167,34 +168,34 @@ UpdateDeletePage (
//
// Create Hii Extend Label OpCode.
//
- StartLabel = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode (
- StartOpCodeHandle,
- &gEfiIfrTianoGuid,
- NULL,
- sizeof (EFI_IFR_GUID_LABEL)
- );
- StartLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL;
- StartLabel->Number = LabelNumber;
-
- EndLabel = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode (
- EndOpCodeHandle,
- &gEfiIfrTianoGuid,
- NULL,
- sizeof (EFI_IFR_GUID_LABEL)
- );
- EndLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL;
- EndLabel->Number = LABEL_END;
+ StartLabel = (EFI_IFR_GUID_LABEL *)HiiCreateGuidOpCode (
+ StartOpCodeHandle,
+ &gEfiIfrTianoGuid,
+ NULL,
+ sizeof (EFI_IFR_GUID_LABEL)
+ );
+ StartLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL;
+ StartLabel->Number = LabelNumber;
+
+ EndLabel = (EFI_IFR_GUID_LABEL *)HiiCreateGuidOpCode (
+ EndOpCodeHandle,
+ &gEfiIfrTianoGuid,
+ NULL,
+ sizeof (EFI_IFR_GUID_LABEL)
+ );
+ EndLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL;
+ EndLabel->Number = LABEL_END;
//
// Read Variable.
//
DataSize = 0;
- Status = gRT->GetVariable (VariableName, VendorGuid, NULL, &DataSize, Data);
- if (EFI_ERROR (Status) && Status != EFI_BUFFER_TOO_SMALL) {
+ Status = gRT->GetVariable (VariableName, VendorGuid, NULL, &DataSize, Data);
+ if (EFI_ERROR (Status) && (Status != EFI_BUFFER_TOO_SMALL)) {
goto ON_EXIT;
}
- Data = (UINT8 *) AllocateZeroPool (DataSize);
+ Data = (UINT8 *)AllocateZeroPool (DataSize);
if (Data == NULL) {
Status = EFI_OUT_OF_RESOURCES;
goto ON_EXIT;
@@ -214,12 +215,11 @@ UpdateDeletePage (
//
// Enumerate all data.
//
- ItemDataSize = (UINT32) DataSize;
- CertList = (EFI_SIGNATURE_LIST *) Data;
- GuidIndex = 0;
+ ItemDataSize = (UINT32)DataSize;
+ CertList = (EFI_SIGNATURE_LIST *)Data;
+ GuidIndex = 0;
while ((ItemDataSize > 0) && (ItemDataSize >= CertList->SignatureListSize)) {
-
if (CompareGuid (&CertList->SignatureType, &gEfiCertX509Guid)) {
Help = STRING_TOKEN (STR_CERT_TYPE_PCKS_GUID);
} else {
@@ -227,24 +227,24 @@ UpdateDeletePage (
// The signature type is not supported in current implementation.
//
ItemDataSize -= CertList->SignatureListSize;
- CertList = (EFI_SIGNATURE_LIST *) ((UINT8 *) CertList + CertList->SignatureListSize);
+ CertList = (EFI_SIGNATURE_LIST *)((UINT8 *)CertList + CertList->SignatureListSize);
continue;
}
- CertCount = (CertList->SignatureListSize - sizeof (EFI_SIGNATURE_LIST) - CertList->SignatureHeaderSize) / CertList->SignatureSize;
+ CertCount = (CertList->SignatureListSize - sizeof (EFI_SIGNATURE_LIST) - CertList->SignatureHeaderSize) / CertList->SignatureSize;
for (Index = 0; Index < CertCount; Index++) {
- Cert = (EFI_SIGNATURE_DATA *) ((UINT8 *) CertList
- + sizeof (EFI_SIGNATURE_LIST)
- + CertList->SignatureHeaderSize
- + Index * CertList->SignatureSize);
+ Cert = (EFI_SIGNATURE_DATA *)((UINT8 *)CertList
+ + sizeof (EFI_SIGNATURE_LIST)
+ + CertList->SignatureHeaderSize
+ + Index * CertList->SignatureSize);
//
// Display GUID and help
//
GuidToString (&Cert->SignatureOwner, GuidStr, 100);
- GuidID = HiiSetString (Private->RegisteredHandle, 0, GuidStr, NULL);
+ GuidID = HiiSetString (Private->RegisteredHandle, 0, GuidStr, NULL);
HiiCreateCheckBoxOpCode (
StartOpCodeHandle,
- (EFI_QUESTION_ID) (QuestionIdBase + GuidIndex++),
+ (EFI_QUESTION_ID)(QuestionIdBase + GuidIndex++),
0,
0,
GuidID,
@@ -256,7 +256,7 @@ UpdateDeletePage (
}
ItemDataSize -= CertList->SignatureListSize;
- CertList = (EFI_SIGNATURE_LIST *) ((UINT8 *) CertList + CertList->SignatureListSize);
+ CertList = (EFI_SIGNATURE_LIST *)((UINT8 *)CertList + CertList->SignatureListSize);
}
ON_EXIT:
@@ -304,110 +304,111 @@ ON_EXIT:
**/
EFI_STATUS
DeleteCert (
- IN TLS_AUTH_CONFIG_PRIVATE_DATA *Private,
- IN CHAR16 *VariableName,
- IN EFI_GUID *VendorGuid,
- IN UINT16 LabelNumber,
- IN EFI_FORM_ID FormId,
- IN EFI_QUESTION_ID QuestionIdBase,
- IN UINTN DeleteIndex
+ IN TLS_AUTH_CONFIG_PRIVATE_DATA *Private,
+ IN CHAR16 *VariableName,
+ IN EFI_GUID *VendorGuid,
+ IN UINT16 LabelNumber,
+ IN EFI_FORM_ID FormId,
+ IN EFI_QUESTION_ID QuestionIdBase,
+ IN UINTN DeleteIndex
)
{
- EFI_STATUS Status;
- UINTN DataSize;
- UINT8 *Data;
- UINT8 *OldData;
- UINT32 Attr;
- UINT32 Index;
- EFI_SIGNATURE_LIST *CertList;
- EFI_SIGNATURE_LIST *NewCertList;
- EFI_SIGNATURE_DATA *Cert;
- UINTN CertCount;
- UINT32 Offset;
- BOOLEAN IsItemFound;
- UINT32 ItemDataSize;
- UINTN GuidIndex;
-
- Data = NULL;
- OldData = NULL;
- CertList = NULL;
- Cert = NULL;
- Attr = 0;
+ EFI_STATUS Status;
+ UINTN DataSize;
+ UINT8 *Data;
+ UINT8 *OldData;
+ UINT32 Attr;
+ UINT32 Index;
+ EFI_SIGNATURE_LIST *CertList;
+ EFI_SIGNATURE_LIST *NewCertList;
+ EFI_SIGNATURE_DATA *Cert;
+ UINTN CertCount;
+ UINT32 Offset;
+ BOOLEAN IsItemFound;
+ UINT32 ItemDataSize;
+ UINTN GuidIndex;
+
+ Data = NULL;
+ OldData = NULL;
+ CertList = NULL;
+ Cert = NULL;
+ Attr = 0;
//
// Get original signature list data.
//
DataSize = 0;
- Status = gRT->GetVariable (VariableName, VendorGuid, NULL, &DataSize, NULL);
- if (EFI_ERROR (Status) && Status != EFI_BUFFER_TOO_SMALL) {
+ Status = gRT->GetVariable (VariableName, VendorGuid, NULL, &DataSize, NULL);
+ if (EFI_ERROR (Status) && (Status != EFI_BUFFER_TOO_SMALL)) {
goto ON_EXIT;
}
- OldData = (UINT8 *) AllocateZeroPool (DataSize);
+ OldData = (UINT8 *)AllocateZeroPool (DataSize);
if (OldData == NULL) {
Status = EFI_OUT_OF_RESOURCES;
goto ON_EXIT;
}
Status = gRT->GetVariable (VariableName, VendorGuid, &Attr, &DataSize, OldData);
- if (EFI_ERROR(Status)) {
+ if (EFI_ERROR (Status)) {
goto ON_EXIT;
}
//
// Allocate space for new variable.
//
- Data = (UINT8*) AllocateZeroPool (DataSize);
+ Data = (UINT8 *)AllocateZeroPool (DataSize);
if (Data == NULL) {
- Status = EFI_OUT_OF_RESOURCES;
+ Status = EFI_OUT_OF_RESOURCES;
goto ON_EXIT;
}
//
// Enumerate all data and erasing the target item.
//
- IsItemFound = FALSE;
- ItemDataSize = (UINT32) DataSize;
- CertList = (EFI_SIGNATURE_LIST *) OldData;
- Offset = 0;
- GuidIndex = 0;
+ IsItemFound = FALSE;
+ ItemDataSize = (UINT32)DataSize;
+ CertList = (EFI_SIGNATURE_LIST *)OldData;
+ Offset = 0;
+ GuidIndex = 0;
while ((ItemDataSize > 0) && (ItemDataSize >= CertList->SignatureListSize)) {
if (CompareGuid (&CertList->SignatureType, &gEfiCertX509Guid)) {
//
// Copy EFI_SIGNATURE_LIST header then calculate the signature count in this list.
//
- CopyMem (Data + Offset, CertList, (sizeof(EFI_SIGNATURE_LIST) + CertList->SignatureHeaderSize));
- NewCertList = (EFI_SIGNATURE_LIST*) (Data + Offset);
- Offset += (sizeof(EFI_SIGNATURE_LIST) + CertList->SignatureHeaderSize);
- Cert = (EFI_SIGNATURE_DATA *) ((UINT8 *) CertList + sizeof (EFI_SIGNATURE_LIST) + CertList->SignatureHeaderSize);
- CertCount = (CertList->SignatureListSize - sizeof (EFI_SIGNATURE_LIST) - CertList->SignatureHeaderSize) / CertList->SignatureSize;
+ CopyMem (Data + Offset, CertList, (sizeof (EFI_SIGNATURE_LIST) + CertList->SignatureHeaderSize));
+ NewCertList = (EFI_SIGNATURE_LIST *)(Data + Offset);
+ Offset += (sizeof (EFI_SIGNATURE_LIST) + CertList->SignatureHeaderSize);
+ Cert = (EFI_SIGNATURE_DATA *)((UINT8 *)CertList + sizeof (EFI_SIGNATURE_LIST) + CertList->SignatureHeaderSize);
+ CertCount = (CertList->SignatureListSize - sizeof (EFI_SIGNATURE_LIST) - CertList->SignatureHeaderSize) / CertList->SignatureSize;
for (Index = 0; Index < CertCount; Index++) {
if (GuidIndex == DeleteIndex) {
//
// Find it! Skip it!
//
NewCertList->SignatureListSize -= CertList->SignatureSize;
- IsItemFound = TRUE;
+ IsItemFound = TRUE;
} else {
//
// This item doesn't match. Copy it to the Data buffer.
//
- CopyMem (Data + Offset, (UINT8*)(Cert), CertList->SignatureSize);
+ CopyMem (Data + Offset, (UINT8 *)(Cert), CertList->SignatureSize);
Offset += CertList->SignatureSize;
}
+
GuidIndex++;
- Cert = (EFI_SIGNATURE_DATA *) ((UINT8 *) Cert + CertList->SignatureSize);
+ Cert = (EFI_SIGNATURE_DATA *)((UINT8 *)Cert + CertList->SignatureSize);
}
} else {
//
// This List doesn't match. Just copy it to the Data buffer.
//
- CopyMem (Data + Offset, (UINT8*)(CertList), CertList->SignatureListSize);
+ CopyMem (Data + Offset, (UINT8 *)(CertList), CertList->SignatureListSize);
Offset += CertList->SignatureListSize;
}
ItemDataSize -= CertList->SignatureListSize;
- CertList = (EFI_SIGNATURE_LIST *) ((UINT8 *) CertList + CertList->SignatureListSize);
+ CertList = (EFI_SIGNATURE_LIST *)((UINT8 *)CertList + CertList->SignatureListSize);
}
if (!IsItemFound) {
@@ -422,23 +423,24 @@ DeleteCert (
// Delete the EFI_SIGNATURE_LIST header if there is no signature in the list.
//
ItemDataSize = Offset;
- CertList = (EFI_SIGNATURE_LIST *) Data;
- Offset = 0;
+ CertList = (EFI_SIGNATURE_LIST *)Data;
+ Offset = 0;
ZeroMem (OldData, ItemDataSize);
while ((ItemDataSize > 0) && (ItemDataSize >= CertList->SignatureListSize)) {
- CertCount = (CertList->SignatureListSize - sizeof (EFI_SIGNATURE_LIST) - CertList->SignatureHeaderSize) / CertList->SignatureSize;
+ CertCount = (CertList->SignatureListSize - sizeof (EFI_SIGNATURE_LIST) - CertList->SignatureHeaderSize) / CertList->SignatureSize;
DEBUG ((DEBUG_INFO, " CertCount = %x\n", CertCount));
if (CertCount != 0) {
- CopyMem (OldData + Offset, (UINT8*)(CertList), CertList->SignatureListSize);
+ CopyMem (OldData + Offset, (UINT8 *)(CertList), CertList->SignatureListSize);
Offset += CertList->SignatureListSize;
}
+
ItemDataSize -= CertList->SignatureListSize;
- CertList = (EFI_SIGNATURE_LIST *) ((UINT8 *) CertList + CertList->SignatureListSize);
+ CertList = (EFI_SIGNATURE_LIST *)((UINT8 *)CertList + CertList->SignatureListSize);
}
DataSize = Offset;
- Status = gRT->SetVariable(
+ Status = gRT->SetVariable (
VariableName,
VendorGuid,
Attr,
@@ -452,11 +454,11 @@ DeleteCert (
ON_EXIT:
if (Data != NULL) {
- FreePool(Data);
+ FreePool (Data);
}
if (OldData != NULL) {
- FreePool(OldData);
+ FreePool (OldData);
}
return UpdateDeletePage (
@@ -469,7 +471,6 @@ ON_EXIT:
);
}
-
/**
Clean the file related resource.
@@ -478,14 +479,14 @@ ON_EXIT:
**/
VOID
CleanFileContext (
- IN TLS_AUTH_CONFIG_PRIVATE_DATA *Private
+ IN TLS_AUTH_CONFIG_PRIVATE_DATA *Private
)
{
if (Private->FileContext->FHandle != NULL) {
Private->FileContext->FHandle->Close (Private->FileContext->FHandle);
Private->FileContext->FHandle = NULL;
- if (Private->FileContext->FileName!= NULL){
- FreePool(Private->FileContext->FileName);
+ if (Private->FileContext->FileName != NULL) {
+ FreePool (Private->FileContext->FileName);
Private->FileContext->FileName = NULL;
}
}
@@ -509,17 +510,17 @@ CleanFileContext (
**/
EFI_STATUS
ReadFileContent (
- IN EFI_FILE_HANDLE FileHandle,
- IN OUT VOID **BufferPtr,
- OUT UINTN *FileSize,
- IN UINTN AddtionAllocateSize
+ IN EFI_FILE_HANDLE FileHandle,
+ IN OUT VOID **BufferPtr,
+ OUT UINTN *FileSize,
+ IN UINTN AddtionAllocateSize
)
{
- UINTN BufferSize;
- UINT64 SourceFileSize;
- VOID *Buffer;
- EFI_STATUS Status;
+ UINTN BufferSize;
+ UINT64 SourceFileSize;
+ VOID *Buffer;
+ EFI_STATUS Status;
if ((FileHandle == NULL) || (FileSize == NULL)) {
return EFI_INVALID_PARAMETER;
@@ -530,7 +531,7 @@ ReadFileContent (
//
// Get the file size
//
- Status = FileHandle->SetPosition (FileHandle, (UINT64) -1);
+ Status = FileHandle->SetPosition (FileHandle, (UINT64)-1);
if (EFI_ERROR (Status)) {
goto ON_EXIT;
}
@@ -545,20 +546,20 @@ ReadFileContent (
goto ON_EXIT;
}
- BufferSize = (UINTN) SourceFileSize + AddtionAllocateSize;
- Buffer = AllocateZeroPool(BufferSize);
+ BufferSize = (UINTN)SourceFileSize + AddtionAllocateSize;
+ Buffer = AllocateZeroPool (BufferSize);
if (Buffer == NULL) {
return EFI_OUT_OF_RESOURCES;
}
- BufferSize = (UINTN) SourceFileSize;
+ BufferSize = (UINTN)SourceFileSize;
*FileSize = BufferSize;
Status = FileHandle->Read (FileHandle, &BufferSize, Buffer);
- if (EFI_ERROR (Status) || BufferSize != *FileSize) {
+ if (EFI_ERROR (Status) || (BufferSize != *FileSize)) {
FreePool (Buffer);
Buffer = NULL;
- Status = EFI_BAD_BUFFER_SIZE;
+ Status = EFI_BAD_BUFFER_SIZE;
goto ON_EXIT;
}
@@ -579,7 +580,7 @@ ON_EXIT:
CHAR16 *
EFIAPI
DevicePathToStr (
- IN EFI_DEVICE_PATH_PROTOCOL *DevPath
+ IN EFI_DEVICE_PATH_PROTOCOL *DevPath
)
{
return ConvertDevicePathToText (
@@ -589,7 +590,6 @@ DevicePathToStr (
);
}
-
/**
Extract filename from device path. The returned buffer is allocated using AllocateCopyPool.
The caller is responsible for freeing the allocated buffer using FreePool(). If return NULL
@@ -603,34 +603,34 @@ DevicePathToStr (
**/
CHAR16 *
ExtractFileNameFromDevicePath (
- IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
+ IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
)
{
- CHAR16 *String;
- CHAR16 *MatchString;
- CHAR16 *LastMatch;
- CHAR16 *FileName;
- UINTN Length;
+ CHAR16 *String;
+ CHAR16 *MatchString;
+ CHAR16 *LastMatch;
+ CHAR16 *FileName;
+ UINTN Length;
- ASSERT(DevicePath != NULL);
+ ASSERT (DevicePath != NULL);
- String = DevicePathToStr(DevicePath);
+ String = DevicePathToStr (DevicePath);
MatchString = String;
LastMatch = String;
FileName = NULL;
- while(MatchString != NULL){
+ while (MatchString != NULL) {
LastMatch = MatchString + 1;
- MatchString = StrStr(LastMatch,L"\\");
+ MatchString = StrStr (LastMatch, L"\\");
}
- Length = StrLen(LastMatch);
- FileName = AllocateCopyPool ((Length + 1) * sizeof(CHAR16), LastMatch);
+ Length = StrLen (LastMatch);
+ FileName = AllocateCopyPool ((Length + 1) * sizeof (CHAR16), LastMatch);
if (FileName != NULL) {
*(FileName + Length) = 0;
}
- FreePool(String);
+ FreePool (String);
return FileName;
}
@@ -647,28 +647,28 @@ ExtractFileNameFromDevicePath (
**/
EFI_STATUS
EnrollX509toVariable (
- IN TLS_AUTH_CONFIG_PRIVATE_DATA *Private,
- IN CHAR16 *VariableName
+ IN TLS_AUTH_CONFIG_PRIVATE_DATA *Private,
+ IN CHAR16 *VariableName
)
{
- EFI_STATUS Status;
- UINTN X509DataSize;
- VOID *X509Data;
- EFI_SIGNATURE_LIST *CACert;
- EFI_SIGNATURE_DATA *CACertData;
- VOID *Data;
- UINTN DataSize;
- UINTN SigDataSize;
- UINT32 Attr;
-
- X509DataSize = 0;
- SigDataSize = 0;
- DataSize = 0;
- X509Data = NULL;
- CACert = NULL;
- CACertData = NULL;
- Data = NULL;
- Attr = 0;
+ EFI_STATUS Status;
+ UINTN X509DataSize;
+ VOID *X509Data;
+ EFI_SIGNATURE_LIST *CACert;
+ EFI_SIGNATURE_DATA *CACertData;
+ VOID *Data;
+ UINTN DataSize;
+ UINTN SigDataSize;
+ UINT32 Attr;
+
+ X509DataSize = 0;
+ SigDataSize = 0;
+ DataSize = 0;
+ X509Data = NULL;
+ CACert = NULL;
+ CACertData = NULL;
+ Data = NULL;
+ Attr = 0;
Status = ReadFileContent (
Private->FileContext->FHandle,
@@ -679,9 +679,10 @@ EnrollX509toVariable (
if (EFI_ERROR (Status)) {
goto ON_EXIT;
}
+
ASSERT (X509Data != NULL);
- SigDataSize = sizeof(EFI_SIGNATURE_LIST) + sizeof(EFI_SIGNATURE_DATA) - 1 + X509DataSize;
+ SigDataSize = sizeof (EFI_SIGNATURE_LIST) + sizeof (EFI_SIGNATURE_DATA) - 1 + X509DataSize;
Data = AllocateZeroPool (SigDataSize);
if (Data == NULL) {
@@ -692,22 +693,22 @@ EnrollX509toVariable (
//
// Fill Certificate Database parameters.
//
- CACert = (EFI_SIGNATURE_LIST*) Data;
- CACert->SignatureListSize = (UINT32) SigDataSize;
+ CACert = (EFI_SIGNATURE_LIST *)Data;
+ CACert->SignatureListSize = (UINT32)SigDataSize;
CACert->SignatureHeaderSize = 0;
- CACert->SignatureSize = (UINT32) (sizeof(EFI_SIGNATURE_DATA) - 1 + X509DataSize);
+ CACert->SignatureSize = (UINT32)(sizeof (EFI_SIGNATURE_DATA) - 1 + X509DataSize);
CopyGuid (&CACert->SignatureType, &gEfiCertX509Guid);
- CACertData = (EFI_SIGNATURE_DATA*) ((UINT8* ) CACert + sizeof (EFI_SIGNATURE_LIST));
+ CACertData = (EFI_SIGNATURE_DATA *)((UINT8 *)CACert + sizeof (EFI_SIGNATURE_LIST));
CopyGuid (&CACertData->SignatureOwner, Private->CertGuid);
- CopyMem ((UINT8* ) (CACertData->SignatureData), X509Data, X509DataSize);
+ CopyMem ((UINT8 *)(CACertData->SignatureData), X509Data, X509DataSize);
//
// Check if the signature database entry already exists. If it does, use the
// EFI_VARIABLE_APPEND_WRITE attribute to append the new signature data to
// the original variable, plus preserve the original variable attributes.
//
- Status = gRT->GetVariable(
+ Status = gRT->GetVariable (
VariableName,
&gEfiTlsCaCertificateGuid,
&Attr,
@@ -722,7 +723,7 @@ EnrollX509toVariable (
goto ON_EXIT;
}
- Status = gRT->SetVariable(
+ Status = gRT->SetVariable (
VariableName,
&gEfiTlsCaCertificateGuid,
Attr,
@@ -770,8 +771,8 @@ EnrollCertDatabase (
IN CHAR16 *VariableName
)
{
- UINT16* FilePostFix;
- UINTN NameLength;
+ UINT16 *FilePostFix;
+ UINTN NameLength;
if ((Private->FileContext->FileName == NULL) || (Private->FileContext->FHandle == NULL) || (Private->CertGuid == NULL)) {
return EFI_INVALID_PARAMETER;
@@ -784,6 +785,7 @@ EnrollCertDatabase (
if (NameLength <= 4) {
return EFI_INVALID_PARAMETER;
}
+
FilePostFix = Private->FileContext->FileName + NameLength - 4;
if (IsDerPemEncodeCertificate (FilePostFix)) {
@@ -820,12 +822,12 @@ RefreshUpdateData (
//
// Create Hii Extend Label OpCode as the start opcode
//
- mStartLabel = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode (
- mStartOpCodeHandle,
- &gEfiIfrTianoGuid,
- NULL,
- sizeof (EFI_IFR_GUID_LABEL)
- );
+ mStartLabel = (EFI_IFR_GUID_LABEL *)HiiCreateGuidOpCode (
+ mStartOpCodeHandle,
+ &gEfiIfrTianoGuid,
+ NULL,
+ sizeof (EFI_IFR_GUID_LABEL)
+ );
mStartLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL;
}
@@ -838,8 +840,8 @@ RefreshUpdateData (
**/
VOID
CleanUpPage (
- IN UINT16 LabelId,
- IN TLS_AUTH_CONFIG_PRIVATE_DATA *PrivateData
+ IN UINT16 LabelId,
+ IN TLS_AUTH_CONFIG_PRIVATE_DATA *PrivateData
)
{
RefreshUpdateData ();
@@ -868,19 +870,20 @@ CleanUpPage (
**/
BOOLEAN
-UpdatePage(
+UpdatePage (
IN EFI_DEVICE_PATH_PROTOCOL *FilePath,
IN EFI_FORM_ID FormId
)
{
- CHAR16 *FileName;
- EFI_STRING_ID StringToken;
+ CHAR16 *FileName;
+ EFI_STRING_ID StringToken;
FileName = NULL;
if (FilePath != NULL) {
- FileName = ExtractFileNameFromDevicePath(FilePath);
+ FileName = ExtractFileNameFromDevicePath (FilePath);
}
+
if (FileName == NULL) {
//
// FileName = NULL has two case:
@@ -890,6 +893,7 @@ UpdatePage(
//
return TRUE;
}
+
StringToken = HiiSetString (mTlsAuthPrivateData->RegisteredHandle, 0, FileName, NULL);
mTlsAuthPrivateData->FileContext->FileName = FileName;
@@ -912,7 +916,7 @@ UpdatePage(
0,
0,
0
- );
+ );
HiiUpdateForm (
mTlsAuthPrivateData->RegisteredHandle,
@@ -936,10 +940,10 @@ UpdatePage(
BOOLEAN
EFIAPI
UpdateCAFromFile (
- IN EFI_DEVICE_PATH_PROTOCOL *FilePath
+ IN EFI_DEVICE_PATH_PROTOCOL *FilePath
)
{
- return UpdatePage(FilePath, TLS_AUTH_CONFIG_FORMID4_FORM);
+ return UpdatePage (FilePath, TLS_AUTH_CONFIG_FORMID4_FORM);
}
/**
@@ -954,7 +958,7 @@ UpdateCAFromFile (
**/
EFI_STATUS
TlsAuthConfigFormUnload (
- IN TLS_AUTH_CONFIG_PRIVATE_DATA *Private
+ IN TLS_AUTH_CONFIG_PRIVATE_DATA *Private
)
{
if (Private->DriverHandle != NULL) {
@@ -1001,7 +1005,6 @@ TlsAuthConfigFormUnload (
return EFI_SUCCESS;
}
-
/**
Initialize the configuration form.
@@ -1013,10 +1016,10 @@ TlsAuthConfigFormUnload (
**/
EFI_STATUS
TlsAuthConfigFormInit (
- IN TLS_AUTH_CONFIG_PRIVATE_DATA *Private
+ IN TLS_AUTH_CONFIG_PRIVATE_DATA *Private
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
Private->Signature = TLS_AUTH_CONFIG_PRIVATE_DATA_SIGNATURE;
@@ -1078,23 +1081,23 @@ TlsAuthConfigFormInit (
//
// Create Hii Extend Label OpCode as the start opcode
//
- mStartLabel = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode (
- mStartOpCodeHandle,
- &gEfiIfrTianoGuid,
- NULL,
- sizeof (EFI_IFR_GUID_LABEL)
- );
+ mStartLabel = (EFI_IFR_GUID_LABEL *)HiiCreateGuidOpCode (
+ mStartOpCodeHandle,
+ &gEfiIfrTianoGuid,
+ NULL,
+ sizeof (EFI_IFR_GUID_LABEL)
+ );
mStartLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL;
//
// Create Hii Extend Label OpCode as the end opcode
//
- mEndLabel = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode (
- mEndOpCodeHandle,
- &gEfiIfrTianoGuid,
- NULL,
- sizeof (EFI_IFR_GUID_LABEL)
- );
+ mEndLabel = (EFI_IFR_GUID_LABEL *)HiiCreateGuidOpCode (
+ mEndOpCodeHandle,
+ &gEfiIfrTianoGuid,
+ NULL,
+ sizeof (EFI_IFR_GUID_LABEL)
+ );
mEndLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL;
mEndLabel->Number = LABEL_END;
@@ -1185,15 +1188,15 @@ TlsAuthConfigAccessExtractConfig (
OUT EFI_STRING *Results
)
{
- EFI_STATUS Status;
- UINTN BufferSize;
- UINTN Size;
- EFI_STRING ConfigRequest;
- EFI_STRING ConfigRequestHdr;
- TLS_AUTH_CONFIG_PRIVATE_DATA *Private;
- BOOLEAN AllocatedRequest;
-
- if (Progress == NULL || Results == NULL) {
+ EFI_STATUS Status;
+ UINTN BufferSize;
+ UINTN Size;
+ EFI_STRING ConfigRequest;
+ EFI_STRING ConfigRequestHdr;
+ TLS_AUTH_CONFIG_PRIVATE_DATA *Private;
+ BOOLEAN AllocatedRequest;
+
+ if ((Progress == NULL) || (Results == NULL)) {
return EFI_INVALID_PARAMETER;
}
@@ -1202,12 +1205,12 @@ TlsAuthConfigAccessExtractConfig (
ConfigRequest = NULL;
Size = 0;
- Private = TLS_AUTH_CONFIG_PRIVATE_FROM_THIS (This);
+ Private = TLS_AUTH_CONFIG_PRIVATE_FROM_THIS (This);
- BufferSize = sizeof (TLS_AUTH_CONFIG_IFR_NVDATA);
+ BufferSize = sizeof (TLS_AUTH_CONFIG_IFR_NVDATA);
ZeroMem (&Private->TlsAuthConfigNvData, BufferSize);
- *Progress = Request;
+ *Progress = Request;
if ((Request != NULL) && !HiiIsConfigHdrMatch (Request, &gTlsAuthConfigGuid, mTlsAuthConfigStorageName)) {
return EFI_NOT_FOUND;
@@ -1222,8 +1225,8 @@ TlsAuthConfigAccessExtractConfig (
// followed by "&OFFSET=0&WIDTH=WWWWWWWWWWWWWWWW" followed by a Null-terminator
//
ConfigRequestHdr = HiiConstructConfigHdr (&gTlsAuthConfigGuid, mTlsAuthConfigStorageName, Private->DriverHandle);
- Size = (StrLen (ConfigRequestHdr) + 32 + 1) * sizeof (CHAR16);
- ConfigRequest = AllocateZeroPool (Size);
+ Size = (StrLen (ConfigRequestHdr) + 32 + 1) * sizeof (CHAR16);
+ ConfigRequest = AllocateZeroPool (Size);
ASSERT (ConfigRequest != NULL);
AllocatedRequest = TRUE;
UnicodeSPrint (ConfigRequest, Size, L"%s&OFFSET=0&WIDTH=%016LX", ConfigRequestHdr, (UINT64)BufferSize);
@@ -1234,7 +1237,7 @@ TlsAuthConfigAccessExtractConfig (
Status = gHiiConfigRouting->BlockToConfig (
gHiiConfigRouting,
ConfigRequest,
- (UINT8 *) &Private->TlsAuthConfigNvData,
+ (UINT8 *)&Private->TlsAuthConfigNvData,
BufferSize,
Results,
Progress
@@ -1307,13 +1310,14 @@ TlsAuthConfigAccessRouteConfig (
OUT EFI_STRING *Progress
)
{
- EFI_STATUS Status;
- UINTN BufferSize;
- TLS_AUTH_CONFIG_PRIVATE_DATA *Private;
+ EFI_STATUS Status;
+ UINTN BufferSize;
+ TLS_AUTH_CONFIG_PRIVATE_DATA *Private;
if (Progress == NULL) {
return EFI_INVALID_PARAMETER;
}
+
*Progress = Configuration;
if (Configuration == NULL) {
@@ -1336,7 +1340,7 @@ TlsAuthConfigAccessRouteConfig (
Status = gHiiConfigRouting->ConfigToBlock (
gHiiConfigRouting,
Configuration,
- (UINT8 *) &Private->TlsAuthConfigNvData,
+ (UINT8 *)&Private->TlsAuthConfigNvData,
&BufferSize,
Progress
);
@@ -1375,26 +1379,26 @@ TlsAuthConfigAccessRouteConfig (
EFI_STATUS
EFIAPI
TlsAuthConfigAccessCallback (
- IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
- IN EFI_BROWSER_ACTION Action,
- IN EFI_QUESTION_ID QuestionId,
- IN UINT8 Type,
- IN OUT EFI_IFR_TYPE_VALUE *Value,
- OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest
+ IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
+ IN EFI_BROWSER_ACTION Action,
+ IN EFI_QUESTION_ID QuestionId,
+ IN UINT8 Type,
+ IN OUT EFI_IFR_TYPE_VALUE *Value,
+ OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest
)
{
- EFI_STATUS Status;
- RETURN_STATUS RStatus;
- TLS_AUTH_CONFIG_PRIVATE_DATA *Private;
- UINTN BufferSize;
- TLS_AUTH_CONFIG_IFR_NVDATA *IfrNvData;
- UINT16 LabelId;
- EFI_DEVICE_PATH_PROTOCOL *File;
- EFI_HII_POPUP_PROTOCOL *HiiPopUp;
- EFI_HII_POPUP_SELECTION PopUpSelect;
-
- Status = EFI_SUCCESS;
- File = NULL;
+ EFI_STATUS Status;
+ RETURN_STATUS RStatus;
+ TLS_AUTH_CONFIG_PRIVATE_DATA *Private;
+ UINTN BufferSize;
+ TLS_AUTH_CONFIG_IFR_NVDATA *IfrNvData;
+ UINT16 LabelId;
+ EFI_DEVICE_PATH_PROTOCOL *File;
+ EFI_HII_POPUP_PROTOCOL *HiiPopUp;
+ EFI_HII_POPUP_SELECTION PopUpSelect;
+
+ Status = EFI_SUCCESS;
+ File = NULL;
if ((This == NULL) || (Value == NULL) || (ActionRequest == NULL)) {
return EFI_INVALID_PARAMETER;
@@ -1403,7 +1407,7 @@ TlsAuthConfigAccessCallback (
Private = TLS_AUTH_CONFIG_PRIVATE_FROM_THIS (This);
mTlsAuthPrivateData = Private;
- Status = gBS->LocateProtocol (&gEfiHiiPopupProtocolGuid, NULL, (VOID**) &HiiPopUp);
+ Status = gBS->LocateProtocol (&gEfiHiiPopupProtocolGuid, NULL, (VOID **)&HiiPopUp);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "Can't find Form PopUp protocol. Exit (%r)\n", Status));
return Status;
@@ -1413,122 +1417,128 @@ TlsAuthConfigAccessCallback (
// Retrieve uncommitted data from Browser
//
BufferSize = sizeof (TLS_AUTH_CONFIG_IFR_NVDATA);
- IfrNvData = AllocateZeroPool (BufferSize);
+ IfrNvData = AllocateZeroPool (BufferSize);
if (IfrNvData == NULL) {
return EFI_OUT_OF_RESOURCES;
}
- HiiGetBrowserData (&gTlsAuthConfigGuid, mTlsAuthConfigStorageName, BufferSize, (UINT8 *) IfrNvData);
+ HiiGetBrowserData (&gTlsAuthConfigGuid, mTlsAuthConfigStorageName, BufferSize, (UINT8 *)IfrNvData);
if ((Action != EFI_BROWSER_ACTION_CHANGED) &&
(Action != EFI_BROWSER_ACTION_CHANGING) &&
- (Action != EFI_BROWSER_ACTION_FORM_CLOSE)) {
+ (Action != EFI_BROWSER_ACTION_FORM_CLOSE))
+ {
Status = EFI_UNSUPPORTED;
goto EXIT;
}
if (Action == EFI_BROWSER_ACTION_CHANGING) {
switch (QuestionId) {
- case KEY_TLS_AUTH_CONFIG_CLIENT_CERT:
- case KEY_TLS_AUTH_CONFIG_SERVER_CA:
- //
- // Clear Cert GUID.
- //
- ZeroMem (IfrNvData->CertGuid, sizeof (IfrNvData->CertGuid));
- if (Private->CertGuid == NULL) {
- Private->CertGuid = (EFI_GUID *) AllocateZeroPool (sizeof (EFI_GUID));
+ case KEY_TLS_AUTH_CONFIG_CLIENT_CERT:
+ case KEY_TLS_AUTH_CONFIG_SERVER_CA:
+ //
+ // Clear Cert GUID.
+ //
+ ZeroMem (IfrNvData->CertGuid, sizeof (IfrNvData->CertGuid));
if (Private->CertGuid == NULL) {
- return EFI_OUT_OF_RESOURCES;
+ Private->CertGuid = (EFI_GUID *)AllocateZeroPool (sizeof (EFI_GUID));
+ if (Private->CertGuid == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
}
- }
- if (QuestionId == KEY_TLS_AUTH_CONFIG_CLIENT_CERT) {
- LabelId = TLS_AUTH_CONFIG_FORMID3_FORM;
- } else {
- LabelId = TLS_AUTH_CONFIG_FORMID4_FORM;
- }
- //
- // Refresh selected file.
- //
- CleanUpPage (LabelId, Private);
- break;
- case KEY_TLS_AUTH_CONFIG_ENROLL_CERT_FROM_FILE:
- //
- // If the file is already opened, clean the file related resource first.
- //
- CleanFileContext (Private);
-
- ChooseFile( NULL, NULL, UpdateCAFromFile, &File);
- break;
+ if (QuestionId == KEY_TLS_AUTH_CONFIG_CLIENT_CERT) {
+ LabelId = TLS_AUTH_CONFIG_FORMID3_FORM;
+ } else {
+ LabelId = TLS_AUTH_CONFIG_FORMID4_FORM;
+ }
- case KEY_TLS_AUTH_CONFIG_VALUE_SAVE_AND_EXIT:
- Status = EnrollCertDatabase (Private, EFI_TLS_CA_CERTIFICATE_VARIABLE);
- if (EFI_ERROR (Status)) {
+ //
+ // Refresh selected file.
+ //
+ CleanUpPage (LabelId, Private);
+ break;
+ case KEY_TLS_AUTH_CONFIG_ENROLL_CERT_FROM_FILE:
+ //
+ // If the file is already opened, clean the file related resource first.
+ //
CleanFileContext (Private);
- HiiPopUp->CreatePopup (
- HiiPopUp,
- EfiHiiPopupStyleError,
- EfiHiiPopupTypeOk,
- Private->RegisteredHandle,
- STRING_TOKEN (STR_TLS_AUTH_ENROLL_CERT_FAILURE),
- &PopUpSelect
- );
- }
- break;
+ ChooseFile (NULL, NULL, UpdateCAFromFile, &File);
+ break;
- case KEY_TLS_AUTH_CONFIG_VALUE_NO_SAVE_AND_EXIT:
- CleanFileContext (Private);
+ case KEY_TLS_AUTH_CONFIG_VALUE_SAVE_AND_EXIT:
+ Status = EnrollCertDatabase (Private, EFI_TLS_CA_CERTIFICATE_VARIABLE);
+ if (EFI_ERROR (Status)) {
+ CleanFileContext (Private);
+
+ HiiPopUp->CreatePopup (
+ HiiPopUp,
+ EfiHiiPopupStyleError,
+ EfiHiiPopupTypeOk,
+ Private->RegisteredHandle,
+ STRING_TOKEN (STR_TLS_AUTH_ENROLL_CERT_FAILURE),
+ &PopUpSelect
+ );
+ }
- if (Private->CertGuid!= NULL) {
- FreePool (Private->CertGuid);
- Private->CertGuid = NULL;
- }
- break;
-
- case KEY_TLS_AUTH_CONFIG_DELETE_CERT:
- UpdateDeletePage (
- Private,
- EFI_TLS_CA_CERTIFICATE_VARIABLE,
- &gEfiTlsCaCertificateGuid,
- LABEL_CA_DELETE,
- TLS_AUTH_CONFIG_FORMID5_FORM,
- OPTION_DEL_CA_ESTION_ID
- );
- break;
+ break;
+
+ case KEY_TLS_AUTH_CONFIG_VALUE_NO_SAVE_AND_EXIT:
+ CleanFileContext (Private);
- default:
- if ((QuestionId >= OPTION_DEL_CA_ESTION_ID) &&
- (QuestionId < (OPTION_DEL_CA_ESTION_ID + OPTION_CONFIG_RANGE))) {
- DeleteCert (
+ if (Private->CertGuid != NULL) {
+ FreePool (Private->CertGuid);
+ Private->CertGuid = NULL;
+ }
+
+ break;
+
+ case KEY_TLS_AUTH_CONFIG_DELETE_CERT:
+ UpdateDeletePage (
Private,
EFI_TLS_CA_CERTIFICATE_VARIABLE,
&gEfiTlsCaCertificateGuid,
LABEL_CA_DELETE,
TLS_AUTH_CONFIG_FORMID5_FORM,
- OPTION_DEL_CA_ESTION_ID,
- QuestionId - OPTION_DEL_CA_ESTION_ID
+ OPTION_DEL_CA_ESTION_ID
);
- }
- break;
+ break;
+
+ default:
+ if ((QuestionId >= OPTION_DEL_CA_ESTION_ID) &&
+ (QuestionId < (OPTION_DEL_CA_ESTION_ID + OPTION_CONFIG_RANGE)))
+ {
+ DeleteCert (
+ Private,
+ EFI_TLS_CA_CERTIFICATE_VARIABLE,
+ &gEfiTlsCaCertificateGuid,
+ LABEL_CA_DELETE,
+ TLS_AUTH_CONFIG_FORMID5_FORM,
+ OPTION_DEL_CA_ESTION_ID,
+ QuestionId - OPTION_DEL_CA_ESTION_ID
+ );
+ }
+
+ break;
}
} else if (Action == EFI_BROWSER_ACTION_CHANGED) {
switch (QuestionId) {
- case KEY_TLS_AUTH_CONFIG_CERT_GUID:
- ASSERT (Private->CertGuid != NULL);
- RStatus = StrToGuid (
- IfrNvData->CertGuid,
- Private->CertGuid
- );
- if (RETURN_ERROR (RStatus) || (IfrNvData->CertGuid[GUID_STRING_LENGTH] != L'\0')) {
- Status = EFI_INVALID_PARAMETER;
- break;
- }
+ case KEY_TLS_AUTH_CONFIG_CERT_GUID:
+ ASSERT (Private->CertGuid != NULL);
+ RStatus = StrToGuid (
+ IfrNvData->CertGuid,
+ Private->CertGuid
+ );
+ if (RETURN_ERROR (RStatus) || (IfrNvData->CertGuid[GUID_STRING_LENGTH] != L'\0')) {
+ Status = EFI_INVALID_PARAMETER;
+ break;
+ }
- *ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_APPLY;
- break;
- default:
- break;
+ *ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_APPLY;
+ break;
+ default:
+ break;
}
} else if (Action == EFI_BROWSER_ACTION_FORM_CLOSE) {
CleanFileContext (Private);
@@ -1538,17 +1548,15 @@ EXIT:
if (!EFI_ERROR (Status)) {
BufferSize = sizeof (TLS_AUTH_CONFIG_IFR_NVDATA);
- HiiSetBrowserData (&gTlsAuthConfigGuid, mTlsAuthConfigStorageName, BufferSize, (UINT8*) IfrNvData, NULL);
+ HiiSetBrowserData (&gTlsAuthConfigGuid, mTlsAuthConfigStorageName, BufferSize, (UINT8 *)IfrNvData, NULL);
}
FreePool (IfrNvData);
- if (File != NULL){
- FreePool(File);
+ if (File != NULL) {
+ FreePool (File);
File = NULL;
}
return EFI_SUCCESS;
-
}
-
diff --git a/NetworkPkg/TlsAuthConfigDxe/TlsAuthConfigImpl.h b/NetworkPkg/TlsAuthConfigDxe/TlsAuthConfigImpl.h
index 68c16845b3..1552f47a9d 100644
--- a/NetworkPkg/TlsAuthConfigDxe/TlsAuthConfigImpl.h
+++ b/NetworkPkg/TlsAuthConfigDxe/TlsAuthConfigImpl.h
@@ -36,34 +36,33 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include <Guid/ImageAuthentication.h>
#include <Guid/TlsAuthentication.h>
-
//
// Include files with function prototypes
//
#include "TlsAuthConfigNvData.h"
-extern UINT8 TlsAuthConfigDxeStrings[];
-extern UINT8 TlsAuthConfigVfrBin[];
+extern UINT8 TlsAuthConfigDxeStrings[];
+extern UINT8 TlsAuthConfigVfrBin[];
-#define TLS_AUTH_CONFIG_PRIVATE_DATA_SIGNATURE SIGNATURE_32 ('T', 'A', 'C', 'D')
-#define TLS_AUTH_CONFIG_PRIVATE_FROM_THIS(a) CR (a, TLS_AUTH_CONFIG_PRIVATE_DATA, ConfigAccess, TLS_AUTH_CONFIG_PRIVATE_DATA_SIGNATURE)
+#define TLS_AUTH_CONFIG_PRIVATE_DATA_SIGNATURE SIGNATURE_32 ('T', 'A', 'C', 'D')
+#define TLS_AUTH_CONFIG_PRIVATE_FROM_THIS(a) CR (a, TLS_AUTH_CONFIG_PRIVATE_DATA, ConfigAccess, TLS_AUTH_CONFIG_PRIVATE_DATA_SIGNATURE)
#define TLS_AUTH_CONFIG_VAR_BASE_ATTR (EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS)
-typedef struct _TLS_AUTH_CONFIG_PRIVATE_DATA TLS_AUTH_CONFIG_PRIVATE_DATA;
-typedef struct _TLS_AUTH_CONFIG_FILE_CONTEXT TLS_AUTH_CONFIG_FILE_CONTEXT;
+typedef struct _TLS_AUTH_CONFIG_PRIVATE_DATA TLS_AUTH_CONFIG_PRIVATE_DATA;
+typedef struct _TLS_AUTH_CONFIG_FILE_CONTEXT TLS_AUTH_CONFIG_FILE_CONTEXT;
///
/// HII specific Vendor Device Path definition.
///
typedef struct {
- VENDOR_DEVICE_PATH VendorDevicePath;
- EFI_DEVICE_PATH_PROTOCOL End;
+ VENDOR_DEVICE_PATH VendorDevicePath;
+ EFI_DEVICE_PATH_PROTOCOL End;
} HII_VENDOR_DEVICE_PATH;
struct _TLS_AUTH_CONFIG_FILE_CONTEXT {
- EFI_FILE_HANDLE FHandle;
- UINT16 *FileName;
+ EFI_FILE_HANDLE FHandle;
+ UINT16 *FileName;
};
struct _TLS_AUTH_CONFIG_PRIVATE_DATA {
@@ -92,7 +91,7 @@ struct _TLS_AUTH_CONFIG_PRIVATE_DATA {
**/
EFI_STATUS
TlsAuthConfigFormUnload (
- IN TLS_AUTH_CONFIG_PRIVATE_DATA *Private
+ IN TLS_AUTH_CONFIG_PRIVATE_DATA *Private
);
/**
@@ -106,7 +105,7 @@ TlsAuthConfigFormUnload (
**/
EFI_STATUS
TlsAuthConfigFormInit (
- IN TLS_AUTH_CONFIG_PRIVATE_DATA *Private
+ IN TLS_AUTH_CONFIG_PRIVATE_DATA *Private
);
/**
@@ -265,13 +264,12 @@ TlsAuthConfigAccessRouteConfig (
EFI_STATUS
EFIAPI
TlsAuthConfigAccessCallback (
- IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
- IN EFI_BROWSER_ACTION Action,
- IN EFI_QUESTION_ID QuestionId,
- IN UINT8 Type,
- IN OUT EFI_IFR_TYPE_VALUE *Value,
- OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest
+ IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
+ IN EFI_BROWSER_ACTION Action,
+ IN EFI_QUESTION_ID QuestionId,
+ IN UINT8 Type,
+ IN OUT EFI_IFR_TYPE_VALUE *Value,
+ OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest
);
#endif
-
diff --git a/NetworkPkg/TlsAuthConfigDxe/TlsAuthConfigNvData.h b/NetworkPkg/TlsAuthConfigDxe/TlsAuthConfigNvData.h
index 13813873e0..9b7855092a 100644
--- a/NetworkPkg/TlsAuthConfigDxe/TlsAuthConfigNvData.h
+++ b/NetworkPkg/TlsAuthConfigDxe/TlsAuthConfigNvData.h
@@ -11,34 +11,32 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include <Guid/TlsAuthConfigHii.h>
-#define TLS_AUTH_CONFIG_GUID_SIZE 36
-#define TLS_AUTH_CONFIG_GUID_STORAGE_SIZE 37
-
-#define TLS_AUTH_CONFIG_FORMID1_FORM 1
-#define TLS_AUTH_CONFIG_FORMID2_FORM 2
-#define TLS_AUTH_CONFIG_FORMID3_FORM 3
-#define TLS_AUTH_CONFIG_FORMID4_FORM 4
-#define TLS_AUTH_CONFIG_FORMID5_FORM 5
-
-
-#define KEY_TLS_AUTH_CONFIG_SERVER_CA 0x1000
-#define KEY_TLS_AUTH_CONFIG_CLIENT_CERT 0x1001
-#define KEY_TLS_AUTH_CONFIG_ENROLL_CERT 0x1002
-#define KEY_TLS_AUTH_CONFIG_DELETE_CERT 0x1003
-#define KEY_TLS_AUTH_CONFIG_ENROLL_CERT_FROM_FILE 0x1004
-#define KEY_TLS_AUTH_CONFIG_CERT_GUID 0x1005
-#define KEY_TLS_AUTH_CONFIG_VALUE_SAVE_AND_EXIT 0x1006
-#define KEY_TLS_AUTH_CONFIG_VALUE_NO_SAVE_AND_EXIT 0x1007
-
-#define OPTION_DEL_CA_ESTION_ID 0x2000
-#define OPTION_CONFIG_RANGE 0x1000
-
-#define LABEL_CA_DELETE 0x1101
-#define LABEL_END 0xffff
+#define TLS_AUTH_CONFIG_GUID_SIZE 36
+#define TLS_AUTH_CONFIG_GUID_STORAGE_SIZE 37
+
+#define TLS_AUTH_CONFIG_FORMID1_FORM 1
+#define TLS_AUTH_CONFIG_FORMID2_FORM 2
+#define TLS_AUTH_CONFIG_FORMID3_FORM 3
+#define TLS_AUTH_CONFIG_FORMID4_FORM 4
+#define TLS_AUTH_CONFIG_FORMID5_FORM 5
+
+#define KEY_TLS_AUTH_CONFIG_SERVER_CA 0x1000
+#define KEY_TLS_AUTH_CONFIG_CLIENT_CERT 0x1001
+#define KEY_TLS_AUTH_CONFIG_ENROLL_CERT 0x1002
+#define KEY_TLS_AUTH_CONFIG_DELETE_CERT 0x1003
+#define KEY_TLS_AUTH_CONFIG_ENROLL_CERT_FROM_FILE 0x1004
+#define KEY_TLS_AUTH_CONFIG_CERT_GUID 0x1005
+#define KEY_TLS_AUTH_CONFIG_VALUE_SAVE_AND_EXIT 0x1006
+#define KEY_TLS_AUTH_CONFIG_VALUE_NO_SAVE_AND_EXIT 0x1007
+
+#define OPTION_DEL_CA_ESTION_ID 0x2000
+#define OPTION_CONFIG_RANGE 0x1000
+
+#define LABEL_CA_DELETE 0x1101
+#define LABEL_END 0xffff
typedef struct {
CHAR16 CertGuid[TLS_AUTH_CONFIG_GUID_STORAGE_SIZE];
} TLS_AUTH_CONFIG_IFR_NVDATA;
#endif
-