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>
/** @file\r
Defines TLS Library APIs.\r
\r
/** @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
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
by SSL/TLS, and initializes the readable error messages.\r
This function must be called before any other action takes places.\r
\r
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
EFIAPI\r
TlsInitialize (\r
VOID\r
EFIAPI\r
TlsInitialize (\r
VOID\r
by SSL/TLS, and initializes the readable error messages.\r
This function must be called before any other action takes places.\r
\r
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
EFIAPI\r
TlsInitialize (\r
VOID\r
)\r
{\r
EFIAPI\r
TlsInitialize (\r
VOID\r
)\r
{\r
//\r
// Performs initialization of crypto and ssl library, and loads required\r
// algorithms.\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
\r
//\r
// Initialize the pseudorandom number generator.\r
//\r
- RandomSeed (NULL, 0);\r
+ return RandomSeed (NULL, 0);\r