]> git.proxmox.com Git - mirror_edk2.git/commitdiff
CryptoPkg: Add Null instance of the TlsLib class
authorSean Brogan <sean.brogan@microsoft.com>
Wed, 25 Sep 2019 17:14:40 +0000 (10:14 -0700)
committerMichael D Kinney <michael.d.kinney@intel.com>
Wed, 23 Oct 2019 21:42:28 +0000 (14:42 -0700)
https://bugzilla.tianocore.org/show_bug.cgi?id=2258

Add a Null instance of the TlsLib class.  This lib instance
can be used as a template for new implementations of the TlsLib
class and can also be used to reduce CI build times for build
checks that depend on the TlsLib class.

Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Xiaoyu Lu <xiaoyux.lu@intel.com>
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: Jian J Wang <jian.j.wang@intel.com>
CryptoPkg/CryptoPkg.dsc
CryptoPkg/Library/TlsLibNull/InternalTlsLib.h [new file with mode: 0644]
CryptoPkg/Library/TlsLibNull/TlsConfigNull.c [new file with mode: 0644]
CryptoPkg/Library/TlsLibNull/TlsInitNull.c [new file with mode: 0644]
CryptoPkg/Library/TlsLibNull/TlsLibNull.inf [new file with mode: 0644]
CryptoPkg/Library/TlsLibNull/TlsLibNull.uni [new file with mode: 0644]
CryptoPkg/Library/TlsLibNull/TlsProcessNull.c [new file with mode: 0644]

index f2670513a65ec157b8e8c85650cd66f07184976b..0128ecdf691e751cfb8b9ae998be503ffb191792 100644 (file)
   CryptoPkg/Library/BaseCryptLib/RuntimeCryptLib.inf\r
   CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf\r
   CryptoPkg/Library/TlsLib/TlsLib.inf\r
   CryptoPkg/Library/BaseCryptLib/RuntimeCryptLib.inf\r
   CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf\r
   CryptoPkg/Library/TlsLib/TlsLib.inf\r
+  CryptoPkg/Library/TlsLibNull/TlsLibNull.inf\r
   CryptoPkg/Library/OpensslLib/OpensslLib.inf\r
   CryptoPkg/Library/OpensslLib/OpensslLibCrypto.inf\r
 \r
   CryptoPkg/Library/OpensslLib/OpensslLib.inf\r
   CryptoPkg/Library/OpensslLib/OpensslLibCrypto.inf\r
 \r
diff --git a/CryptoPkg/Library/TlsLibNull/InternalTlsLib.h b/CryptoPkg/Library/TlsLibNull/InternalTlsLib.h
new file mode 100644 (file)
index 0000000..888c906
--- /dev/null
@@ -0,0 +1,16 @@
+/** @file\r
+  Internal include file for TlsLibNull.\r
+\r
+Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.<BR>\r
+SPDX-License-Identifier: BSD-2-Clause-Patent\r
+\r
+**/\r
+\r
+#ifndef __INTERNAL_TLS_LIB_NULL_H__\r
+#define __INTERNAL_TLS_LIB_NULL_H__\r
+\r
+#include <Library/BaseCryptLib.h>\r
+#include <Library/DebugLib.h>\r
+#include <Library/BaseLib.h>\r
+\r
+#endif\r
diff --git a/CryptoPkg/Library/TlsLibNull/TlsConfigNull.c b/CryptoPkg/Library/TlsLibNull/TlsConfigNull.c
new file mode 100644 (file)
index 0000000..8033a61
--- /dev/null
@@ -0,0 +1,622 @@
+/** @file\r
+  SSL/TLS Configuration Null Library Wrapper Implementation.\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
+  Set a new TLS/SSL method for a particular TLS object.\r
+\r
+  This function sets a new TLS/SSL method for a particular TLS object.\r
+\r
+  @param[in]  Tls         Pointer to a TLS object.\r
+  @param[in]  MajorVer    Major Version of TLS/SSL Protocol.\r
+  @param[in]  MinorVer    Minor Version of TLS/SSL Protocol.\r
+\r
+  @retval  EFI_SUCCESS           The TLS/SSL method was set successfully.\r
+  @retval  EFI_INVALID_PARAMETER The parameter is invalid.\r
+  @retval  EFI_UNSUPPORTED       Unsupported TLS/SSL method.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+TlsSetVersion (\r
+  IN     VOID                     *Tls,\r
+  IN     UINT8                    MajorVer,\r
+  IN     UINT8                    MinorVer\r
+  )\r
+{\r
+  ASSERT(FALSE);\r
+  return EFI_UNSUPPORTED;\r
+}\r
+\r
+/**\r
+  Set TLS object to work in client or server mode.\r
+\r
+  This function prepares a TLS object to work in client or server mode.\r
+\r
+  @param[in]  Tls         Pointer to a TLS object.\r
+  @param[in]  IsServer    Work in server mode.\r
+\r
+  @retval  EFI_SUCCESS           The TLS/SSL work mode was set successfully.\r
+  @retval  EFI_INVALID_PARAMETER The parameter is invalid.\r
+  @retval  EFI_UNSUPPORTED       Unsupported TLS/SSL work mode.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+TlsSetConnectionEnd (\r
+  IN     VOID                     *Tls,\r
+  IN     BOOLEAN                  IsServer\r
+  )\r
+{\r
+  ASSERT(FALSE);\r
+  return EFI_UNSUPPORTED;\r
+}\r
+\r
+/**\r
+  Set the ciphers list to be used by the TLS object.\r
+\r
+  This function sets the ciphers for use by a specified TLS object.\r
+\r
+  @param[in]  Tls          Pointer to a TLS object.\r
+  @param[in]  CipherId     Array of UINT16 cipher identifiers. Each UINT16\r
+                           cipher identifier comes from the TLS Cipher Suite\r
+                           Registry of the IANA, interpreting Byte1 and Byte2\r
+                           in network (big endian) byte order.\r
+  @param[in]  CipherNum    The number of cipher in the list.\r
+\r
+  @retval  EFI_SUCCESS           The ciphers list was set successfully.\r
+  @retval  EFI_INVALID_PARAMETER The parameter is invalid.\r
+  @retval  EFI_UNSUPPORTED       No supported TLS cipher was found in CipherId.\r
+  @retval  EFI_OUT_OF_RESOURCES  Memory allocation failed.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+TlsSetCipherList (\r
+  IN     VOID                     *Tls,\r
+  IN     UINT16                   *CipherId,\r
+  IN     UINTN                    CipherNum\r
+  )\r
+{\r
+  ASSERT(FALSE);\r
+  return EFI_UNSUPPORTED;\r
+}\r
+\r
+/**\r
+  Set the compression method for TLS/SSL operations.\r
+\r
+  This function handles TLS/SSL integrated compression methods.\r
+\r
+  @param[in]  CompMethod    The compression method ID.\r
+\r
+  @retval  EFI_SUCCESS        The compression method for the communication was\r
+                              set successfully.\r
+  @retval  EFI_UNSUPPORTED    Unsupported compression method.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+TlsSetCompressionMethod (\r
+  IN     UINT8                    CompMethod\r
+  )\r
+{\r
+  ASSERT(FALSE);\r
+  return EFI_UNSUPPORTED;\r
+}\r
+\r
+/**\r
+  Set peer certificate verification mode for the TLS connection.\r
+\r
+  This function sets the verification mode flags for the TLS connection.\r
+\r
+  @param[in]  Tls           Pointer to the TLS object.\r
+  @param[in]  VerifyMode    A set of logically or'ed verification mode flags.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+TlsSetVerify (\r
+  IN     VOID                     *Tls,\r
+  IN     UINT32                   VerifyMode\r
+  )\r
+{\r
+  ASSERT(FALSE);\r
+}\r
+\r
+// MU_CHANGE - Proposed fixes for TCBZ960, invalid domain name (CN) accepted. [BEGIN]\r
+/**\r
+  Set the specified host name to be verified.\r
+\r
+  @param[in]  Tls           Pointer to the TLS object.\r
+  @param[in]  Flags         The setting flags during the validation.\r
+  @param[in]  HostName      The specified host name to be verified.\r
+\r
+  @retval  EFI_SUCCESS           The HostName setting was set successfully.\r
+  @retval  EFI_INVALID_PARAMETER The parameter is invalid.\r
+  @retval  EFI_ABORTED           Invalid HostName setting.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+TlsSetVerifyHost (\r
+  IN     VOID                     *Tls,\r
+  IN     UINT32                   Flags,\r
+  IN     CHAR8                    *HostName\r
+  )\r
+{\r
+  ASSERT(FALSE);\r
+  return EFI_UNSUPPORTED;\r
+}\r
+\r
+// MU_CHANGE - Proposed fixes for TCBZ960, invalid domain name (CN) accepted. [END]\r
+\r
+/**\r
+  Sets a TLS/SSL session ID to be used during TLS/SSL connect.\r
+\r
+  This function sets a session ID to be used when the TLS/SSL connection is\r
+  to be established.\r
+\r
+  @param[in]  Tls             Pointer to the TLS object.\r
+  @param[in]  SessionId       Session ID data used for session resumption.\r
+  @param[in]  SessionIdLen    Length of Session ID in bytes.\r
+\r
+  @retval  EFI_SUCCESS           Session ID was set successfully.\r
+  @retval  EFI_INVALID_PARAMETER The parameter is invalid.\r
+  @retval  EFI_UNSUPPORTED       No available session for ID setting.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+TlsSetSessionId (\r
+  IN     VOID                     *Tls,\r
+  IN     UINT8                    *SessionId,\r
+  IN     UINT16                   SessionIdLen\r
+  )\r
+{\r
+  ASSERT(FALSE);\r
+  return EFI_UNSUPPORTED;\r
+}\r
+\r
+/**\r
+  Adds the CA to the cert store when requesting Server or Client authentication.\r
+\r
+  This function adds the CA certificate to the list of CAs when requesting\r
+  Server or Client authentication for the chosen TLS connection.\r
+\r
+  @param[in]  Tls         Pointer to the TLS object.\r
+  @param[in]  Data        Pointer to the data buffer of a DER-encoded binary\r
+                          X.509 certificate or PEM-encoded X.509 certificate.\r
+  @param[in]  DataSize    The size of data buffer in bytes.\r
+\r
+  @retval  EFI_SUCCESS             The operation succeeded.\r
+  @retval  EFI_INVALID_PARAMETER   The parameter is invalid.\r
+  @retval  EFI_OUT_OF_RESOURCES    Required resources could not be allocated.\r
+  @retval  EFI_ABORTED             Invalid X.509 certificate.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+TlsSetCaCertificate (\r
+  IN     VOID                     *Tls,\r
+  IN     VOID                     *Data,\r
+  IN     UINTN                    DataSize\r
+  )\r
+{\r
+  ASSERT(FALSE);\r
+  return EFI_UNSUPPORTED;\r
+}\r
+\r
+/**\r
+  Loads the local public certificate into the specified TLS object.\r
+\r
+  This function loads the X.509 certificate into the specified TLS object\r
+  for TLS negotiation.\r
+\r
+  @param[in]  Tls         Pointer to the TLS object.\r
+  @param[in]  Data        Pointer to the data buffer of a DER-encoded binary\r
+                          X.509 certificate or PEM-encoded X.509 certificate.\r
+  @param[in]  DataSize    The size of data buffer in bytes.\r
+\r
+  @retval  EFI_SUCCESS             The operation succeeded.\r
+  @retval  EFI_INVALID_PARAMETER   The parameter is invalid.\r
+  @retval  EFI_OUT_OF_RESOURCES    Required resources could not be allocated.\r
+  @retval  EFI_ABORTED             Invalid X.509 certificate.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+TlsSetHostPublicCert (\r
+  IN     VOID                     *Tls,\r
+  IN     VOID                     *Data,\r
+  IN     UINTN                    DataSize\r
+  )\r
+{\r
+  ASSERT(FALSE);\r
+  return EFI_UNSUPPORTED;\r
+}\r
+\r
+/**\r
+  Adds the local private key to the specified TLS object.\r
+\r
+  This function adds the local private key (PEM-encoded RSA or PKCS#8 private\r
+  key) into the specified TLS object for TLS negotiation.\r
+\r
+  @param[in]  Tls         Pointer to the TLS object.\r
+  @param[in]  Data        Pointer to the data buffer of a PEM-encoded RSA\r
+                          or PKCS#8 private key.\r
+  @param[in]  DataSize    The size of data buffer in bytes.\r
+\r
+  @retval  EFI_SUCCESS     The operation succeeded.\r
+  @retval  EFI_UNSUPPORTED This function is not supported.\r
+  @retval  EFI_ABORTED     Invalid private key data.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+TlsSetHostPrivateKey (\r
+  IN     VOID                     *Tls,\r
+  IN     VOID                     *Data,\r
+  IN     UINTN                    DataSize\r
+  )\r
+{\r
+  ASSERT(FALSE);\r
+  return EFI_UNSUPPORTED;\r
+}\r
+\r
+/**\r
+  Adds the CA-supplied certificate revocation list for certificate validation.\r
+\r
+  This function adds the CA-supplied certificate revocation list data for\r
+  certificate validity checking.\r
+\r
+  @param[in]  Data        Pointer to the data buffer of a DER-encoded CRL data.\r
+  @param[in]  DataSize    The size of data buffer in bytes.\r
+\r
+  @retval  EFI_SUCCESS     The operation succeeded.\r
+  @retval  EFI_UNSUPPORTED This function is not supported.\r
+  @retval  EFI_ABORTED     Invalid CRL data.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+TlsSetCertRevocationList (\r
+  IN     VOID                     *Data,\r
+  IN     UINTN                    DataSize\r
+  )\r
+{\r
+  ASSERT(FALSE);\r
+  return EFI_UNSUPPORTED;\r
+}\r
+\r
+/**\r
+  Gets the protocol version used by the specified TLS connection.\r
+\r
+  This function returns the protocol version used by the specified TLS\r
+  connection.\r
+\r
+  If Tls is NULL, then ASSERT().\r
+\r
+  @param[in]  Tls    Pointer to the TLS object.\r
+\r
+  @return  The protocol version of the specified TLS connection.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+TlsGetVersion (\r
+  IN     VOID                     *Tls\r
+  )\r
+{\r
+  ASSERT(FALSE);\r
+  return 0;\r
+}\r
+\r
+/**\r
+  Gets the connection end of the specified TLS connection.\r
+\r
+  This function returns the connection end (as client or as server) used by\r
+  the specified TLS connection.\r
+\r
+  If Tls is NULL, then ASSERT().\r
+\r
+  @param[in]  Tls    Pointer to the TLS object.\r
+\r
+  @return  The connection end used by the specified TLS connection.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+TlsGetConnectionEnd (\r
+  IN     VOID                     *Tls\r
+  )\r
+{\r
+  ASSERT(FALSE);\r
+  return 0;\r
+}\r
+\r
+/**\r
+  Gets the cipher suite used by the specified TLS connection.\r
+\r
+  This function returns current cipher suite used by the specified\r
+  TLS connection.\r
+\r
+  @param[in]      Tls         Pointer to the TLS object.\r
+  @param[in,out]  CipherId    The cipher suite used by the TLS object.\r
+\r
+  @retval  EFI_SUCCESS           The cipher suite was returned successfully.\r
+  @retval  EFI_INVALID_PARAMETER The parameter is invalid.\r
+  @retval  EFI_UNSUPPORTED       Unsupported cipher suite.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+TlsGetCurrentCipher (\r
+  IN     VOID                     *Tls,\r
+  IN OUT UINT16                   *CipherId\r
+  )\r
+{\r
+  ASSERT(FALSE);\r
+  return EFI_UNSUPPORTED;\r
+}\r
+\r
+/**\r
+  Gets the compression methods used by the specified TLS connection.\r
+\r
+  This function returns current integrated compression methods used by\r
+  the specified TLS connection.\r
+\r
+  @param[in]      Tls              Pointer to the TLS object.\r
+  @param[in,out]  CompressionId    The current compression method used by\r
+                                   the TLS object.\r
+\r
+  @retval  EFI_SUCCESS           The compression method was returned successfully.\r
+  @retval  EFI_INVALID_PARAMETER The parameter is invalid.\r
+  @retval  EFI_ABORTED           Invalid Compression method.\r
+  @retval  EFI_UNSUPPORTED       This function is not supported.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+TlsGetCurrentCompressionId (\r
+  IN     VOID                     *Tls,\r
+  IN OUT UINT8                    *CompressionId\r
+  )\r
+{\r
+  ASSERT(FALSE);\r
+  return EFI_UNSUPPORTED;\r
+}\r
+\r
+/**\r
+  Gets the verification mode currently set in the TLS connection.\r
+\r
+  This function returns the peer verification mode currently set in the\r
+  specified TLS connection.\r
+\r
+  If Tls is NULL, then ASSERT().\r
+\r
+  @param[in]  Tls    Pointer to the TLS object.\r
+\r
+  @return  The verification mode set in the specified TLS connection.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+TlsGetVerify (\r
+  IN     VOID                     *Tls\r
+  )\r
+{\r
+  ASSERT(FALSE);\r
+  return 0;\r
+}\r
+\r
+/**\r
+  Gets the session ID used by the specified TLS connection.\r
+\r
+  This function returns the TLS/SSL session ID currently used by the\r
+  specified TLS connection.\r
+\r
+  @param[in]      Tls             Pointer to the TLS object.\r
+  @param[in,out]  SessionId       Buffer to contain the returned session ID.\r
+  @param[in,out]  SessionIdLen    The length of Session ID in bytes.\r
+\r
+  @retval  EFI_SUCCESS           The Session ID was returned successfully.\r
+  @retval  EFI_INVALID_PARAMETER The parameter is invalid.\r
+  @retval  EFI_UNSUPPORTED       Invalid TLS/SSL session.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+TlsGetSessionId (\r
+  IN     VOID                     *Tls,\r
+  IN OUT UINT8                    *SessionId,\r
+  IN OUT UINT16                   *SessionIdLen\r
+  )\r
+{\r
+  ASSERT(FALSE);\r
+  return EFI_UNSUPPORTED;\r
+}\r
+\r
+/**\r
+  Gets the client random data used in the specified TLS connection.\r
+\r
+  This function returns the TLS/SSL client random data currently used in\r
+  the specified TLS connection.\r
+\r
+  @param[in]      Tls             Pointer to the TLS object.\r
+  @param[in,out]  ClientRandom    Buffer to contain the returned client\r
+                                  random data (32 bytes).\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+TlsGetClientRandom (\r
+  IN     VOID                     *Tls,\r
+  IN OUT UINT8                    *ClientRandom\r
+  )\r
+{\r
+  ASSERT(FALSE);\r
+}\r
+\r
+/**\r
+  Gets the server random data used in the specified TLS connection.\r
+\r
+  This function returns the TLS/SSL server random data currently used in\r
+  the specified TLS connection.\r
+\r
+  @param[in]      Tls             Pointer to the TLS object.\r
+  @param[in,out]  ServerRandom    Buffer to contain the returned server\r
+                                  random data (32 bytes).\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+TlsGetServerRandom (\r
+  IN     VOID                     *Tls,\r
+  IN OUT UINT8                    *ServerRandom\r
+  )\r
+{\r
+  ASSERT(FALSE);\r
+}\r
+\r
+/**\r
+  Gets the master key data used in the specified TLS connection.\r
+\r
+  This function returns the TLS/SSL master key material currently used in\r
+  the specified TLS connection.\r
+\r
+  @param[in]      Tls            Pointer to the TLS object.\r
+  @param[in,out]  KeyMaterial    Buffer to contain the returned key material.\r
+\r
+  @retval  EFI_SUCCESS           Key material was returned successfully.\r
+  @retval  EFI_INVALID_PARAMETER The parameter is invalid.\r
+  @retval  EFI_UNSUPPORTED       Invalid TLS/SSL session.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+TlsGetKeyMaterial (\r
+  IN     VOID                     *Tls,\r
+  IN OUT UINT8                    *KeyMaterial\r
+  )\r
+{\r
+  ASSERT(FALSE);\r
+  return EFI_UNSUPPORTED;\r
+}\r
+\r
+/**\r
+  Gets the CA Certificate from the cert store.\r
+\r
+  This function returns the CA certificate for the chosen\r
+  TLS connection.\r
+\r
+  @param[in]      Tls         Pointer to the TLS object.\r
+  @param[out]     Data        Pointer to the data buffer to receive the CA\r
+                              certificate data sent to the client.\r
+  @param[in,out]  DataSize    The size of data buffer in bytes.\r
+\r
+  @retval  EFI_SUCCESS             The operation succeeded.\r
+  @retval  EFI_UNSUPPORTED         This function is not supported.\r
+  @retval  EFI_BUFFER_TOO_SMALL    The Data is too small to hold the data.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+TlsGetCaCertificate (\r
+  IN     VOID                     *Tls,\r
+  OUT    VOID                     *Data,\r
+  IN OUT UINTN                    *DataSize\r
+  )\r
+{\r
+  ASSERT(FALSE);\r
+  return EFI_UNSUPPORTED;\r
+}\r
+\r
+/**\r
+  Gets the local public Certificate set in the specified TLS object.\r
+\r
+  This function returns the local public certificate which was currently set\r
+  in the specified TLS object.\r
+\r
+  @param[in]      Tls         Pointer to the TLS object.\r
+  @param[out]     Data        Pointer to the data buffer to receive the local\r
+                              public certificate.\r
+  @param[in,out]  DataSize    The size of data buffer in bytes.\r
+\r
+  @retval  EFI_SUCCESS             The operation succeeded.\r
+  @retval  EFI_INVALID_PARAMETER   The parameter is invalid.\r
+  @retval  EFI_NOT_FOUND           The certificate is not found.\r
+  @retval  EFI_BUFFER_TOO_SMALL    The Data is too small to hold the data.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+TlsGetHostPublicCert (\r
+  IN     VOID                     *Tls,\r
+  OUT    VOID                     *Data,\r
+  IN OUT UINTN                    *DataSize\r
+  )\r
+{\r
+  ASSERT(FALSE);\r
+  return EFI_UNSUPPORTED;\r
+}\r
+\r
+/**\r
+  Gets the local private key set in the specified TLS object.\r
+\r
+  This function returns the local private key data which was currently set\r
+  in the specified TLS object.\r
+\r
+  @param[in]      Tls         Pointer to the TLS object.\r
+  @param[out]     Data        Pointer to the data buffer to receive the local\r
+                              private key data.\r
+  @param[in,out]  DataSize    The size of data buffer in bytes.\r
+\r
+  @retval  EFI_SUCCESS             The operation succeeded.\r
+  @retval  EFI_UNSUPPORTED         This function is not supported.\r
+  @retval  EFI_BUFFER_TOO_SMALL    The Data is too small to hold the data.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+TlsGetHostPrivateKey (\r
+  IN     VOID                     *Tls,\r
+  OUT    VOID                     *Data,\r
+  IN OUT UINTN                    *DataSize\r
+  )\r
+{\r
+  ASSERT(FALSE);\r
+  return EFI_UNSUPPORTED;\r
+}\r
+\r
+/**\r
+  Gets the CA-supplied certificate revocation list data set in the specified\r
+  TLS object.\r
+\r
+  This function returns the CA-supplied certificate revocation list data which\r
+  was currently set in the specified TLS object.\r
+\r
+  @param[out]     Data        Pointer to the data buffer to receive the CRL data.\r
+  @param[in,out]  DataSize    The size of data buffer in bytes.\r
+\r
+  @retval  EFI_SUCCESS             The operation succeeded.\r
+  @retval  EFI_UNSUPPORTED         This function is not supported.\r
+  @retval  EFI_BUFFER_TOO_SMALL    The Data is too small to hold the data.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+TlsGetCertRevocationList (\r
+  OUT    VOID                     *Data,\r
+  IN OUT UINTN                    *DataSize\r
+  )\r
+{\r
+  ASSERT(FALSE);\r
+  return EFI_UNSUPPORTED;\r
+}\r
diff --git a/CryptoPkg/Library/TlsLibNull/TlsInitNull.c b/CryptoPkg/Library/TlsLibNull/TlsInitNull.c
new file mode 100644 (file)
index 0000000..3e44117
--- /dev/null
@@ -0,0 +1,111 @@
+/** @file\r
+  SSL/TLS Initialization Null Library Wrapper Implementation.\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
+  Initializes the library.\r
+\r
+  This function registers ciphers and digests used directly and indirectly\r
+  by SSL/TLS, and initializes the readable error messages.\r
+  This function must be called before any other action takes places.\r
+\r
+  @retval TRUE   The library has been initialized.\r
+  @retval FALSE  Failed to initialize the library.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+TlsInitialize (\r
+  VOID\r
+  )\r
+{\r
+  ASSERT(FALSE);\r
+  return FALSE;\r
+}\r
+\r
+/**\r
+  Free an allocated SSL_CTX object.\r
+\r
+  @param[in]  TlsCtx    Pointer to the SSL_CTX object to be released.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+TlsCtxFree (\r
+  IN   VOID                  *TlsCtx\r
+  )\r
+{\r
+  ASSERT(FALSE);\r
+  return;\r
+}\r
+\r
+/**\r
+  Creates a new SSL_CTX object as framework to establish TLS/SSL enabled\r
+  connections.\r
+\r
+  @param[in]  MajorVer    Major Version of TLS/SSL Protocol.\r
+  @param[in]  MinorVer    Minor Version of TLS/SSL Protocol.\r
+\r
+  @return  Pointer to an allocated SSL_CTX object.\r
+           If the creation failed, TlsCtxNew() returns NULL.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+TlsCtxNew (\r
+  IN     UINT8                    MajorVer,\r
+  IN     UINT8                    MinorVer\r
+  )\r
+{\r
+  ASSERT(FALSE);\r
+  return NULL;\r
+}\r
+\r
+/**\r
+  Free an allocated TLS object.\r
+\r
+  This function removes the TLS object pointed to by Tls and frees up the\r
+  allocated memory. If Tls is NULL, nothing is done.\r
+\r
+  @param[in]  Tls    Pointer to the TLS object to be freed.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+TlsFree (\r
+  IN     VOID                     *Tls\r
+  )\r
+{\r
+  ASSERT(FALSE);\r
+}\r
+\r
+/**\r
+  Create a new TLS object for a connection.\r
+\r
+  This function creates a new TLS object for a connection. The new object\r
+  inherits the setting of the underlying context TlsCtx: connection method,\r
+  options, verification setting.\r
+\r
+  @param[in]  TlsCtx    Pointer to the SSL_CTX object.\r
+\r
+  @return  Pointer to an allocated SSL object.\r
+           If the creation failed, TlsNew() returns NULL.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+TlsNew (\r
+  IN     VOID                     *TlsCtx\r
+  )\r
+{\r
+  ASSERT(FALSE);\r
+  return NULL;\r
+}\r
+\r
diff --git a/CryptoPkg/Library/TlsLibNull/TlsLibNull.inf b/CryptoPkg/Library/TlsLibNull/TlsLibNull.inf
new file mode 100644 (file)
index 0000000..33f0e74
--- /dev/null
@@ -0,0 +1,38 @@
+## @file\r
+#  SSL/TLS Wrapper Null Library Instance.\r
+#\r
+#  Copyright (c) 2016 - 2018, 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
+[Defines]\r
+  INF_VERSION                    = 0x00010005\r
+  BASE_NAME                      = TlsLibNull\r
+  MODULE_UNI_FILE                = TlsLibNull.uni\r
+  FILE_GUID                      = 705a5b3b-cfa5-42ea-87f0-f2b8d44ec521\r
+  MODULE_TYPE                    = BASE\r
+  VERSION_STRING                 = 1.0\r
+  LIBRARY_CLASS                  = TlsLib\r
+\r
+#\r
+# The following information is for reference only and not required by the build tools.\r
+#\r
+#  VALID_ARCHITECTURES           = IA32 X64 ARM AARCH64\r
+#\r
+\r
+[Sources]\r
+  InternalTlsLib.h\r
+  TlsInitNull.c\r
+  TlsConfigNull.c\r
+  TlsProcessNull.c\r
+\r
+[Packages]\r
+  MdePkg/MdePkg.dec\r
+  CryptoPkg/CryptoPkg.dec\r
+\r
+[LibraryClasses]\r
+  BaseCryptLib\r
+  DebugLib\r
+  BaseLib\r
diff --git a/CryptoPkg/Library/TlsLibNull/TlsLibNull.uni b/CryptoPkg/Library/TlsLibNull/TlsLibNull.uni
new file mode 100644 (file)
index 0000000..869f3fc
--- /dev/null
@@ -0,0 +1,13 @@
+// /** @file\r
+// SSL/TLS Wrapper Null Library Instance.\r
+//\r
+// Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>\r
+//\r
+// SPDX-License-Identifier: BSD-2-Clause-Patent\r
+//\r
+// **/\r
+\r
+\r
+#string STR_MODULE_ABSTRACT             #language en-US "SSL/TLS Wrapper Null Library Instance"\r
+\r
+#string STR_MODULE_DESCRIPTION          #language en-US "This module provides SSL/TLS Wrapper Null Library Instance."\r
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