Skip to content

Commit 2ca74e1

Browse files
Wu, JiaxinLaszlo Ersek
authored andcommitted
CryptoPkg/TlsLib: Add the new API "TlsSetVerifyHost" (CVE-2019-14553)
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=960 CVE: CVE-2019-14553 In the patch, we add the new API "TlsSetVerifyHost" for the TLS protocol to set the specified host name that need to be verified. Signed-off-by: Wu Jiaxin <[email protected]> Reviewed-by: Ye Ting <[email protected]> Reviewed-by: Long Qin <[email protected]> Reviewed-by: Fu Siyuan <[email protected]> Acked-by: Laszlo Ersek <[email protected]> Message-Id: <[email protected]> Cc: David Woodhouse <[email protected]> Cc: Jian J Wang <[email protected]> Cc: Jiaxin Wu <[email protected]> Cc: Sivaraman Nainar <[email protected]> Cc: Xiaoyu Lu <[email protected]> Signed-off-by: Laszlo Ersek <[email protected]> Reviewed-by: Philippe Mathieu-Daude <[email protected]> Reviewed-by: Jian J Wang <[email protected]>
1 parent 31efec8 commit 2ca74e1

File tree

2 files changed

+57
-1
lines changed

2 files changed

+57
-1
lines changed

CryptoPkg/Include/Library/TlsLib.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,26 @@ TlsSetVerify (
396396
IN UINT32 VerifyMode
397397
);
398398

399+
/**
400+
Set the specified host name to be verified.
401+
402+
@param[in] Tls Pointer to the TLS object.
403+
@param[in] Flags The setting flags during the validation.
404+
@param[in] HostName The specified host name to be verified.
405+
406+
@retval EFI_SUCCESS The HostName setting was set successfully.
407+
@retval EFI_INVALID_PARAMETER The parameter is invalid.
408+
@retval EFI_ABORTED Invalid HostName setting.
409+
410+
**/
411+
EFI_STATUS
412+
EFIAPI
413+
TlsSetVerifyHost (
414+
IN VOID *Tls,
415+
IN UINT32 Flags,
416+
IN CHAR8 *HostName
417+
);
418+
399419
/**
400420
Sets a TLS/SSL session ID to be used during TLS/SSL connect.
401421

CryptoPkg/Library/TlsLib/TlsConfig.c

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/** @file
22
SSL/TLS Configuration Library Wrapper Implementation over OpenSSL.
33
4-
Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.<BR>
4+
Copyright (c) 2016 - 2018, Intel Corporation. All rights reserved.<BR>
55
(C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>
66
SPDX-License-Identifier: BSD-2-Clause-Patent
77
@@ -497,6 +497,42 @@ TlsSetVerify (
497497
SSL_set_verify (TlsConn->Ssl, VerifyMode, NULL);
498498
}
499499

500+
/**
501+
Set the specified host name to be verified.
502+
503+
@param[in] Tls Pointer to the TLS object.
504+
@param[in] Flags The setting flags during the validation.
505+
@param[in] HostName The specified host name to be verified.
506+
507+
@retval EFI_SUCCESS The HostName setting was set successfully.
508+
@retval EFI_INVALID_PARAMETER The parameter is invalid.
509+
@retval EFI_ABORTED Invalid HostName setting.
510+
511+
**/
512+
EFI_STATUS
513+
EFIAPI
514+
TlsSetVerifyHost (
515+
IN VOID *Tls,
516+
IN UINT32 Flags,
517+
IN CHAR8 *HostName
518+
)
519+
{
520+
TLS_CONNECTION *TlsConn;
521+
522+
TlsConn = (TLS_CONNECTION *) Tls;
523+
if (TlsConn == NULL || TlsConn->Ssl == NULL || HostName == NULL) {
524+
return EFI_INVALID_PARAMETER;
525+
}
526+
527+
SSL_set_hostflags(TlsConn->Ssl, Flags);
528+
529+
if (SSL_set1_host(TlsConn->Ssl, HostName) == 0) {
530+
return EFI_ABORTED;
531+
}
532+
533+
return EFI_SUCCESS;
534+
}
535+
500536
/**
501537
Sets a TLS/SSL session ID to be used during TLS/SSL connect.
502538

0 commit comments

Comments
 (0)