]> git.proxmox.com Git - mirror_edk2.git/commitdiff
CryptoPkg/TlsLib: Change the return type of TlsInitialize().
authorJiaxin Wu <jiaxin.wu@intel.com>
Fri, 17 Nov 2017 03:50:11 +0000 (11:50 +0800)
committerJiaxin Wu <jiaxin.wu@intel.com>
Fri, 24 Nov 2017 00:46:20 +0000 (08:46 +0800)
V2:
* Correct the commit log.

Currently, the return code of OPENSSL_init_ssl(0 or 1) and RandomSeed
(TRUE or FALSE) are not checked in TlsInitialize(). Also "VOID" is used
as the return type of TlsInitialize(), which can't be used to capture
the returned value for 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 <ting.ye@intel.com>
Cc: Long Qin <qin.long@intel.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin <jiaxin.wu@intel.com>
Reviewed-by: Long Qin <qin.long@intel.com>
CryptoPkg/Include/Library/TlsLib.h
CryptoPkg/Library/TlsLib/TlsInit.c

index fa6cb99d789699d67101cd8481bb6f7cbd241eeb..b69d5132850a34ab1770a361778d73a94a23b99c 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Defines TLS Library APIs.\r
 \r
-Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -22,8 +22,11 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
   by SSL/TLS, and initializes the readable error messages.\r
   This function must be called before any other action takes places.\r
 \r
+  @retval TRUE   The OpenSSL library has been initialized.\r
+  @retval FALSE  Failed to initialize the OpenSSL library.\r
+\r
 **/\r
-VOID\r
+BOOLEAN\r
 EFIAPI\r
 TlsInitialize (\r
   VOID\r
index e524647103f96d0f47cb11d9485bc54b0109d3e3..a530ff7ad5d5be08da6a6c7563932b9ca5463c8d 100644 (file)
@@ -22,26 +22,34 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
   by SSL/TLS, and initializes the readable error messages.\r
   This function must be called before any other action takes places.\r
 \r
+  @retval TRUE   The OpenSSL library has been initialized.\r
+  @retval FALSE  Failed to initialize the OpenSSL library.\r
+\r
 **/\r
-VOID\r
+BOOLEAN\r
 EFIAPI\r
 TlsInitialize (\r
   VOID\r
   )\r
 {\r
+  INTN            Ret;\r
+\r
   //\r
   // Performs initialization of crypto and ssl library, and loads required\r
   // algorithms.\r
   //\r
-  OPENSSL_init_ssl (\r
-    OPENSSL_INIT_LOAD_SSL_STRINGS | OPENSSL_INIT_LOAD_CRYPTO_STRINGS,\r
-    NULL\r
-    );\r
+  Ret = OPENSSL_init_ssl (\r
+          OPENSSL_INIT_LOAD_SSL_STRINGS | OPENSSL_INIT_LOAD_CRYPTO_STRINGS,\r
+          NULL\r
+          );\r
+  if (Ret != 1) {\r
+    return FALSE;\r
+  }\r
 \r
   //\r
   // Initialize the pseudorandom number generator.\r
   //\r
-  RandomSeed (NULL, 0);\r
+  return RandomSeed (NULL, 0);\r
 }\r
 \r
 /**\r