]> git.proxmox.com Git - mirror_edk2.git/commitdiff
CryptoPkg/BaseCryptLib: Add X509ConstructCertificateStackV().
authorMichael D Kinney <michael.d.kinney@intel.com>
Thu, 21 Nov 2019 01:14:16 +0000 (17:14 -0800)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Fri, 7 Feb 2020 16:32:13 +0000 (16:32 +0000)
https://bugzilla.tianocore.org/show_bug.cgi?id=2420

Add X509ConstructCertificateStackV() to BaseCryptLib that is
identical in behavior to X509ConstructCertificateStack(), but
it takes a VA_LIST parameter for the variable argument list.

The VA_LIST form of this function is required for BaseCryptLib
functions to be wrapped in a Protocol/PPI.

Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Xiaoyu Lu <xiaoyux.lu@intel.com>
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: Jian J Wang <jian.j.wang@intel.com>
CryptoPkg/Include/Library/BaseCryptLib.h
CryptoPkg/Library/BaseCryptLib/Pk/CryptX509.c
CryptoPkg/Library/BaseCryptLib/Pk/CryptX509Null.c
CryptoPkg/Library/BaseCryptLibNull/Pk/CryptX509Null.c

index 8320fddc4cfdfa5c1b5a726763cf35743968ff01..5e8f2e0a10bf45c653f6b010e8ece7c656278b92 100644 (file)
@@ -2371,6 +2371,32 @@ X509ConstructCertificate (
   OUT  UINT8        **SingleX509Cert\r
   );\r
 \r
+/**\r
+  Construct a X509 stack object from a list of DER-encoded certificate data.\r
+\r
+  If X509Stack is NULL, then return FALSE.\r
+  If this interface is not supported, then return FALSE.\r
+\r
+  @param[in, out]  X509Stack  On input, pointer to an existing or NULL X509 stack object.\r
+                              On output, pointer to the X509 stack object with new\r
+                              inserted X509 certificate.\r
+  @param[in]       Args       VA_LIST marker for the variable argument list.\r
+                              A list of DER-encoded single certificate data followed\r
+                              by certificate size. A NULL terminates the list. The\r
+                              pairs are the arguments to X509ConstructCertificate().\r
+\r
+  @retval     TRUE            The X509 stack construction succeeded.\r
+  @retval     FALSE           The construction operation failed.\r
+  @retval     FALSE           This interface is not supported.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+X509ConstructCertificateStackV (\r
+  IN OUT  UINT8    **X509Stack,\r
+  IN      VA_LIST  Args\r
+  );\r
+\r
 /**\r
   Construct a X509 stack object from a list of DER-encoded certificate data.\r
 \r
index 9b5579e71a7550fedbc2f18ebf546e322ba6cd4e..b1393a89c5abb8de7f219737c3c948bc5bc63645 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   X.509 Certificate Handler Wrapper Implementation over OpenSSL.\r
 \r
-Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2010 - 2020, Intel Corporation. All rights reserved.<BR>\r
 SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
 **/\r
@@ -60,23 +60,26 @@ X509ConstructCertificate (
   Construct a X509 stack object from a list of DER-encoded certificate data.\r
 \r
   If X509Stack is NULL, then return FALSE.\r
+  If this interface is not supported, then return FALSE.\r
 \r
   @param[in, out]  X509Stack  On input, pointer to an existing or NULL X509 stack object.\r
                               On output, pointer to the X509 stack object with new\r
                               inserted X509 certificate.\r
-  @param           ...        A list of DER-encoded single certificate data followed\r
+  @param[in]       Args       VA_LIST marker for the variable argument list.\r
+                              A list of DER-encoded single certificate data followed\r
                               by certificate size. A NULL terminates the list. The\r
                               pairs are the arguments to X509ConstructCertificate().\r
 \r
   @retval     TRUE            The X509 stack construction succeeded.\r
   @retval     FALSE           The construction operation failed.\r
+  @retval     FALSE           This interface is not supported.\r
 \r
 **/\r
 BOOLEAN\r
 EFIAPI\r
-X509ConstructCertificateStack (\r
-  IN OUT  UINT8  **X509Stack,\r
-  ...\r
+X509ConstructCertificateStackV (\r
+  IN OUT  UINT8    **X509Stack,\r
+  IN      VA_LIST  Args\r
   )\r
 {\r
   UINT8           *Cert;\r
@@ -84,7 +87,6 @@ X509ConstructCertificateStack (
   X509            *X509Cert;\r
   STACK_OF(X509)  *CertStack;\r
   BOOLEAN         Status;\r
-  VA_LIST         Args;\r
   UINTN           Index;\r
 \r
   //\r
@@ -107,8 +109,6 @@ X509ConstructCertificateStack (
     }\r
   }\r
 \r
-  VA_START (Args, X509Stack);\r
-\r
   for (Index = 0; ; Index++) {\r
     //\r
     // If Cert is NULL, then it is the end of the list.\r
@@ -145,8 +145,6 @@ X509ConstructCertificateStack (
     sk_X509_push (CertStack, X509Cert);\r
   }\r
 \r
-  VA_END (Args);\r
-\r
   if (!Status) {\r
     sk_X509_pop_free (CertStack, X509_free);\r
   } else {\r
@@ -156,6 +154,38 @@ X509ConstructCertificateStack (
   return Status;\r
 }\r
 \r
+/**\r
+  Construct a X509 stack object from a list of DER-encoded certificate data.\r
+\r
+  If X509Stack is NULL, then return FALSE.\r
+\r
+  @param[in, out]  X509Stack  On input, pointer to an existing or NULL X509 stack object.\r
+                              On output, pointer to the X509 stack object with new\r
+                              inserted X509 certificate.\r
+  @param           ...        A list of DER-encoded single certificate data followed\r
+                              by certificate size. A NULL terminates the list. The\r
+                              pairs are the arguments to X509ConstructCertificate().\r
+\r
+  @retval     TRUE            The X509 stack construction succeeded.\r
+  @retval     FALSE           The construction operation failed.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+X509ConstructCertificateStack (\r
+  IN OUT  UINT8  **X509Stack,\r
+  ...\r
+  )\r
+{\r
+  VA_LIST  Args;\r
+  BOOLEAN  Result;\r
+\r
+  VA_START (Args, X509Stack);\r
+  Result = X509ConstructCertificateStackV (X509Stack, Args);\r
+  VA_END (Args);\r
+  return Result;\r
+}\r
+\r
 /**\r
   Release the specified X509 object.\r
 \r
index 5e59cb1634b5f87c42cff401a97f8ef34b956894..14309825ed758139f9ff7349ccef45faca33a485 100644 (file)
@@ -2,7 +2,7 @@
   X.509 Certificate Handler Wrapper Implementation which does not provide\r
   real capabilities.\r
 \r
-Copyright (c) 2012 - 2018, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2012 - 2020, Intel Corporation. All rights reserved.<BR>\r
 SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
 **/\r
@@ -33,6 +33,36 @@ X509ConstructCertificate (
   return FALSE;\r
 }\r
 \r
+/**\r
+  Construct a X509 stack object from a list of DER-encoded certificate data.\r
+\r
+  If X509Stack is NULL, then return FALSE.\r
+  If this interface is not supported, then return FALSE.\r
+\r
+  @param[in, out]  X509Stack  On input, pointer to an existing or NULL X509 stack object.\r
+                              On output, pointer to the X509 stack object with new\r
+                              inserted X509 certificate.\r
+  @param[in]       Args       VA_LIST marker for the variable argument list.\r
+                              A list of DER-encoded single certificate data followed\r
+                              by certificate size. A NULL terminates the list. The\r
+                              pairs are the arguments to X509ConstructCertificate().\r
+\r
+  @retval     TRUE            The X509 stack construction succeeded.\r
+  @retval     FALSE           The construction operation failed.\r
+  @retval     FALSE           This interface is not supported.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+X509ConstructCertificateStackV (\r
+  IN OUT  UINT8    **X509Stack,\r
+  IN      VA_LIST  Args\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return FALSE;\r
+}\r
+\r
 /**\r
   Construct a X509 stack object from a list of DER-encoded certificate data.\r
 \r
index 5e59cb1634b5f87c42cff401a97f8ef34b956894..14309825ed758139f9ff7349ccef45faca33a485 100644 (file)
@@ -2,7 +2,7 @@
   X.509 Certificate Handler Wrapper Implementation which does not provide\r
   real capabilities.\r
 \r
-Copyright (c) 2012 - 2018, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2012 - 2020, Intel Corporation. All rights reserved.<BR>\r
 SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
 **/\r
@@ -33,6 +33,36 @@ X509ConstructCertificate (
   return FALSE;\r
 }\r
 \r
+/**\r
+  Construct a X509 stack object from a list of DER-encoded certificate data.\r
+\r
+  If X509Stack is NULL, then return FALSE.\r
+  If this interface is not supported, then return FALSE.\r
+\r
+  @param[in, out]  X509Stack  On input, pointer to an existing or NULL X509 stack object.\r
+                              On output, pointer to the X509 stack object with new\r
+                              inserted X509 certificate.\r
+  @param[in]       Args       VA_LIST marker for the variable argument list.\r
+                              A list of DER-encoded single certificate data followed\r
+                              by certificate size. A NULL terminates the list. The\r
+                              pairs are the arguments to X509ConstructCertificate().\r
+\r
+  @retval     TRUE            The X509 stack construction succeeded.\r
+  @retval     FALSE           The construction operation failed.\r
+  @retval     FALSE           This interface is not supported.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+X509ConstructCertificateStackV (\r
+  IN OUT  UINT8    **X509Stack,\r
+  IN      VA_LIST  Args\r
+  )\r
+{\r
+  ASSERT (FALSE);\r
+  return FALSE;\r
+}\r
+\r
 /**\r
   Construct a X509 stack object from a list of DER-encoded certificate data.\r
 \r