From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.100; helo=mga07.intel.com; envelope-from=qin.long@intel.com; receiver=edk2-devel@lists.01.org Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id E982021A134A8 for ; Mon, 20 Nov 2017 17:52:09 -0800 (PST) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 20 Nov 2017 17:56:24 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.44,431,1505804400"; d="scan'208";a="4122126" Received: from fmsmsx104.amr.corp.intel.com ([10.18.124.202]) by fmsmga004.fm.intel.com with ESMTP; 20 Nov 2017 17:56:24 -0800 Received: from fmsmsx151.amr.corp.intel.com (10.18.125.4) by fmsmsx104.amr.corp.intel.com (10.18.124.202) with Microsoft SMTP Server (TLS) id 14.3.319.2; Mon, 20 Nov 2017 17:56:23 -0800 Received: from shsmsx151.ccr.corp.intel.com (10.239.6.50) by FMSMSX151.amr.corp.intel.com (10.18.125.4) with Microsoft SMTP Server (TLS) id 14.3.319.2; Mon, 20 Nov 2017 17:56:23 -0800 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.213]) by SHSMSX151.ccr.corp.intel.com ([169.254.3.218]) with mapi id 14.03.0319.002; Tue, 21 Nov 2017 09:56:21 +0800 From: "Long, Qin" To: "Wu, Jiaxin" , "edk2-devel@lists.01.org" CC: "Ye, Ting" , "Fu, Siyuan" Thread-Topic: [Patch] CryptoPkg/TlsLib: Change the return type of TlsInitialize(). Thread-Index: AQHTX1gu3NwDeDfIlE+ShBOq95mP86MeGRDQ Date: Tue, 21 Nov 2017 01:56:20 +0000 Message-ID: References: <1510891025-13168-1-git-send-email-jiaxin.wu@intel.com> In-Reply-To: <1510891025-13168-1-git-send-email-jiaxin.wu@intel.com> Accept-Language: zh-CN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiZGNiYzZmNmEtMWZmMy00ZDhkLWI5NWYtY2M0Y2I5NjBmYmMyIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjIuNS4xOCIsIlRydXN0ZWRMYWJlbEhhc2giOiJFUmlLY1JVcUNGeDJkUXFBRCt3RlJhUEQzajI1Z1ZkV0VYOXB0VWdBbjM3clNLYkJFdW0wYWpzR0Z0TzVTSDFQIn0= x-ctpclassification: CTP_IC dlp-product: dlpe-windows dlp-version: 11.0.0.116 dlp-reaction: no-action x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [Patch] CryptoPkg/TlsLib: Change the return type of TlsInitialize(). X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 21 Nov 2017 01:52:10 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Long Qin Best Regards & Thanks, LONG, Qin -----Original Message----- From: Wu, Jiaxin=20 Sent: Friday, November 17, 2017 11:57 AM To: edk2-devel@lists.01.org Cc: Ye, Ting ; Long, Qin ; Fu, Siyua= n ; Wu, Jiaxin Subject: [Patch] CryptoPkg/TlsLib: Change the return type of TlsInitialize(= ). Currently, in TlsInitialize(), neither the return status of OPENSSL_init_ss= l(0, or 1) nor the return code of RandomSeed (TRUE or FALSE) is not checked= . Also VOID is used as the return type of TlsInitialize(), which can't be u= sed to capture the returned value for the error handling. >>From Long Qin (CryptoPkg owner): The early version of OPENSSL_init_ssl() use the "VOID" as the return value,= which was updated to "int" later because the function changes can fail. So, this patch is to change the return type of TlsInitialize() to follow up= the OPENSSL_init_ssl() update. Cc: Ye Ting Cc: Long Qin Cc: Fu Siyuan Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Wu Jiaxin --- CryptoPkg/Include/Library/TlsLib.h | 7 +++++-- CryptoPkg/Library/TlsLib/= TlsInit.c | 20 ++++++++++++++------ 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/CryptoPkg/Include/Library/TlsLib.h b/CryptoPkg/Include/Library= /TlsLib.h index fa6cb99..b69d513 100644 --- a/CryptoPkg/Include/Library/TlsLib.h +++ b/CryptoPkg/Include/Library/TlsLib.h @@ -1,9 +1,9 @@ /** @file Defines TLS Library APIs. =20 -Copyright (c) 2016, Intel Corporation. All rights reserved.
+Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made availab= le under the terms and conditions of the BSD License which accompanies thi= s distribution. The full text of the license may be found at http://opens= ource.org/licenses/bsd-license.php =20 @@ -20,12 +20,15 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITH= ER EXPRESS OR IMPLIED. =20 This function registers ciphers and digests used directly and indirectly by SSL/TLS, and initializes the readable error messages. This function must be called before any other action takes places. =20 + @retval TRUE The OpenSSL library has been initialized. + @retval FALSE Failed to initialize the OpenSSL library. + **/ -VOID +BOOLEAN EFIAPI TlsInitialize ( VOID ); =20 diff --git a/CryptoPkg/Library/TlsLib/TlsInit.c b/CryptoPkg/Library/TlsLib/= TlsInit.c index e524647..a530ff7 100644 --- a/CryptoPkg/Library/TlsLib/TlsInit.c +++ b/CryptoPkg/Library/TlsLib/TlsInit.c @@ -20,30 +20,38 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITH= ER EXPRESS OR IMPLIED. =20 This function registers ciphers and digests used directly and indirectly by SSL/TLS, and initializes the readable error messages. This function must be called before any other action takes places. =20 + @retval TRUE The OpenSSL library has been initialized. + @retval FALSE Failed to initialize the OpenSSL library. + **/ -VOID +BOOLEAN EFIAPI TlsInitialize ( VOID ) { + INTN Ret; + // // Performs initialization of crypto and ssl library, and loads required // algorithms. // - OPENSSL_init_ssl ( - OPENSSL_INIT_LOAD_SSL_STRINGS | OPENSSL_INIT_LOAD_CRYPTO_STRINGS, - NULL - ); + Ret =3D OPENSSL_init_ssl ( + OPENSSL_INIT_LOAD_SSL_STRINGS | OPENSSL_INIT_LOAD_CRYPTO_STRINGS= , + NULL + ); + if (Ret !=3D 1) { + return FALSE; + } =20 // // Initialize the pseudorandom number generator. // - RandomSeed (NULL, 0); + return RandomSeed (NULL, 0); } =20 /** Free an allocated SSL_CTX object. =20 -- 1.9.5.msysgit.1