2 SSL/TLS Process Null Library Wrapper Implementation.
3 The process includes the TLS handshake and packet I/O.
5 Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.<BR>
6 (C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>
7 SPDX-License-Identifier: BSD-2-Clause-Patent
11 #include "InternalTlsLib.h"
14 Checks if the TLS handshake was done.
16 This function will check if the specified TLS handshake was done.
18 @param[in] Tls Pointer to the TLS object for handshake state checking.
20 @retval TRUE The TLS handshake was done.
21 @retval FALSE The TLS handshake was not done.
35 Perform a TLS/SSL handshake.
37 This function will perform a TLS/SSL handshake.
39 @param[in] Tls Pointer to the TLS object for handshake operation.
40 @param[in] BufferIn Pointer to the most recently received TLS Handshake packet.
41 @param[in] BufferInSize Packet size in bytes for the most recently received TLS
43 @param[out] BufferOut Pointer to the buffer to hold the built packet.
44 @param[in, out] BufferOutSize Pointer to the buffer size in bytes. On input, it is
45 the buffer size provided by the caller. On output, it
46 is the buffer size in fact needed to contain the
49 @retval EFI_SUCCESS The required TLS packet is built successfully.
50 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
52 BufferIn is NULL but BufferInSize is NOT 0.
53 BufferInSize is 0 but BufferIn is NOT NULL.
54 BufferOutSize is NULL.
55 BufferOut is NULL if *BufferOutSize is not zero.
56 @retval EFI_BUFFER_TOO_SMALL BufferOutSize is too small to hold the response packet.
57 @retval EFI_ABORTED Something wrong during handshake.
64 IN UINT8
*BufferIn OPTIONAL
,
65 IN UINTN BufferInSize OPTIONAL
,
66 OUT UINT8
*BufferOut OPTIONAL
,
67 IN OUT UINTN
*BufferOutSize
71 return EFI_UNSUPPORTED
;
75 Handle Alert message recorded in BufferIn. If BufferIn is NULL and BufferInSize is zero,
76 TLS session has errors and the response packet needs to be Alert message based on error type.
78 @param[in] Tls Pointer to the TLS object for state checking.
79 @param[in] BufferIn Pointer to the most recently received TLS Alert packet.
80 @param[in] BufferInSize Packet size in bytes for the most recently received TLS
82 @param[out] BufferOut Pointer to the buffer to hold the built packet.
83 @param[in, out] BufferOutSize Pointer to the buffer size in bytes. On input, it is
84 the buffer size provided by the caller. On output, it
85 is the buffer size in fact needed to contain the
88 @retval EFI_SUCCESS The required TLS packet is built successfully.
89 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
91 BufferIn is NULL but BufferInSize is NOT 0.
92 BufferInSize is 0 but BufferIn is NOT NULL.
93 BufferOutSize is NULL.
94 BufferOut is NULL if *BufferOutSize is not zero.
95 @retval EFI_ABORTED An error occurred.
96 @retval EFI_BUFFER_TOO_SMALL BufferOutSize is too small to hold the response packet.
103 IN UINT8
*BufferIn OPTIONAL
,
104 IN UINTN BufferInSize OPTIONAL
,
105 OUT UINT8
*BufferOut OPTIONAL
,
106 IN OUT UINTN
*BufferOutSize
110 return EFI_UNSUPPORTED
;
114 Build the CloseNotify packet.
116 @param[in] Tls Pointer to the TLS object for state checking.
117 @param[in, out] Buffer Pointer to the buffer to hold the built packet.
118 @param[in, out] BufferSize Pointer to the buffer size in bytes. On input, it is
119 the buffer size provided by the caller. On output, it
120 is the buffer size in fact needed to contain the
123 @retval EFI_SUCCESS The required TLS packet is built successfully.
124 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
127 Buffer is NULL if *BufferSize is not zero.
128 @retval EFI_BUFFER_TOO_SMALL BufferSize is too small to hold the response packet.
135 IN OUT UINT8
*Buffer
,
136 IN OUT UINTN
*BufferSize
140 return EFI_UNSUPPORTED
;
144 Attempts to read bytes from one TLS object and places the data in Buffer.
146 This function will attempt to read BufferSize bytes from the TLS object
147 and places the data in Buffer.
149 @param[in] Tls Pointer to the TLS object.
150 @param[in,out] Buffer Pointer to the buffer to store the data.
151 @param[in] BufferSize The size of Buffer in bytes.
153 @retval >0 The amount of data successfully read from the TLS object.
154 @retval <=0 No data was successfully read.
170 Attempts to write data from the buffer to TLS object.
172 This function will attempt to write BufferSize bytes data from the Buffer
175 @param[in] Tls Pointer to the TLS object.
176 @param[in] Buffer Pointer to the data buffer.
177 @param[in] BufferSize The size of Buffer in bytes.
179 @retval >0 The amount of data successfully written to the TLS object.
180 @retval <=0 No data was successfully written.
196 Attempts to read bytes from the specified TLS connection into the buffer.
198 This function tries to read BufferSize bytes data from the specified TLS
199 connection into the Buffer.
201 @param[in] Tls Pointer to the TLS connection for data reading.
202 @param[in,out] Buffer Pointer to the data buffer.
203 @param[in] BufferSize The size of Buffer in bytes.
205 @retval >0 The read operation was successful, and return value is the
206 number of bytes actually read from the TLS connection.
207 @retval <=0 The read operation was not successful.
223 Attempts to write data to a TLS connection.
225 This function tries to write BufferSize bytes data from the Buffer into the
226 specified TLS connection.
228 @param[in] Tls Pointer to the TLS connection for data writing.
229 @param[in] Buffer Pointer to the data buffer.
230 @param[in] BufferSize The size of Buffer in bytes.
232 @retval >0 The write operation was successful, and return value is the
233 number of bytes actually written to the TLS connection.
234 @retval <=0 The write operation was not successful.