Blame SOURCES/edk2-CryptoPkg-TlsLib-Add-the-new-API-TlsSetVerifyHost-CV.patch

6009e6
From 3885ce313d1d06359aa76b085668c1391d8a5f50 Mon Sep 17 00:00:00 2001
6009e6
From: Laszlo Ersek <lersek@redhat.com>
6009e6
Date: Mon, 2 Dec 2019 12:31:43 +0100
6009e6
Subject: [PATCH 2/9] CryptoPkg/TlsLib: Add the new API "TlsSetVerifyHost"
6009e6
 (CVE-2019-14553)
6009e6
MIME-Version: 1.0
6009e6
Content-Type: text/plain; charset=UTF-8
6009e6
Content-Transfer-Encoding: 8bit
6009e6
6009e6
RH-Author: Laszlo Ersek <lersek@redhat.com>
6009e6
Message-id: <20191117220052.15700-3-lersek@redhat.com>
6009e6
Patchwork-id: 92460
6009e6
O-Subject: [RHEL-8.2.0 edk2 PATCH 2/9] CryptoPkg/TlsLib: Add the new API "TlsSetVerifyHost" (CVE-2019-14553)
6009e6
Bugzilla: 1536624
6009e6
RH-Acked-by: Philippe Mathieu-Daudé <philmd@redhat.com>
6009e6
RH-Acked-by: Vitaly Kuznetsov <vkuznets@redhat.com>
6009e6
6009e6
From: "Wu, Jiaxin" <jiaxin.wu@intel.com>
6009e6
6009e6
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=960
6009e6
CVE: CVE-2019-14553
6009e6
In the patch, we add the new API "TlsSetVerifyHost" for the TLS
6009e6
protocol to set the specified host name that need to be verified.
6009e6
6009e6
Signed-off-by: Wu Jiaxin <jiaxin.wu@intel.com>
6009e6
Reviewed-by: Ye Ting <ting.ye@intel.com>
6009e6
Reviewed-by: Long Qin <qin.long@intel.com>
6009e6
Reviewed-by: Fu Siyuan <siyuan.fu@intel.com>
6009e6
Acked-by: Laszlo Ersek <lersek@redhat.com>
6009e6
Message-Id: <20190927034441.3096-3-Jiaxin.wu@intel.com>
6009e6
Cc: David Woodhouse <dwmw2@infradead.org>
6009e6
Cc: Jian J Wang <jian.j.wang@intel.com>
6009e6
Cc: Jiaxin Wu <jiaxin.wu@intel.com>
6009e6
Cc: Sivaraman Nainar <sivaramann@amiindia.co.in>
6009e6
Cc: Xiaoyu Lu <xiaoyux.lu@intel.com>
6009e6
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
6009e6
Reviewed-by: Philippe Mathieu-Daude <philmd@redhat.com>
6009e6
Reviewed-by: Jian J Wang <jian.j.wang@intel.com>
6009e6
(cherry picked from commit 2ca74e1a175232cc201798e27437700adc7fb07e)
6009e6
---
6009e6
 CryptoPkg/Include/Library/TlsLib.h   | 20 +++++++++++++++++++
6009e6
 CryptoPkg/Library/TlsLib/TlsConfig.c | 38 +++++++++++++++++++++++++++++++++++-
6009e6
 2 files changed, 57 insertions(+), 1 deletion(-)
6009e6
6009e6
diff --git a/CryptoPkg/Include/Library/TlsLib.h b/CryptoPkg/Include/Library/TlsLib.h
6009e6
index 9875cb6..3af7d4b 100644
6009e6
--- a/CryptoPkg/Include/Library/TlsLib.h
6009e6
+++ b/CryptoPkg/Include/Library/TlsLib.h
6009e6
@@ -397,6 +397,26 @@ TlsSetVerify (
6009e6
   );
6009e6
 
6009e6
 /**
6009e6
+  Set the specified host name to be verified.
6009e6
+
6009e6
+  @param[in]  Tls           Pointer to the TLS object.
6009e6
+  @param[in]  Flags         The setting flags during the validation.
6009e6
+  @param[in]  HostName      The specified host name to be verified.
6009e6
+
6009e6
+  @retval  EFI_SUCCESS           The HostName setting was set successfully.
6009e6
+  @retval  EFI_INVALID_PARAMETER The parameter is invalid.
6009e6
+  @retval  EFI_ABORTED           Invalid HostName setting.
6009e6
+
6009e6
+**/
6009e6
+EFI_STATUS
6009e6
+EFIAPI
6009e6
+TlsSetVerifyHost (
6009e6
+  IN     VOID                     *Tls,
6009e6
+  IN     UINT32                   Flags,
6009e6
+  IN     CHAR8                    *HostName
6009e6
+  );
6009e6
+
6009e6
+/**
6009e6
   Sets a TLS/SSL session ID to be used during TLS/SSL connect.
6009e6
 
6009e6
   This function sets a session ID to be used when the TLS/SSL connection is
6009e6
diff --git a/CryptoPkg/Library/TlsLib/TlsConfig.c b/CryptoPkg/Library/TlsLib/TlsConfig.c
6009e6
index 74b577d..2bf5aee 100644
6009e6
--- a/CryptoPkg/Library/TlsLib/TlsConfig.c
6009e6
+++ b/CryptoPkg/Library/TlsLib/TlsConfig.c
6009e6
@@ -1,7 +1,7 @@
6009e6
 /** @file
6009e6
   SSL/TLS Configuration Library Wrapper Implementation over OpenSSL.
6009e6
 
6009e6
-Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.
6009e6
+Copyright (c) 2016 - 2018, Intel Corporation. All rights reserved.
6009e6
 (C) Copyright 2016 Hewlett Packard Enterprise Development LP
6009e6
 SPDX-License-Identifier: BSD-2-Clause-Patent
6009e6
 
6009e6
@@ -498,6 +498,42 @@ TlsSetVerify (
6009e6
 }
6009e6
 
6009e6
 /**
6009e6
+  Set the specified host name to be verified.
6009e6
+
6009e6
+  @param[in]  Tls           Pointer to the TLS object.
6009e6
+  @param[in]  Flags         The setting flags during the validation.
6009e6
+  @param[in]  HostName      The specified host name to be verified.
6009e6
+
6009e6
+  @retval  EFI_SUCCESS           The HostName setting was set successfully.
6009e6
+  @retval  EFI_INVALID_PARAMETER The parameter is invalid.
6009e6
+  @retval  EFI_ABORTED           Invalid HostName setting.
6009e6
+
6009e6
+**/
6009e6
+EFI_STATUS
6009e6
+EFIAPI
6009e6
+TlsSetVerifyHost (
6009e6
+  IN     VOID                     *Tls,
6009e6
+  IN     UINT32                   Flags,
6009e6
+  IN     CHAR8                    *HostName
6009e6
+  )
6009e6
+{
6009e6
+  TLS_CONNECTION  *TlsConn;
6009e6
+
6009e6
+  TlsConn = (TLS_CONNECTION *) Tls;
6009e6
+  if (TlsConn == NULL || TlsConn->Ssl == NULL || HostName == NULL) {
6009e6
+     return EFI_INVALID_PARAMETER;
6009e6
+  }
6009e6
+
6009e6
+  SSL_set_hostflags(TlsConn->Ssl, Flags);
6009e6
+
6009e6
+  if (SSL_set1_host(TlsConn->Ssl, HostName) == 0) {
6009e6
+    return EFI_ABORTED;
6009e6
+  }
6009e6
+
6009e6
+  return EFI_SUCCESS;
6009e6
+}
6009e6
+
6009e6
+/**
6009e6
   Sets a TLS/SSL session ID to be used during TLS/SSL connect.
6009e6
 
6009e6
   This function sets a session ID to be used when the TLS/SSL connection is
6009e6
-- 
6009e6
1.8.3.1
6009e6