TianoCore EDK2 master
Loading...
Searching...
No Matches
TlsAuthConfigImpl.c File Reference

Go to the source code of this file.

Functions

BOOLEAN IsDerPemEncodeCertificate (IN CONST CHAR16 *FileSuffix)
 
UINTN GuidToString (IN EFI_GUID *Guid, IN CHAR16 *Buffer, IN UINTN BufferSize)
 
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)
 
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)
 
VOID CleanFileContext (IN TLS_AUTH_CONFIG_PRIVATE_DATA *Private)
 
EFI_STATUS ReadFileContent (IN EFI_FILE_HANDLE FileHandle, IN OUT VOID **BufferPtr, OUT UINTN *FileSize, IN UINTN AddtionAllocateSize)
 
CHAR16 *EFIAPI DevicePathToStr (IN EFI_DEVICE_PATH_PROTOCOL *DevPath)
 
CHAR16 * ExtractFileNameFromDevicePath (IN EFI_DEVICE_PATH_PROTOCOL *DevicePath)
 
EFI_STATUS EnrollX509toVariable (IN TLS_AUTH_CONFIG_PRIVATE_DATA *Private, IN CHAR16 *VariableName)
 
EFI_STATUS EnrollCertDatabase (IN TLS_AUTH_CONFIG_PRIVATE_DATA *Private, IN CHAR16 *VariableName)
 
VOID RefreshUpdateData (VOID)
 
VOID CleanUpPage (IN UINT16 LabelId, IN TLS_AUTH_CONFIG_PRIVATE_DATA *PrivateData)
 
BOOLEAN UpdatePage (IN EFI_DEVICE_PATH_PROTOCOL *FilePath, IN EFI_FORM_ID FormId)
 
BOOLEAN EFIAPI UpdateCAFromFile (IN EFI_DEVICE_PATH_PROTOCOL *FilePath)
 
EFI_STATUS TlsAuthConfigFormUnload (IN TLS_AUTH_CONFIG_PRIVATE_DATA *Private)
 
EFI_STATUS TlsAuthConfigFormInit (IN TLS_AUTH_CONFIG_PRIVATE_DATA *Private)
 
EFI_STATUS EFIAPI TlsAuthConfigAccessExtractConfig (IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This, IN CONST EFI_STRING Request, OUT EFI_STRING *Progress, OUT EFI_STRING *Results)
 
EFI_STATUS EFIAPI TlsAuthConfigAccessRouteConfig (IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This, IN CONST EFI_STRING Configuration, OUT EFI_STRING *Progress)
 
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)
 

Variables

VOID * mStartOpCodeHandle = NULL
 
VOID * mEndOpCodeHandle = NULL
 
EFI_IFR_GUID_LABELmStartLabel = NULL
 
EFI_IFR_GUID_LABELmEndLabel = NULL
 
CHAR16 mTlsAuthConfigStorageName [] = L"TLS_AUTH_CONFIG_IFR_NVDATA"
 
TLS_AUTH_CONFIG_PRIVATE_DATAmTlsAuthPrivateData = NULL
 
HII_VENDOR_DEVICE_PATH mTlsAuthConfigHiiVendorDevicePath
 
CHAR16 * mDerPemEncodedSuffix []
 

Detailed Description

The Miscellaneous Routines for TlsAuthConfigDxe driver.

Copyright (c) 2016 - 2018, Intel Corporation. All rights reserved.

SPDX-License-Identifier: BSD-2-Clause-Patent

Definition in file TlsAuthConfigImpl.c.

Function Documentation

◆ CleanFileContext()

VOID CleanFileContext ( IN TLS_AUTH_CONFIG_PRIVATE_DATA Private)

Clean the file related resource.

Parameters
[in]PrivateModule's private data.

Definition at line 481 of file TlsAuthConfigImpl.c.

◆ CleanUpPage()

VOID CleanUpPage ( IN UINT16  LabelId,
IN TLS_AUTH_CONFIG_PRIVATE_DATA PrivateData 
)

Clean up the dynamic opcode at label and form specified by both LabelId.

Parameters
[in]LabelIdIt is both the Form ID and Label ID for opcode deletion.
[in]PrivateDataModule private data.

Definition at line 842 of file TlsAuthConfigImpl.c.

◆ DeleteCert()

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 
)

Delete one entry from cert database.

Parameters
[in]PrivateModule's private data.
[in]VariableNameThe variable name of the database.
[in]VendorGuidA unique identifier for the vendor.
[in]LabelNumberLabel number to insert opcodes.
[in]FormIdForm ID of current page.
[in]QuestionIdBaseBase question id of the cert list.
[in]DeleteIndexCert index to delete.
Return values
EFI_SUCCESSDelete signature successfully.
EFI_NOT_FOUNDCan't find the signature item,
EFI_OUT_OF_RESOURCESCould not allocate needed resources.

Definition at line 306 of file TlsAuthConfigImpl.c.

◆ DevicePathToStr()

CHAR16 *EFIAPI DevicePathToStr ( IN EFI_DEVICE_PATH_PROTOCOL DevPath)

This function converts an input device structure to a Unicode string.

Parameters
[in]DevPathA pointer to the device path structure.
Returns
A new allocated Unicode string that represents the device path.

Definition at line 582 of file TlsAuthConfigImpl.c.

◆ EnrollCertDatabase()

EFI_STATUS EnrollCertDatabase ( IN TLS_AUTH_CONFIG_PRIVATE_DATA Private,
IN CHAR16 *  VariableName 
)

Enroll Cert into TlsCaCertificate. The GUID will be Private->CertGuid.

Parameters
[in]PrivateDataThe module's private data.
[in]VariableNameVariable name of signature database.
Return values
EFI_SUCCESSNew Cert enrolled successfully.
EFI_INVALID_PARAMETERThe parameter is invalid.
EFI_UNSUPPORTEDThe Cert file is unsupported type.
othersFail to enroll Cert data.

Definition at line 769 of file TlsAuthConfigImpl.c.

◆ EnrollX509toVariable()

EFI_STATUS EnrollX509toVariable ( IN TLS_AUTH_CONFIG_PRIVATE_DATA Private,
IN CHAR16 *  VariableName 
)

Enroll a new X509 certificate into Variable.

Parameters
[in]PrivateDataThe module's private data.
[in]VariableNameVariable name of CA database.
Return values
EFI_SUCCESSNew X509 is enrolled successfully.
EFI_OUT_OF_RESOURCESCould not allocate needed resources.

Definition at line 649 of file TlsAuthConfigImpl.c.

◆ ExtractFileNameFromDevicePath()

CHAR16 * ExtractFileNameFromDevicePath ( IN EFI_DEVICE_PATH_PROTOCOL DevicePath)

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 means not enough memory resource.

Parameters
DevicePathDevice path.
Return values
NULLNot enough memory resource for AllocateCopyPool.
OtherA new allocated string that represents the file name.

Definition at line 605 of file TlsAuthConfigImpl.c.

◆ GuidToString()

UINTN GuidToString ( IN EFI_GUID Guid,
IN CHAR16 *  Buffer,
IN UINTN  BufferSize 
)

Worker function that prints an EFI_GUID into specified Buffer.

Parameters
[in]GuidPointer to GUID to print.
[in]BufferBuffer to print Guid into.
[in]BufferSizeSize of Buffer.
Return values
Numberof characters printed.

Definition at line 90 of file TlsAuthConfigImpl.c.

◆ IsDerPemEncodeCertificate()

BOOLEAN IsDerPemEncodeCertificate ( IN CONST CHAR16 *  FileSuffix)

This code checks if the FileSuffix is one of the possible DER/PEM-encoded certificate suffix.

Parameters
[in]FileSuffixThe suffix of the input certificate file
Return values
TRUEIt's a DER/PEM-encoded certificate.
FALSEIt's NOT a DER/PEM-encoded certificate.

Definition at line 64 of file TlsAuthConfigImpl.c.

◆ ReadFileContent()

EFI_STATUS ReadFileContent ( IN EFI_FILE_HANDLE  FileHandle,
IN OUT VOID **  BufferPtr,
OUT UINTN FileSize,
IN UINTN  AddtionAllocateSize 
)

Read file content into BufferPtr, the size of the allocate buffer is *FileSize plus AddtionAllocateSize.

Parameters
[in]FileHandleThe file to be read.
[in,out]BufferPtrPointers to the pointer of allocated buffer.
[out]FileSizeSize of input file
[in]AddtionAllocateSizeAddtion size the buffer need to be allocated. In case the buffer need to contain others besides the file content.
Return values
EFI_SUCCESSThe file was read into the buffer.
EFI_INVALID_PARAMETERA parameter was invalid.
EFI_OUT_OF_RESOURCESA memory allocation failed.
othersUnexpected error.

Definition at line 512 of file TlsAuthConfigImpl.c.

◆ RefreshUpdateData()

VOID RefreshUpdateData ( VOID  )

Refresh the global UpdateData structure.

Definition at line 806 of file TlsAuthConfigImpl.c.

◆ TlsAuthConfigAccessCallback()

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 
)

This function is called to provide results data to the driver. This data consists of a unique key that is used to identify which data is either being passed back or being asked for.

Parameters
ThisPoints to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
ActionSpecifies the type of action taken by the browser.
QuestionIdA unique value which is sent to the original exporting driver so that it can identify the type of data to expect. The format of the data tends to vary based on the opcode that generated the callback.
TypeThe type of value for the question.
ValueA pointer to the data being sent to the original exporting driver.
ActionRequestOn return, points to the action requested by the callback function.
Return values
EFI_SUCCESSThe callback successfully handled the action.
EFI_OUT_OF_RESOURCESNot enough storage is available to hold the variable and its data.
EFI_DEVICE_ERRORThe variable could not be saved.
EFI_UNSUPPORTEDThe specified Action is not supported by the callback.

Definition at line 1381 of file TlsAuthConfigImpl.c.

◆ TlsAuthConfigAccessExtractConfig()

EFI_STATUS EFIAPI TlsAuthConfigAccessExtractConfig ( IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL This,
IN CONST EFI_STRING  Request,
OUT EFI_STRING *  Progress,
OUT EFI_STRING *  Results 
)

This function allows the caller to request the current configuration for one or more named elements. The resulting string is in <ConfigAltResp> format. Any and all alternative configuration strings shall also be appended to the end of the current configuration string. If they are, they must appear after the current configuration. They must contain the same routing (GUID, NAME, PATH) as the current configuration string. They must have an additional description indicating the type of alternative configuration the string represents, "ALTCFG=<StringToken>". That <StringToken> (when converted from Hex UNICODE to binary) is a reference to a string in the associated string pack.

Parameters
ThisPoints to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
RequestA null-terminated Unicode string in <ConfigRequest> format. Note that this includes the routing information as well as the configurable name / value pairs. It is invalid for this string to be in <MultiConfigRequest> format. If a NULL is passed in for the Request field, all of the settings being abstracted by this function will be returned in the Results field. In addition, if a ConfigHdr is passed in with no request elements, all of the settings being abstracted for that particular ConfigHdr reference will be returned in the Results Field.
ProgressOn return, points to a character in the Request string. Points to the string's null terminator if request was successful. Points to the most recent "&" before the first failing name / value pair (or the beginning of the string if the failure is in the first name / value pair) if the request was not successful.
ResultsA null-terminated Unicode string in <MultiConfigAltResp> format which has all values filled in for the names in the Request string. String to be allocated by the called function.
Return values
EFI_SUCCESSThe Results string is filled with the values corresponding to all requested names.
EFI_OUT_OF_RESOURCESNot enough memory to store the parts of the results that must be stored awaiting possible future protocols.
EFI_NOT_FOUNDRouting data doesn't match any known driver. Progress set to the first character in the routing header. Note: There is no requirement that the driver validate the routing data. It must skip the <ConfigHdr> in order to process the names.
EFI_INVALID_PARAMETERIllegal syntax. Progress set to most recent "&" before the error or the beginning of the string.
EFI_INVALID_PARAMETERUnknown name. Progress points to the & before the name in question.

Definition at line 1184 of file TlsAuthConfigImpl.c.

◆ TlsAuthConfigAccessRouteConfig()

EFI_STATUS EFIAPI TlsAuthConfigAccessRouteConfig ( IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL This,
IN CONST EFI_STRING  Configuration,
OUT EFI_STRING *  Progress 
)

This function applies changes in a driver's configuration. Input is a Configuration, which has the routing data for this driver followed by name / value configuration pairs. The driver must apply those pairs to its configurable storage. If the driver's configuration is stored in a linear block of data and the driver's name / value pairs are in <BlockConfig> format, it may use the ConfigToBlock helper function (above) to simplify the job.

Parameters
ThisPoints to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
ConfigurationA null-terminated Unicode string in <ConfigString> format.
ProgressA pointer to a string filled in with the offset of the most recent '&' before the first failing name / value pair (or the beginning of the string if the failure is in the first name / value pair) or the terminating NULL if all was successful.
Return values
EFI_SUCCESSThe results have been distributed or are awaiting distribution.
EFI_OUT_OF_RESOURCESNot enough memory to store the parts of the results that must be stored awaiting possible future protocols.
EFI_INVALID_PARAMETERSPassing in a NULL for the Results parameter would result in this type of error.
EFI_NOT_FOUNDTarget for the specified routing data was not found

Definition at line 1307 of file TlsAuthConfigImpl.c.

◆ TlsAuthConfigFormInit()

EFI_STATUS TlsAuthConfigFormInit ( IN TLS_AUTH_CONFIG_PRIVATE_DATA Private)

Initialize the configuration form.

Parameters
[in]PrivatePointer to the driver private data.
Return values
EFI_SUCCESSThe configuration form is initialized.
EFI_OUT_OF_RESOURCESFailed to allocate memory.

Definition at line 1018 of file TlsAuthConfigImpl.c.

◆ TlsAuthConfigFormUnload()

EFI_STATUS TlsAuthConfigFormUnload ( IN TLS_AUTH_CONFIG_PRIVATE_DATA Private)

Unload the configuration form, this includes: delete all the configuration entries, uninstall the form callback protocol, and free the resources used.

Parameters
[in]PrivatePointer to the driver private data.
Return values
EFI_SUCCESSThe configuration form is unloaded.
OthersFailed to unload the form.

Definition at line 960 of file TlsAuthConfigImpl.c.

◆ UpdateCAFromFile()

BOOLEAN EFIAPI UpdateCAFromFile ( IN EFI_DEVICE_PATH_PROTOCOL FilePath)

Update the form base on the input file path info.

Parameters
FilePathPoint to the file path.
Return values
TRUEExit caller function.
FALSENot exit caller function.

Definition at line 942 of file TlsAuthConfigImpl.c.

◆ UpdateDeletePage()

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 
)

List all cert in specified database by GUID in the page for user to select and delete as needed.

Parameters
[in]PrivateDataModule's private data.
[in]VariableNameThe variable name of the vendor's signature database.
[in]VendorGuidA unique identifier for the vendor.
[in]LabelNumberLabel number to insert opcodes.
[in]FormIdForm ID of current page.
[in]QuestionIdBaseBase question id of the signature list.
Return values
EFI_SUCCESSSuccess to update the signature list page
EFI_OUT_OF_RESOURCESUnable to allocate required resources.

Definition at line 120 of file TlsAuthConfigImpl.c.

◆ UpdatePage()

BOOLEAN UpdatePage ( IN EFI_DEVICE_PATH_PROTOCOL FilePath,
IN EFI_FORM_ID  FormId 
)

Update the form base on the selected file.

Parameters
FilePathPoint to the file path.
FormIdThe form need to display.
Return values
TRUEExit caller function.
FALSENot exit caller function.

Label FormId

LABEL_END

Definition at line 873 of file TlsAuthConfigImpl.c.

Variable Documentation

◆ mDerPemEncodedSuffix

CHAR16* mDerPemEncodedSuffix[]
Initial value:
= {
L".cer",
L".der",
L".crt",
L".pem",
}
#define NULL
Definition: Base.h:319

Definition at line 46 of file TlsAuthConfigImpl.c.

◆ mEndLabel

EFI_IFR_GUID_LABEL* mEndLabel = NULL

Definition at line 15 of file TlsAuthConfigImpl.c.

◆ mEndOpCodeHandle

VOID* mEndOpCodeHandle = NULL

Definition at line 13 of file TlsAuthConfigImpl.c.

◆ mStartLabel

EFI_IFR_GUID_LABEL* mStartLabel = NULL

Definition at line 14 of file TlsAuthConfigImpl.c.

◆ mStartOpCodeHandle

VOID* mStartOpCodeHandle = NULL

Definition at line 12 of file TlsAuthConfigImpl.c.

◆ mTlsAuthConfigHiiVendorDevicePath

HII_VENDOR_DEVICE_PATH mTlsAuthConfigHiiVendorDevicePath
Initial value:
= {
{
{
{
(UINT8)(sizeof (VENDOR_DEVICE_PATH)),
(UINT8)((sizeof (VENDOR_DEVICE_PATH)) >> 8)
}
},
TLS_AUTH_CONFIG_GUID
},
{
END_DEVICE_PATH_TYPE,
END_ENTIRE_DEVICE_PATH_SUBTYPE,
{
(UINT8)(END_DEVICE_PATH_LENGTH),
(UINT8)((END_DEVICE_PATH_LENGTH) >> 8)
}
}
}
#define HARDWARE_DEVICE_PATH
Definition: DevicePath.h:68
#define HW_VENDOR_DP
Definition: DevicePath.h:133

Definition at line 21 of file TlsAuthConfigImpl.c.

◆ mTlsAuthConfigStorageName

CHAR16 mTlsAuthConfigStorageName[] = L"TLS_AUTH_CONFIG_IFR_NVDATA"

Definition at line 17 of file TlsAuthConfigImpl.c.

◆ mTlsAuthPrivateData

TLS_AUTH_CONFIG_PRIVATE_DATA* mTlsAuthPrivateData = NULL

Definition at line 19 of file TlsAuthConfigImpl.c.