]> git.proxmox.com Git - mirror_edk2.git/blobdiff - CryptoPkg/Library/TlsLibNull/TlsProcessNull.c
CryptoPkg: Add Null instance of the TlsLib class
[mirror_edk2.git] / CryptoPkg / Library / TlsLibNull / TlsProcessNull.c
diff --git a/CryptoPkg/Library/TlsLibNull/TlsProcessNull.c b/CryptoPkg/Library/TlsLibNull/TlsProcessNull.c
new file mode 100644 (file)
index 0000000..2949d4c
--- /dev/null
@@ -0,0 +1,247 @@
+/** @file\r
+  SSL/TLS Process Null Library Wrapper Implementation.\r
+  The process includes the TLS handshake and packet I/O.\r
+\r
+Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.<BR>\r
+(C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>\r
+SPDX-License-Identifier: BSD-2-Clause-Patent\r
+\r
+**/\r
+\r
+#include "InternalTlsLib.h"\r
+\r
+/**\r
+  Checks if the TLS handshake was done.\r
+\r
+  This function will check if the specified TLS handshake was done.\r
+\r
+  @param[in]  Tls    Pointer to the TLS object for handshake state checking.\r
+\r
+  @retval  TRUE     The TLS handshake was done.\r
+  @retval  FALSE    The TLS handshake was not done.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+TlsInHandshake (\r
+  IN     VOID                     *Tls\r
+  )\r
+{\r
+  ASSERT(FALSE);\r
+  return FALSE;\r
+}\r
+\r
+/**\r
+  Perform a TLS/SSL handshake.\r
+\r
+  This function will perform a TLS/SSL handshake.\r
+\r
+  @param[in]       Tls            Pointer to the TLS object for handshake operation.\r
+  @param[in]       BufferIn       Pointer to the most recently received TLS Handshake packet.\r
+  @param[in]       BufferInSize   Packet size in bytes for the most recently received TLS\r
+                                  Handshake packet.\r
+  @param[out]      BufferOut      Pointer to the buffer to hold the built packet.\r
+  @param[in, out]  BufferOutSize  Pointer to the buffer size in bytes. On input, it is\r
+                                  the buffer size provided by the caller. On output, it\r
+                                  is the buffer size in fact needed to contain the\r
+                                  packet.\r
+\r
+  @retval EFI_SUCCESS             The required TLS packet is built successfully.\r
+  @retval EFI_INVALID_PARAMETER   One or more of the following conditions is TRUE:\r
+                                  Tls is NULL.\r
+                                  BufferIn is NULL but BufferInSize is NOT 0.\r
+                                  BufferInSize is 0 but BufferIn is NOT NULL.\r
+                                  BufferOutSize is NULL.\r
+                                  BufferOut is NULL if *BufferOutSize is not zero.\r
+  @retval EFI_BUFFER_TOO_SMALL    BufferOutSize is too small to hold the response packet.\r
+  @retval EFI_ABORTED             Something wrong during handshake.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+TlsDoHandshake (\r
+  IN     VOID                     *Tls,\r
+  IN     UINT8                    *BufferIn, OPTIONAL\r
+  IN     UINTN                    BufferInSize, OPTIONAL\r
+     OUT UINT8                    *BufferOut, OPTIONAL\r
+  IN OUT UINTN                    *BufferOutSize\r
+  )\r
+{\r
+  ASSERT(FALSE);\r
+  return EFI_UNSUPPORTED;\r
+}\r
+\r
+/**\r
+  Handle Alert message recorded in BufferIn. If BufferIn is NULL and BufferInSize is zero,\r
+  TLS session has errors and the response packet needs to be Alert message based on error type.\r
+\r
+  @param[in]       Tls            Pointer to the TLS object for state checking.\r
+  @param[in]       BufferIn       Pointer to the most recently received TLS Alert packet.\r
+  @param[in]       BufferInSize   Packet size in bytes for the most recently received TLS\r
+                                  Alert packet.\r
+  @param[out]      BufferOut      Pointer to the buffer to hold the built packet.\r
+  @param[in, out]  BufferOutSize  Pointer to the buffer size in bytes. On input, it is\r
+                                  the buffer size provided by the caller. On output, it\r
+                                  is the buffer size in fact needed to contain the\r
+                                  packet.\r
+\r
+  @retval EFI_SUCCESS             The required TLS packet is built successfully.\r
+  @retval EFI_INVALID_PARAMETER   One or more of the following conditions is TRUE:\r
+                                  Tls is NULL.\r
+                                  BufferIn is NULL but BufferInSize is NOT 0.\r
+                                  BufferInSize is 0 but BufferIn is NOT NULL.\r
+                                  BufferOutSize is NULL.\r
+                                  BufferOut is NULL if *BufferOutSize is not zero.\r
+  @retval EFI_ABORTED             An error occurred.\r
+  @retval EFI_BUFFER_TOO_SMALL    BufferOutSize is too small to hold the response packet.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+TlsHandleAlert (\r
+  IN     VOID                     *Tls,\r
+  IN     UINT8                    *BufferIn, OPTIONAL\r
+  IN     UINTN                    BufferInSize, OPTIONAL\r
+     OUT UINT8                    *BufferOut, OPTIONAL\r
+  IN OUT UINTN                    *BufferOutSize\r
+  )\r
+{\r
+  ASSERT(FALSE);\r
+  return EFI_UNSUPPORTED;\r
+}\r
+\r
+/**\r
+  Build the CloseNotify packet.\r
+\r
+  @param[in]       Tls            Pointer to the TLS object for state checking.\r
+  @param[in, out]  Buffer         Pointer to the buffer to hold the built packet.\r
+  @param[in, out]  BufferSize     Pointer to the buffer size in bytes. On input, it is\r
+                                  the buffer size provided by the caller. On output, it\r
+                                  is the buffer size in fact needed to contain the\r
+                                  packet.\r
+\r
+  @retval EFI_SUCCESS             The required TLS packet is built successfully.\r
+  @retval EFI_INVALID_PARAMETER   One or more of the following conditions is TRUE:\r
+                                  Tls is NULL.\r
+                                  BufferSize is NULL.\r
+                                  Buffer is NULL if *BufferSize is not zero.\r
+  @retval EFI_BUFFER_TOO_SMALL    BufferSize is too small to hold the response packet.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+TlsCloseNotify (\r
+  IN     VOID                     *Tls,\r
+  IN OUT UINT8                    *Buffer,\r
+  IN OUT UINTN                    *BufferSize\r
+  )\r
+{\r
+  ASSERT(FALSE);\r
+  return EFI_UNSUPPORTED;\r
+}\r
+\r
+/**\r
+  Attempts to read bytes from one TLS object and places the data in Buffer.\r
+\r
+  This function will attempt to read BufferSize bytes from the TLS object\r
+  and places the data in Buffer.\r
+\r
+  @param[in]      Tls           Pointer to the TLS object.\r
+  @param[in,out]  Buffer        Pointer to the buffer to store the data.\r
+  @param[in]      BufferSize    The size of Buffer in bytes.\r
+\r
+  @retval  >0    The amount of data successfully read from the TLS object.\r
+  @retval  <=0   No data was successfully read.\r
+\r
+**/\r
+INTN\r
+EFIAPI\r
+TlsCtrlTrafficOut (\r
+  IN     VOID                     *Tls,\r
+  IN OUT VOID                     *Buffer,\r
+  IN     UINTN                    BufferSize\r
+  )\r
+{\r
+  ASSERT(FALSE);\r
+  return 0;\r
+}\r
+\r
+/**\r
+  Attempts to write data from the buffer to TLS object.\r
+\r
+  This function will attempt to write BufferSize bytes data from the Buffer\r
+  to the TLS object.\r
+\r
+  @param[in]  Tls           Pointer to the TLS object.\r
+  @param[in]  Buffer        Pointer to the data buffer.\r
+  @param[in]  BufferSize    The size of Buffer in bytes.\r
+\r
+  @retval  >0    The amount of data successfully written to the TLS object.\r
+  @retval <=0    No data was successfully written.\r
+\r
+**/\r
+INTN\r
+EFIAPI\r
+TlsCtrlTrafficIn (\r
+  IN     VOID                     *Tls,\r
+  IN     VOID                     *Buffer,\r
+  IN     UINTN                    BufferSize\r
+  )\r
+{\r
+  ASSERT(FALSE);\r
+  return 0;\r
+}\r
+/**\r
+  Attempts to read bytes from the specified TLS connection into the buffer.\r
+\r
+  This function tries to read BufferSize bytes data from the specified TLS\r
+  connection into the Buffer.\r
+\r
+  @param[in]      Tls           Pointer to the TLS connection for data reading.\r
+  @param[in,out]  Buffer        Pointer to the data buffer.\r
+  @param[in]      BufferSize    The size of Buffer in bytes.\r
+\r
+  @retval  >0    The read operation was successful, and return value is the\r
+                 number of bytes actually read from the TLS connection.\r
+  @retval  <=0   The read operation was not successful.\r
+\r
+**/\r
+INTN\r
+EFIAPI\r
+TlsRead (\r
+  IN     VOID                     *Tls,\r
+  IN OUT VOID                     *Buffer,\r
+  IN     UINTN                    BufferSize\r
+  )\r
+{\r
+  ASSERT(FALSE);\r
+  return 0;\r
+}\r
+\r
+/**\r
+  Attempts to write data to a TLS connection.\r
+\r
+  This function tries to write BufferSize bytes data from the Buffer into the\r
+  specified TLS connection.\r
+\r
+  @param[in]  Tls           Pointer to the TLS connection for data writing.\r
+  @param[in]  Buffer        Pointer to the data buffer.\r
+  @param[in]  BufferSize    The size of Buffer in bytes.\r
+\r
+  @retval  >0    The write operation was successful, and return value is the\r
+                 number of bytes actually written to the TLS connection.\r
+  @retval <=0    The write operation was not successful.\r
+\r
+**/\r
+INTN\r
+EFIAPI\r
+TlsWrite (\r
+  IN     VOID                     *Tls,\r
+  IN     VOID                     *Buffer,\r
+  IN     UINTN                    BufferSize\r
+  )\r
+{\r
+  ASSERT(FALSE);\r
+  return 0;\r
+}\r
+\r