[edk2] [Patch 4/6] NetworkPkg: TlsDxe driver implementation over OpenSSL

2016-02-24 Thread Jiaxin Wu
This patch is the implementation of EFI TLS Protocol
and EFI TLS Configuration Protocol Interfaces.

Cc: Ye Ting 
Cc: Fu Siyuan 
Cc: Long Qin 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jiaxin Wu 
---
 NetworkPkg/NetworkPkg.dsc |   3 +
 NetworkPkg/TlsDxe/TlsConfigProtocol.c | 152 +
 NetworkPkg/TlsDxe/TlsDriver.c | 499 +++
 NetworkPkg/TlsDxe/TlsDriver.h | 237 +
 NetworkPkg/TlsDxe/TlsDxe.inf  |  67 
 NetworkPkg/TlsDxe/TlsDxe.uni  |  25 ++
 NetworkPkg/TlsDxe/TlsDxeExtra.uni |  20 ++
 NetworkPkg/TlsDxe/TlsImpl.c   | 280 +++
 NetworkPkg/TlsDxe/TlsImpl.h   | 342 +++
 NetworkPkg/TlsDxe/TlsProtocol.c   | 627 ++
 10 files changed, 2252 insertions(+)
 create mode 100644 NetworkPkg/TlsDxe/TlsConfigProtocol.c
 create mode 100644 NetworkPkg/TlsDxe/TlsDriver.c
 create mode 100644 NetworkPkg/TlsDxe/TlsDriver.h
 create mode 100644 NetworkPkg/TlsDxe/TlsDxe.inf
 create mode 100644 NetworkPkg/TlsDxe/TlsDxe.uni
 create mode 100644 NetworkPkg/TlsDxe/TlsDxeExtra.uni
 create mode 100644 NetworkPkg/TlsDxe/TlsImpl.c
 create mode 100644 NetworkPkg/TlsDxe/TlsImpl.h
 create mode 100644 NetworkPkg/TlsDxe/TlsProtocol.c

diff --git a/NetworkPkg/NetworkPkg.dsc b/NetworkPkg/NetworkPkg.dsc
index 0695dc1..2712a6a 100644
--- a/NetworkPkg/NetworkPkg.dsc
+++ b/NetworkPkg/NetworkPkg.dsc
@@ -47,10 +47,12 @@
   TcpIoLib|MdeModulePkg/Library/DxeTcpIoLib/DxeTcpIoLib.inf
   HttpLib|MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.inf
   BaseCryptLib|CryptoPkg/Library/BaseCryptLib/BaseCryptLib.inf
   OpensslLib|CryptoPkg/Library/OpensslLib/OpensslLib.inf
   IntrinsicLib|CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf
+  OpensslTlsLib|CryptoPkg/Library/OpensslLib/OpensslTlsLib.inf
+  TlsLib|CryptoPkg/Library/TlsLib/TlsLib.inf
   
DebugPrintErrorLevelLib|MdePkg/Library/BaseDebugPrintErrorLevelLib/BaseDebugPrintErrorLevelLib.inf
  
   FileHandleLib|MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.inf
   SortLib|MdeModulePkg/Library/UefiSortLib/UefiSortLib.inf
 
 [LibraryClasses.common.UEFI_DRIVER]
@@ -103,10 +105,11 @@
   NetworkPkg/Mtftp6Dxe/Mtftp6Dxe.inf
   NetworkPkg/DnsDxe/DnsDxe.inf
   NetworkPkg/HttpDxe/HttpDxe.inf
   NetworkPkg/HttpUtilitiesDxe/HttpUtilitiesDxe.inf
   NetworkPkg/HttpBootDxe/HttpBootDxe.inf
+  NetworkPkg/TlsDxe/TlsDxe.inf
 
   NetworkPkg/Application/IfConfig6/IfConfig6.inf
   NetworkPkg/Application/IpsecConfig/IpSecConfig.inf
   NetworkPkg/Application/VConfig/VConfig.inf
 
diff --git a/NetworkPkg/TlsDxe/TlsConfigProtocol.c 
b/NetworkPkg/TlsDxe/TlsConfigProtocol.c
new file mode 100644
index 000..2855be1
--- /dev/null
+++ b/NetworkPkg/TlsDxe/TlsConfigProtocol.c
@@ -0,0 +1,152 @@
+/** @file
+  Implementation of EFI TLS Configuration Protocol Interfaces.
+
+  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.
+
+**/
+
+#include "TlsImpl.h"
+
+EFI_TLS_CONFIGURATION_PROTOCOL  mTlsConfigurationProtocol = {
+  TlsConfigurationSetData,
+  TlsConfigurationGetData
+};
+
+/**
+  Set TLS configuration data.
+
+  The SetData() function sets TLS configuration to non-volatile storage or 
volatile
+  storage.
+
+  @param[in]  ThisPointer to the 
EFI_TLS_CONFIGURATION_PROTOCOL instance.
+  @param[in]  DataTypeConfiguration data type.
+  @param[in]  DataPointer to configuration data.
+  @param[in]  DataSizeTotal size of configuration data.
+
+  @retval EFI_SUCCESS The TLS configuration data is set 
successfully.
+  @retval EFI_INVALID_PARAMETER   One or more of the following conditions is 
TRUE:
+  This is NULL.
+  Data is NULL.
+  DataSize is 0.
+  @retval EFI_UNSUPPORTED The DataType is unsupported.
+  @retval EFI_OUT_OF_RESOURCESRequired system resources could not be 
allocated.
+
+**/
+EFI_STATUS
+EFIAPI
+TlsConfigurationSetData (
+  IN EFI_TLS_CONFIGURATION_PROTOCOL  *This,
+  IN EFI_TLS_CONFIG_DATA_TYPEDataType,
+  IN VOID*Data,
+  IN UINTN   DataSize
+  )
+{
+  EFI_STATUSStatus;
+  TLS_INSTANCE  *Instance;
+  EFI_TPL   OldTpl;
+
+  Status = EFI_SUCCESS;
+
+  if (This == NULL ||  Data == NULL || DataSize == 0) {
+return EFI_INVALID_PARAMETER;
+  }
+
+  OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
+
+  Instance = TLS_INSTANCE_

Re: [edk2] [Patch 4/6] NetworkPkg: TlsDxe driver implementation over OpenSSL

2016-02-24 Thread Fu, Siyuan
Reviewed-by: Fu Siyuan 



> -Original Message-
> From: Wu, Jiaxin
> Sent: Wednesday, February 24, 2016 4:15 PM
> To: edk2-devel@lists.01.org
> Cc: Ye, Ting ; Fu, Siyuan ; Long,
> Qin 
> Subject: [Patch 4/6] NetworkPkg: TlsDxe driver implementation over OpenSSL
> 
> This patch is the implementation of EFI TLS Protocol
> and EFI TLS Configuration Protocol Interfaces.
> 
> Cc: Ye Ting 
> Cc: Fu Siyuan 
> Cc: Long Qin 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Jiaxin Wu 
> ---
>  NetworkPkg/NetworkPkg.dsc |   3 +
>  NetworkPkg/TlsDxe/TlsConfigProtocol.c | 152 +
>  NetworkPkg/TlsDxe/TlsDriver.c | 499 +++
>  NetworkPkg/TlsDxe/TlsDriver.h | 237 +
>  NetworkPkg/TlsDxe/TlsDxe.inf  |  67 
>  NetworkPkg/TlsDxe/TlsDxe.uni  |  25 ++
>  NetworkPkg/TlsDxe/TlsDxeExtra.uni |  20 ++
>  NetworkPkg/TlsDxe/TlsImpl.c   | 280 +++
>  NetworkPkg/TlsDxe/TlsImpl.h   | 342 +++
>  NetworkPkg/TlsDxe/TlsProtocol.c   | 627
> ++
>  10 files changed, 2252 insertions(+)
>  create mode 100644 NetworkPkg/TlsDxe/TlsConfigProtocol.c
>  create mode 100644 NetworkPkg/TlsDxe/TlsDriver.c
>  create mode 100644 NetworkPkg/TlsDxe/TlsDriver.h
>  create mode 100644 NetworkPkg/TlsDxe/TlsDxe.inf
>  create mode 100644 NetworkPkg/TlsDxe/TlsDxe.uni
>  create mode 100644 NetworkPkg/TlsDxe/TlsDxeExtra.uni
>  create mode 100644 NetworkPkg/TlsDxe/TlsImpl.c
>  create mode 100644 NetworkPkg/TlsDxe/TlsImpl.h
>  create mode 100644 NetworkPkg/TlsDxe/TlsProtocol.c
> 
> diff --git a/NetworkPkg/NetworkPkg.dsc b/NetworkPkg/NetworkPkg.dsc
> index 0695dc1..2712a6a 100644
> --- a/NetworkPkg/NetworkPkg.dsc
> +++ b/NetworkPkg/NetworkPkg.dsc
> @@ -47,10 +47,12 @@
>TcpIoLib|MdeModulePkg/Library/DxeTcpIoLib/DxeTcpIoLib.inf
>HttpLib|MdeModulePkg/Library/DxeHttpLib/DxeHttpLib.inf
>BaseCryptLib|CryptoPkg/Library/BaseCryptLib/BaseCryptLib.inf
>OpensslLib|CryptoPkg/Library/OpensslLib/OpensslLib.inf
>IntrinsicLib|CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf
> +  OpensslTlsLib|CryptoPkg/Library/OpensslLib/OpensslTlsLib.inf
> +  TlsLib|CryptoPkg/Library/TlsLib/TlsLib.inf
> 
> DebugPrintErrorLevelLib|MdePkg/Library/BaseDebugPrintErrorLevelLib/Base
> DebugPrintErrorLevelLib.inf
>FileHandleLib|MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.inf
>SortLib|MdeModulePkg/Library/UefiSortLib/UefiSortLib.inf
> 
>  [LibraryClasses.common.UEFI_DRIVER]
> @@ -103,10 +105,11 @@
>NetworkPkg/Mtftp6Dxe/Mtftp6Dxe.inf
>NetworkPkg/DnsDxe/DnsDxe.inf
>NetworkPkg/HttpDxe/HttpDxe.inf
>NetworkPkg/HttpUtilitiesDxe/HttpUtilitiesDxe.inf
>NetworkPkg/HttpBootDxe/HttpBootDxe.inf
> +  NetworkPkg/TlsDxe/TlsDxe.inf
> 
>NetworkPkg/Application/IfConfig6/IfConfig6.inf
>NetworkPkg/Application/IpsecConfig/IpSecConfig.inf
>NetworkPkg/Application/VConfig/VConfig.inf
> 
> diff --git a/NetworkPkg/TlsDxe/TlsConfigProtocol.c
> b/NetworkPkg/TlsDxe/TlsConfigProtocol.c
> new file mode 100644
> index 000..2855be1
> --- /dev/null
> +++ b/NetworkPkg/TlsDxe/TlsConfigProtocol.c
> @@ -0,0 +1,152 @@
> +/** @file
> +  Implementation of EFI TLS Configuration Protocol Interfaces.
> +
> +  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.
> +
> +**/
> +
> +#include "TlsImpl.h"
> +
> +EFI_TLS_CONFIGURATION_PROTOCOL  mTlsConfigurationProtocol = {
> +  TlsConfigurationSetData,
> +  TlsConfigurationGetData
> +};
> +
> +/**
> +  Set TLS configuration data.
> +
> +  The SetData() function sets TLS configuration to non-volatile storage or
> volatile
> +  storage.
> +
> +  @param[in]  ThisPointer to the
> EFI_TLS_CONFIGURATION_PROTOCOL instance.
> +  @param[in]  DataTypeConfiguration data type.
> +  @param[in]  DataPointer to configuration data.
> +  @param[in]  DataSizeTotal size of configuration data.
> +
> +  @retval EFI_SUCCESS The TLS configuration data is set 
> successfully.
> +  @retval EFI_INVALID_PARAMETER   One or more of the following
> conditions is TRUE:
> +  This is NULL.
> +  Data is NULL.
> +  DataSize is 0.
> +  @retval EFI_UNSUPPORTED The DataType is unsupported.
> +  @retval EFI_OUT_OF_RESOURCESRequired system resources could not
> be allocated.
> +
> +**/
> +EFI_STATUS
> +EFIAPI
> +TlsConfigurationSetData (
> +  IN EFI_TL