XenevaOS
Loading...
Searching...
No Matches
Classes | Macros | Typedefs | Enumerations | Variables
Tls.h File Reference

Go to the source code of this file.

Classes

struct  EFI_TLS_VERSION
 
struct  EFI_TLS_CIPHER
 
struct  EFI_TLS_EXTENSION
 
struct  EFI_TLS_RANDOM
 
struct  EFI_TLS_MASTER_SECRET
 
struct  EFI_TLS_SESSION_ID
 
struct  EFI_TLS_FRAGMENT_DATA
 
struct  _EFI_TLS_PROTOCOL
 

Macros

#define EFI_TLS_SERVICE_BINDING_PROTOCOL_GUID
 
#define EFI_TLS_PROTOCOL_GUID
 
#define EFI_TLS_VERIFY_NONE   0x0
 
#define EFI_TLS_VERIFY_PEER   0x1
 
#define EFI_TLS_VERIFY_FAIL_IF_NO_PEER_CERT   0x2
 
#define EFI_TLS_VERIFY_CLIENT_ONCE   0x4
 
#define MAX_TLS_SESSION_ID_LENGTH   32
 

Typedefs

typedef struct _EFI_TLS_PROTOCOL EFI_TLS_PROTOCOL
 
typedef UINT8 EFI_TLS_COMPRESSION
 
typedef UINT32 EFI_TLS_VERIFY
 
typedef EFI_STATUS(EFIAPIEFI_TLS_SET_SESSION_DATA) (IN EFI_TLS_PROTOCOL *This, IN EFI_TLS_SESSION_DATA_TYPE DataType, IN VOID *Data, IN UINTN DataSize)
 
typedef EFI_STATUS(EFIAPIEFI_TLS_GET_SESSION_DATA) (IN EFI_TLS_PROTOCOL *This, IN EFI_TLS_SESSION_DATA_TYPE DataType, IN OUT VOID *Data, OPTIONAL IN OUT UINTN *DataSize)
 
typedef EFI_STATUS(EFIAPIEFI_TLS_BUILD_RESPONSE_PACKET) (IN EFI_TLS_PROTOCOL *This, IN UINT8 *RequestBuffer, OPTIONAL IN UINTN RequestSize, OPTIONAL OUT UINT8 *Buffer, OPTIONAL IN OUT UINTN *BufferSize)
 
typedef EFI_STATUS(EFIAPIEFI_TLS_PROCESS_PACKET) (IN EFI_TLS_PROTOCOL *This, IN OUT EFI_TLS_FRAGMENT_DATA **FragmentTable, IN UINT32 *FragmentCount, IN EFI_TLS_CRYPT_MODE CryptMode)
 

Enumerations

enum  EFI_TLS_SESSION_DATA_TYPE {
  EfiTlsVersion , EfiTlsConnectionEnd , EfiTlsCipherList , EfiTlsCompressionMethod ,
  EfiTlsExtensionData , EfiTlsVerifyMethod , EfiTlsSessionID , EfiTlsSessionState ,
  EfiTlsClientRandom , EfiTlsServerRandom , EfiTlsKeyMaterial , EfiTlsSessionDataTypeMaximum
}
 
enum  EFI_TLS_CONNECTION_END { EfiTlsClient , EfiTlsServer }
 
enum  EFI_TLS_SESSION_STATE {
  EfiTlsSessionNotStarted , EfiTlsSessionHandShaking , EfiTlsSessionDataTransferring , EfiTlsSessionClosing ,
  EfiTlsSessionError , EfiTlsSessionStateMaximum
}
 
enum  EFI_TLS_CRYPT_MODE { EfiTlsEncrypt , EfiTlsDecrypt }
 

Variables

EFI_GUID gEfiTlsServiceBindingProtocolGuid
 
EFI_GUID gEfiTlsProtocolGuid
 

Detailed Description

EFI TLS Protocols as defined in UEFI 2.5.

The EFI TLS Service Binding Protocol is used to locate EFI TLS Protocol drivers to create and destroy child of the driver to communicate with other host using TLS protocol. The EFI TLS Protocol provides the ability to manage TLS session.

Copyright (c) 2016, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php

THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.

Revision Reference:
This Protocol is introduced in UEFI Specification 2.5

Macro Definition Documentation

◆ EFI_TLS_PROTOCOL_GUID

#define EFI_TLS_PROTOCOL_GUID
Value:
{ \
0xca959f, 0x6cfa, 0x4db1, {0x95, 0xbc, 0xe4, 0x6c, 0x47, 0x51, 0x43, 0x90 } \
}

The EFI TLS protocol provides the ability to manage TLS session.

◆ EFI_TLS_SERVICE_BINDING_PROTOCOL_GUID

#define EFI_TLS_SERVICE_BINDING_PROTOCOL_GUID
Value:
{ \
0x952cb795, 0xff36, 0x48cf, {0xa2, 0x49, 0x4d, 0xf4, 0x86, 0xd6, 0xab, 0x8d } \
}

The EFI TLS Service Binding Protocol is used to locate EFI TLS Protocol drivers to create and destroy child of the driver to communicate with other host using TLS protocol.

◆ EFI_TLS_VERIFY_CLIENT_ONCE

#define EFI_TLS_VERIFY_CLIENT_ONCE   0x4

TLS session only verify client once, and doesn't request certificate during re-negotiation.

◆ EFI_TLS_VERIFY_FAIL_IF_NO_PEER_CERT

#define EFI_TLS_VERIFY_FAIL_IF_NO_PEER_CERT   0x2

TLS session will fail peer certificate is absent.

◆ EFI_TLS_VERIFY_NONE

#define EFI_TLS_VERIFY_NONE   0x0

No certificates will be sent or the TLS/SSL handshake will be continued regardless of the certificate verification result.

◆ EFI_TLS_VERIFY_PEER

#define EFI_TLS_VERIFY_PEER   0x1

The TLS/SSL handshake is immediately terminated with an alert message containing the reason for the certificate verification failure.

◆ MAX_TLS_SESSION_ID_LENGTH

#define MAX_TLS_SESSION_ID_LENGTH   32

EFI_TLS_SESSION_ID Note: The definition of EFI_TLS_SESSION_ID is from "RFC 5246 A.4.1. Hello Messages".

Typedef Documentation

◆ EFI_TLS_BUILD_RESPONSE_PACKET

typedef EFI_STATUS(EFIAPI * EFI_TLS_BUILD_RESPONSE_PACKET) (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.

◆ EFI_TLS_COMPRESSION

EFI_TLS_COMPRESSION Note: The value of EFI_TLS_COMPRESSION definition is from "RFC 3749".

◆ EFI_TLS_GET_SESSION_DATA

typedef EFI_STATUS(EFIAPI * EFI_TLS_GET_SESSION_DATA) (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.

◆ EFI_TLS_PROCESS_PACKET

typedef EFI_STATUS(EFIAPI * EFI_TLS_PROCESS_PACKET) (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.

◆ EFI_TLS_PROTOCOL

◆ EFI_TLS_SET_SESSION_DATA

typedef EFI_STATUS(EFIAPI * EFI_TLS_SET_SESSION_DATA) (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.

◆ EFI_TLS_VERIFY

EFI_TLS_VERIFY Use either EFI_TLS_VERIFY_NONE or EFI_TLS_VERIFY_PEER, the last two options are 'ORed' with EFI_TLS_VERIFY_PEER if they are desired.

Enumeration Type Documentation

◆ EFI_TLS_CONNECTION_END

EFI_TLS_CONNECTION_END to define TLS session as client or server.

Enumerator
EfiTlsClient 
EfiTlsServer 

◆ EFI_TLS_CRYPT_MODE

EFI_TLS_CRYPT_MODE

Enumerator
EfiTlsEncrypt 

Encrypt data provided in the fragment buffers.

EfiTlsDecrypt 

Decrypt data provided in the fragment buffers.

◆ EFI_TLS_SESSION_DATA_TYPE

EFI_TLS_SESSION_DATA_TYPE

Enumerator
EfiTlsVersion 

Session Configuration TLS session Version. The corresponding Data is of type EFI_TLS_VERSION.

EfiTlsConnectionEnd 

TLS session as client or as server. The corresponding Data is of EFI_TLS_CONNECTION_END.

EfiTlsCipherList 

A priority list of preferred algorithms for the TLS session. The corresponding Data is a list of EFI_TLS_CIPHER.

EfiTlsCompressionMethod 

TLS session compression method. The corresponding Data is of type EFI_TLS_COMPRESSION.

EfiTlsExtensionData 

TLS session extension data. The corresponding Data is a list of type EFI_TLS_EXTENSION .

EfiTlsVerifyMethod 

TLS session verify method. The corresponding Data is of type EFI_TLS_VERIFY.

EfiTlsSessionID 

TLS session data session ID. For SetSessionData(), it is TLS session ID used for session resumption. For GetSessionData(), it is the TLS session ID used for current session. The corresponding Data is of type EFI_TLS_SESSION_ID.

EfiTlsSessionState 

TLS session data session state. The corresponding Data is of type EFI_TLS_SESSION_STATE.

EfiTlsClientRandom 

Session information TLS session data client random. The corresponding Data is of type EFI_TLS_RANDOM.

EfiTlsServerRandom 

TLS session data server random. The corresponding Data is of type EFI_TLS_RANDOM.

EfiTlsKeyMaterial 

TLS session data key material. The corresponding Data is of type EFI_TLS_MASTER_SECRET.

EfiTlsSessionDataTypeMaximum 

◆ EFI_TLS_SESSION_STATE

EFI_TLS_SESSION_STATE

Enumerator
EfiTlsSessionNotStarted 

When a new child of TLS protocol is created, the initial state of TLS session is EfiTlsSessionNotStarted.

EfiTlsSessionHandShaking 

The consumer can call BuildResponsePacket() with NULL to get ClientHello to start the TLS session. Then the status is EfiTlsSessionHandShaking.

EfiTlsSessionDataTransferring 

During handshake, the consumer need call BuildResponsePacket() with input data from peer, then get response packet and send to peer. After handshake finish, the TLS session status becomes EfiTlsSessionDataTransferring, and consumer can use ProcessPacket() for data transferring.

EfiTlsSessionClosing 

Finally, if consumer wants to active close TLS session, consumer need call SetSessionData to set TLS session state to EfiTlsSessionClosing, and call BuildResponsePacket() with NULL to get CloseNotify alert message, and sent it out.

EfiTlsSessionError 

If any error happen during parsing ApplicationData content type, EFI_ABORT will be returned by ProcessPacket(), and TLS session state will become EfiTlsSessionError. Then consumer need call BuildResponsePacket() with NULL to get alert message and sent it out.

EfiTlsSessionStateMaximum 

Variable Documentation

◆ gEfiTlsProtocolGuid

EFI_GUID gEfiTlsProtocolGuid
extern

◆ gEfiTlsServiceBindingProtocolGuid

EFI_GUID gEfiTlsServiceBindingProtocolGuid
extern