TianoCore EDK2 master
Loading...
Searching...
No Matches
TlsImpl.h File Reference

Go to the source code of this file.

Functions

EFI_STATUS TlsEncryptPacket (IN TLS_INSTANCE *TlsInstance, IN OUT EFI_TLS_FRAGMENT_DATA **FragmentTable, IN UINT32 *FragmentCount)
 
EFI_STATUS TlsDecryptPacket (IN TLS_INSTANCE *TlsInstance, IN OUT EFI_TLS_FRAGMENT_DATA **FragmentTable, IN UINT32 *FragmentCount)
 
EFI_STATUS EFIAPI TlsSetSessionData (IN EFI_TLS_PROTOCOL *This, IN EFI_TLS_SESSION_DATA_TYPE DataType, IN VOID *Data, IN UINTN DataSize)
 
EFI_STATUS EFIAPI TlsGetSessionData (IN EFI_TLS_PROTOCOL *This, IN EFI_TLS_SESSION_DATA_TYPE DataType, IN OUT VOID *Data OPTIONAL, IN OUT UINTN *DataSize)
 
EFI_STATUS EFIAPI TlsBuildResponsePacket (IN EFI_TLS_PROTOCOL *This, IN UINT8 *RequestBuffer OPTIONAL, IN UINTN RequestSize OPTIONAL, OUT UINT8 *Buffer OPTIONAL, IN OUT UINTN *BufferSize)
 
EFI_STATUS EFIAPI TlsProcessPacket (IN EFI_TLS_PROTOCOL *This, IN OUT EFI_TLS_FRAGMENT_DATA **FragmentTable, IN UINT32 *FragmentCount, IN EFI_TLS_CRYPT_MODE CryptMode)
 
EFI_STATUS EFIAPI TlsConfigurationSetData (IN EFI_TLS_CONFIGURATION_PROTOCOL *This, IN EFI_TLS_CONFIG_DATA_TYPE DataType, IN VOID *Data, IN UINTN DataSize)
 
EFI_STATUS EFIAPI TlsConfigurationGetData (IN EFI_TLS_CONFIGURATION_PROTOCOL *This, IN EFI_TLS_CONFIG_DATA_TYPE DataType, IN OUT VOID *Data OPTIONAL, IN OUT UINTN *DataSize)
 

Variables

EFI_SERVICE_BINDING_PROTOCOL mTlsServiceBinding
 
EFI_TLS_PROTOCOL mTlsProtocol
 
EFI_TLS_CONFIGURATION_PROTOCOL mTlsConfigurationProtocol
 

Detailed Description

Header file of Miscellaneous Routines for TlsDxe driver.

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

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

Definition in file TlsImpl.h.

Function Documentation

◆ TlsBuildResponsePacket()

EFI_STATUS EFIAPI TlsBuildResponsePacket ( IN EFI_TLS_PROTOCOL This,
IN UINT8 *RequestBuffer  OPTIONAL,
IN UINTN RequestSize  OPTIONAL,
OUT UINT8 *Buffer  OPTIONAL,
IN OUT UINTN BufferSize 
)

Build response packet according to TLS state machine. This function is only valid for alert, handshake and change_cipher_spec content type.

The BuildResponsePacket() function builds TLS response packet in response to the TLS request packet specified by RequestBuffer and RequestSize. If RequestBuffer is NULL and RequestSize is 0, and TLS session status is EfiTlsSessionNotStarted, the TLS session will be initiated and the response packet needs to be ClientHello. If RequestBuffer is NULL and RequestSize is 0, and TLS session status is EfiTlsSessionClosing, the TLS session will be closed and response packet needs to be CloseNotify. If RequestBuffer is NULL and RequestSize is 0, and TLS session status is EfiTlsSessionError, the TLS session has errors and the response packet needs to be Alert message based on error type.

Parameters
[in]ThisPointer to the EFI_TLS_PROTOCOL instance.
[in]RequestBufferPointer to the most recently received TLS packet. NULL means TLS need initiate the TLS session and response packet need to be ClientHello.
[in]RequestSizePacket size in bytes for the most recently received TLS packet. 0 is only valid when RequestBuffer is NULL.
[out]BufferPointer to the buffer to hold the built packet.
[in,out]BufferSizePointer to the buffer size in bytes. On input, it is the buffer size provided by the caller. On output, it is the buffer size in fact needed to contain the packet.
Return values
EFI_SUCCESSThe required TLS packet is built successfully.
EFI_INVALID_PARAMETEROne or more of the following conditions is TRUE: This is NULL. RequestBuffer is NULL but RequestSize is NOT 0. RequestSize is 0 but RequestBuffer is NOT NULL. BufferSize is NULL. Buffer is NULL if *BufferSize is not zero.
EFI_BUFFER_TOO_SMALLBufferSize is too small to hold the response packet.
EFI_NOT_READYCurrent TLS session state is NOT ready to build ResponsePacket.
EFI_ABORTEDSomething wrong build response packet.

Definition at line 458 of file TlsProtocol.c.

◆ TlsConfigurationGetData()

EFI_STATUS EFIAPI TlsConfigurationGetData ( IN EFI_TLS_CONFIGURATION_PROTOCOL This,
IN EFI_TLS_CONFIG_DATA_TYPE  DataType,
IN OUT VOID *Data  OPTIONAL,
IN OUT UINTN DataSize 
)

Get TLS configuration data.

The GetData() function gets TLS configuration.

Parameters
[in]ThisPointer to the EFI_TLS_CONFIGURATION_PROTOCOL instance.
[in]DataTypeConfiguration data type.
[in,out]DataPointer to configuration data.
[in,out]DataSizeTotal size of configuration data. On input, it means the size of Data buffer. On output, it means the size of copied Data buffer if EFI_SUCCESS, and means the size of desired Data buffer if EFI_BUFFER_TOO_SMALL.
Return values
EFI_SUCCESSThe TLS configuration data is got successfully.
EFI_INVALID_PARAMETEROne or more of the following conditions is TRUE: This is NULL. DataSize is NULL. Data is NULL if *DataSize is not zero.
EFI_UNSUPPORTEDThe DataType is unsupported.
EFI_NOT_FOUNDThe TLS configuration data is not found.
EFI_BUFFER_TOO_SMALLThe buffer is too small to hold the data.

Definition at line 105 of file TlsConfigProtocol.c.

◆ TlsConfigurationSetData()

EFI_STATUS EFIAPI TlsConfigurationSetData ( IN EFI_TLS_CONFIGURATION_PROTOCOL This,
IN EFI_TLS_CONFIG_DATA_TYPE  DataType,
IN VOID *  Data,
IN UINTN  DataSize 
)

Set TLS configuration data.

The SetData() function sets TLS configuration to non-volatile storage or volatile storage.

Parameters
[in]ThisPointer to the EFI_TLS_CONFIGURATION_PROTOCOL instance.
[in]DataTypeConfiguration data type.
[in]DataPointer to configuration data.
[in]DataSizeTotal size of configuration data.
Return values
EFI_SUCCESSThe TLS configuration data is set successfully.
EFI_INVALID_PARAMETEROne or more of the following conditions is TRUE: This is NULL. Data is NULL. DataSize is 0.
EFI_UNSUPPORTEDThe DataType is unsupported.
EFI_OUT_OF_RESOURCESRequired system resources could not be allocated.

Definition at line 39 of file TlsConfigProtocol.c.

◆ TlsDecryptPacket()

EFI_STATUS TlsDecryptPacket ( IN TLS_INSTANCE TlsInstance,
IN OUT EFI_TLS_FRAGMENT_DATA **  FragmentTable,
IN UINT32 *  FragmentCount 
)

Decrypt the message listed in fragment.

Parameters
[in]TlsInstanceThe pointer to the TLS instance.
[in,out]FragmentTablePointer to a list of fragment. On input these fragments contain the TLS header and cipher text TLS payload; On output these fragments contain the TLS header and plain text TLS payload.
[in]FragmentCountNumber of fragment.
Return values
EFI_SUCCESSThe operation completed successfully.
EFI_OUT_OF_RESOURCESCan't allocate memory resources.
EFI_ABORTEDTLS session state is incorrect.
OthersOther errors as indicated.

Definition at line 195 of file TlsImpl.c.

◆ TlsEncryptPacket()

EFI_STATUS TlsEncryptPacket ( IN TLS_INSTANCE TlsInstance,
IN OUT EFI_TLS_FRAGMENT_DATA **  FragmentTable,
IN UINT32 *  FragmentCount 
)

Encrypt the message listed in fragment.

Parameters
[in]TlsInstanceThe pointer to the TLS instance.
[in,out]FragmentTablePointer to a list of fragment. On input these fragments contain the TLS header and plain text TLS payload; On output these fragments contain the TLS header and cipher text TLS payload.
[in]FragmentCountNumber of fragment.
Return values
EFI_SUCCESSThe operation completed successfully.
EFI_OUT_OF_RESOURCESCan't allocate memory resources.
EFI_ABORTEDTLS session state is incorrect.
OthersOther errors as indicated.

Definition at line 29 of file TlsImpl.c.

◆ TlsGetSessionData()

EFI_STATUS EFIAPI TlsGetSessionData ( IN EFI_TLS_PROTOCOL This,
IN EFI_TLS_SESSION_DATA_TYPE  DataType,
IN OUT VOID *Data  OPTIONAL,
IN OUT UINTN DataSize 
)

Get TLS session data.

The GetSessionData() function return the TLS session information.

Parameters
[in]ThisPointer to the EFI_TLS_PROTOCOL instance.
[in]DataTypeTLS session data type.
[in,out]DataPointer to session data.
[in,out]DataSizeTotal size of session data. On input, it means the size of Data buffer. On output, it means the size of copied Data buffer if EFI_SUCCESS, and means the size of desired Data buffer if EFI_BUFFER_TOO_SMALL.
Return values
EFI_SUCCESSThe TLS session data is got successfully.
EFI_INVALID_PARAMETEROne or more of the following conditions is TRUE: This is NULL. DataSize is NULL. Data is NULL if *DataSize is not zero.
EFI_UNSUPPORTEDThe DataType is unsupported.
EFI_NOT_FOUNDThe TLS session data is not found.
EFI_NOT_READYThe DataType is not ready in current session state.
EFI_BUFFER_TOO_SMALLThe buffer is too small to hold the data.

Definition at line 261 of file TlsProtocol.c.

◆ TlsProcessPacket()

EFI_STATUS EFIAPI TlsProcessPacket ( IN EFI_TLS_PROTOCOL This,
IN OUT EFI_TLS_FRAGMENT_DATA **  FragmentTable,
IN UINT32 *  FragmentCount,
IN EFI_TLS_CRYPT_MODE  CryptMode 
)

Decrypt or encrypt TLS packet during session. This function is only valid after session connected and for application_data content type.

The ProcessPacket () function process each inbound or outbound TLS APP packet.

Parameters
[in]ThisPointer to the EFI_TLS_PROTOCOL instance.
[in,out]FragmentTablePointer to a list of fragment. The caller will take responsible to handle the original FragmentTable while it may be reallocated in TLS driver. If CryptMode is EfiTlsEncrypt, on input these fragments contain the TLS header and plain text TLS APP payload; on output these fragments contain the TLS header and cipher text TLS APP payload. If CryptMode is EfiTlsDecrypt, on input these fragments contain the TLS header and cipher text TLS APP payload; on output these fragments contain the TLS header and plain text TLS APP payload.
[in]FragmentCountNumber of fragment.
[in]CryptModeCrypt mode.
Return values
EFI_SUCCESSThe operation completed successfully.
EFI_INVALID_PARAMETEROne or more of the following conditions is TRUE: This is NULL. FragmentTable is NULL. FragmentCount is NULL. CryptoMode is invalid.
EFI_NOT_READYCurrent TLS session state is NOT EfiTlsSessionDataTransferring.
EFI_ABORTEDSomething wrong decryption the message. TLS session status will become EfiTlsSessionError. The caller need call BuildResponsePacket() to generate Error Alert message and send it out.
EFI_OUT_OF_RESOURCESNo enough resource to finish the operation.

Definition at line 643 of file TlsProtocol.c.

◆ TlsSetSessionData()

EFI_STATUS EFIAPI TlsSetSessionData ( IN EFI_TLS_PROTOCOL This,
IN EFI_TLS_SESSION_DATA_TYPE  DataType,
IN VOID *  Data,
IN UINTN  DataSize 
)

Set TLS session data.

The SetSessionData() function set data for a new TLS session. All session data should be set before BuildResponsePacket() invoked.

Parameters
[in]ThisPointer to the EFI_TLS_PROTOCOL instance.
[in]DataTypeTLS session data type.
[in]DataPointer to session data.
[in]DataSizeTotal size of session data.
Return values
EFI_SUCCESSThe TLS session data is set successfully.
EFI_INVALID_PARAMETEROne or more of the following conditions is TRUE: This is NULL. Data is NULL. DataSize is 0.
EFI_UNSUPPORTEDThe DataType is unsupported.
EFI_ACCESS_DENIEDIf the DataType is one of below: EfiTlsClientRandom EfiTlsServerRandom EfiTlsKeyMaterial
EFI_NOT_READYCurrent TLS session state is NOT EfiTlsSessionStateNotStarted.
EFI_OUT_OF_RESOURCESRequired system resources could not be allocated.

Set TLS session data.

The SetSessionData() function set data for a new TLS session. All session data should be set before BuildResponsePacket() invoked.

Parameters
[in]ThisPointer to the EFI_TLS_PROTOCOL instance.
[in]DataTypeTLS session data type.
[in]DataPointer to session data.
[in]DataSizeTotal size of session data.
Return values
EFI_SUCCESSThe TLS session data is set successfully.
EFI_INVALID_PARAMETEROne or more of the following conditions is TRUE: This is NULL. Data is NULL. DataSize is 0. DataSize is invalid for DataType.
EFI_UNSUPPORTEDThe DataType is unsupported.
EFI_ACCESS_DENIEDIf the DataType is one of below: EfiTlsClientRandom EfiTlsServerRandom EfiTlsKeyMaterial
EFI_NOT_READYCurrent TLS session state is NOT EfiTlsSessionStateNotStarted.
EFI_OUT_OF_RESOURCESRequired system resources could not be allocated.

Definition at line 47 of file TlsProtocol.c.

Variable Documentation

◆ mTlsConfigurationProtocol

EFI_TLS_CONFIGURATION_PROTOCOL mTlsConfigurationProtocol
extern

Definition at line 12 of file TlsConfigProtocol.c.

◆ mTlsProtocol

EFI_TLS_PROTOCOL mTlsProtocol
extern

Definition at line 12 of file TlsProtocol.c.

◆ mTlsServiceBinding

EFI_SERVICE_BINDING_PROTOCOL mTlsServiceBinding
extern

Definition at line 12 of file TlsDriver.c.