mirror of
https://github.com/acidanthera/audk.git
synced 2025-04-08 17:05:09 +02:00
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3892 1. TlsSetSignatureAlgoList(): Configure the list of TLS signature algorithms that should be used as part of the TLS session establishment. This is needed for some WLAN Supplicant connection establishment flows that allow only specific TLS signature algorithms to be used, e.g., Authenticate and Key Managmenet (AKM) suites that are SUITE-B compliant. 2. TlsSetEcCurve(): Configure the Elliptic Curve that should be used for TLS flows the use cipher suite with EC, e.g., TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384. This is needed for some WLAN Supplicant connection establishment flows that allow only specific TLS signature algorithms to be used, e.g., Authenticate and Key Managmenet (AKM) suites that are SUITE-B compliant. 3. TlsShutdown(): Shutdown the TLS connection without releasing the resources, meaning a new connection can be started without calling TlsNew() and without setting certificates etc. 4. TlsGetExportKey(): Derive keying material from a TLS connection using the mechanism described in RFC 5705 and export the key material (needed by EAP methods such as EAP-TTLS and EAP-PEAP). 5. TlsSetHostPrivateKeyEx(): This function adds the local private key (PEM-encoded or PKCS#8 or DER-encoded private key) into the specified TLS object for TLS negotiation. There is already a similar function TlsSetHostPrivateKey(), the new Ex function introduces a new parameter Password, set Password to NULL when useless. Cc: Jiewen Yao <jiewen.yao@intel.com> Cc: Jian J Wang <jian.j.wang@intel.com> Cc: Xiaoyu Lu <xiaoyu1.lu@intel.com> Cc: Guomin Jiang <guomin.jiang@intel.com> Signed-off-by: Yi Li <yi1.li@intel.com> Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
271 lines
8.7 KiB
C
271 lines
8.7 KiB
C
/** @file
|
|
SSL/TLS Process Null Library Wrapper Implementation.
|
|
The process includes the TLS handshake and packet I/O.
|
|
|
|
Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.<BR>
|
|
(C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>
|
|
SPDX-License-Identifier: BSD-2-Clause-Patent
|
|
|
|
**/
|
|
|
|
#include "InternalTlsLib.h"
|
|
|
|
/**
|
|
Checks if the TLS handshake was done.
|
|
|
|
This function will check if the specified TLS handshake was done.
|
|
|
|
@param[in] Tls Pointer to the TLS object for handshake state checking.
|
|
|
|
@retval TRUE The TLS handshake was done.
|
|
@retval FALSE The TLS handshake was not done.
|
|
|
|
**/
|
|
BOOLEAN
|
|
EFIAPI
|
|
TlsInHandshake (
|
|
IN VOID *Tls
|
|
)
|
|
{
|
|
ASSERT (FALSE);
|
|
return FALSE;
|
|
}
|
|
|
|
/**
|
|
Perform a TLS/SSL handshake.
|
|
|
|
This function will perform a TLS/SSL handshake.
|
|
|
|
@param[in] Tls Pointer to the TLS object for handshake operation.
|
|
@param[in] BufferIn Pointer to the most recently received TLS Handshake packet.
|
|
@param[in] BufferInSize Packet size in bytes for the most recently received TLS
|
|
Handshake packet.
|
|
@param[out] BufferOut Pointer to the buffer to hold the built packet.
|
|
@param[in, out] BufferOutSize Pointer 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.
|
|
|
|
@retval EFI_SUCCESS The required TLS packet is built successfully.
|
|
@retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
|
|
Tls is NULL.
|
|
BufferIn is NULL but BufferInSize is NOT 0.
|
|
BufferInSize is 0 but BufferIn is NOT NULL.
|
|
BufferOutSize is NULL.
|
|
BufferOut is NULL if *BufferOutSize is not zero.
|
|
@retval EFI_BUFFER_TOO_SMALL BufferOutSize is too small to hold the response packet.
|
|
@retval EFI_ABORTED Something wrong during handshake.
|
|
|
|
**/
|
|
EFI_STATUS
|
|
EFIAPI
|
|
TlsDoHandshake (
|
|
IN VOID *Tls,
|
|
IN UINT8 *BufferIn OPTIONAL,
|
|
IN UINTN BufferInSize OPTIONAL,
|
|
OUT UINT8 *BufferOut OPTIONAL,
|
|
IN OUT UINTN *BufferOutSize
|
|
)
|
|
{
|
|
ASSERT (FALSE);
|
|
return EFI_UNSUPPORTED;
|
|
}
|
|
|
|
/**
|
|
Handle Alert message recorded in BufferIn. If BufferIn is NULL and BufferInSize is zero,
|
|
TLS session has errors and the response packet needs to be Alert message based on error type.
|
|
|
|
@param[in] Tls Pointer to the TLS object for state checking.
|
|
@param[in] BufferIn Pointer to the most recently received TLS Alert packet.
|
|
@param[in] BufferInSize Packet size in bytes for the most recently received TLS
|
|
Alert packet.
|
|
@param[out] BufferOut Pointer to the buffer to hold the built packet.
|
|
@param[in, out] BufferOutSize Pointer 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.
|
|
|
|
@retval EFI_SUCCESS The required TLS packet is built successfully.
|
|
@retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
|
|
Tls is NULL.
|
|
BufferIn is NULL but BufferInSize is NOT 0.
|
|
BufferInSize is 0 but BufferIn is NOT NULL.
|
|
BufferOutSize is NULL.
|
|
BufferOut is NULL if *BufferOutSize is not zero.
|
|
@retval EFI_ABORTED An error occurred.
|
|
@retval EFI_BUFFER_TOO_SMALL BufferOutSize is too small to hold the response packet.
|
|
|
|
**/
|
|
EFI_STATUS
|
|
EFIAPI
|
|
TlsHandleAlert (
|
|
IN VOID *Tls,
|
|
IN UINT8 *BufferIn OPTIONAL,
|
|
IN UINTN BufferInSize OPTIONAL,
|
|
OUT UINT8 *BufferOut OPTIONAL,
|
|
IN OUT UINTN *BufferOutSize
|
|
)
|
|
{
|
|
ASSERT (FALSE);
|
|
return EFI_UNSUPPORTED;
|
|
}
|
|
|
|
/**
|
|
Build the CloseNotify packet.
|
|
|
|
@param[in] Tls Pointer to the TLS object for state checking.
|
|
@param[in, out] Buffer Pointer to the buffer to hold the built packet.
|
|
@param[in, out] BufferSize Pointer 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.
|
|
|
|
@retval EFI_SUCCESS The required TLS packet is built successfully.
|
|
@retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
|
|
Tls is NULL.
|
|
BufferSize is NULL.
|
|
Buffer is NULL if *BufferSize is not zero.
|
|
@retval EFI_BUFFER_TOO_SMALL BufferSize is too small to hold the response packet.
|
|
|
|
**/
|
|
EFI_STATUS
|
|
EFIAPI
|
|
TlsCloseNotify (
|
|
IN VOID *Tls,
|
|
IN OUT UINT8 *Buffer,
|
|
IN OUT UINTN *BufferSize
|
|
)
|
|
{
|
|
ASSERT (FALSE);
|
|
return EFI_UNSUPPORTED;
|
|
}
|
|
|
|
/**
|
|
Attempts to read bytes from one TLS object and places the data in Buffer.
|
|
|
|
This function will attempt to read BufferSize bytes from the TLS object
|
|
and places the data in Buffer.
|
|
|
|
@param[in] Tls Pointer to the TLS object.
|
|
@param[in,out] Buffer Pointer to the buffer to store the data.
|
|
@param[in] BufferSize The size of Buffer in bytes.
|
|
|
|
@retval >0 The amount of data successfully read from the TLS object.
|
|
@retval <=0 No data was successfully read.
|
|
|
|
**/
|
|
INTN
|
|
EFIAPI
|
|
TlsCtrlTrafficOut (
|
|
IN VOID *Tls,
|
|
IN OUT VOID *Buffer,
|
|
IN UINTN BufferSize
|
|
)
|
|
{
|
|
ASSERT (FALSE);
|
|
return 0;
|
|
}
|
|
|
|
/**
|
|
Attempts to write data from the buffer to TLS object.
|
|
|
|
This function will attempt to write BufferSize bytes data from the Buffer
|
|
to the TLS object.
|
|
|
|
@param[in] Tls Pointer to the TLS object.
|
|
@param[in] Buffer Pointer to the data buffer.
|
|
@param[in] BufferSize The size of Buffer in bytes.
|
|
|
|
@retval >0 The amount of data successfully written to the TLS object.
|
|
@retval <=0 No data was successfully written.
|
|
|
|
**/
|
|
INTN
|
|
EFIAPI
|
|
TlsCtrlTrafficIn (
|
|
IN VOID *Tls,
|
|
IN VOID *Buffer,
|
|
IN UINTN BufferSize
|
|
)
|
|
{
|
|
ASSERT (FALSE);
|
|
return 0;
|
|
}
|
|
|
|
/**
|
|
Attempts to read bytes from the specified TLS connection into the buffer.
|
|
|
|
This function tries to read BufferSize bytes data from the specified TLS
|
|
connection into the Buffer.
|
|
|
|
@param[in] Tls Pointer to the TLS connection for data reading.
|
|
@param[in,out] Buffer Pointer to the data buffer.
|
|
@param[in] BufferSize The size of Buffer in bytes.
|
|
|
|
@retval >0 The read operation was successful, and return value is the
|
|
number of bytes actually read from the TLS connection.
|
|
@retval <=0 The read operation was not successful.
|
|
|
|
**/
|
|
INTN
|
|
EFIAPI
|
|
TlsRead (
|
|
IN VOID *Tls,
|
|
IN OUT VOID *Buffer,
|
|
IN UINTN BufferSize
|
|
)
|
|
{
|
|
ASSERT (FALSE);
|
|
return 0;
|
|
}
|
|
|
|
/**
|
|
Attempts to write data to a TLS connection.
|
|
|
|
This function tries to write BufferSize bytes data from the Buffer into the
|
|
specified TLS connection.
|
|
|
|
@param[in] Tls Pointer to the TLS connection for data writing.
|
|
@param[in] Buffer Pointer to the data buffer.
|
|
@param[in] BufferSize The size of Buffer in bytes.
|
|
|
|
@retval >0 The write operation was successful, and return value is the
|
|
number of bytes actually written to the TLS connection.
|
|
@retval <=0 The write operation was not successful.
|
|
|
|
**/
|
|
INTN
|
|
EFIAPI
|
|
TlsWrite (
|
|
IN VOID *Tls,
|
|
IN VOID *Buffer,
|
|
IN UINTN BufferSize
|
|
)
|
|
{
|
|
ASSERT (FALSE);
|
|
return 0;
|
|
}
|
|
|
|
/**
|
|
Shutdown a TLS connection.
|
|
|
|
Shutdown the TLS connection without releasing the resources, meaning a new
|
|
connection can be started without calling TlsNew() and without setting
|
|
certificates etc.
|
|
|
|
@param[in] Tls Pointer to the TLS object to shutdown.
|
|
|
|
@retval EFI_SUCCESS The TLS is shutdown successfully.
|
|
@retval EFI_INVALID_PARAMETER Tls is NULL.
|
|
@retval EFI_PROTOCOL_ERROR Some other error occurred.
|
|
**/
|
|
EFI_STATUS
|
|
EFIAPI
|
|
TlsShutdown (
|
|
IN VOID *Tls
|
|
)
|
|
{
|
|
ASSERT (FALSE);
|
|
return EFI_UNSUPPORTED;
|
|
}
|