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

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