* [PATCH EDK2 v1 0/1] CryptoPkg/BaseCryptLib: Support PEM certification
@ 2021-11-09 12:58 wenyi,xie
2021-11-09 12:58 ` [PATCH EDK2 v1 1/1] " wenyi,xie
0 siblings, 1 reply; 2+ messages in thread
From: wenyi,xie @ 2021-11-09 12:58 UTC (permalink / raw)
To: devel, jiewen.yao, jian.j.wang, xiaoyux.lu, guomin.jiang
Cc: songdongkuang, xiewenyi2, xujiaxia
Main Changes :
1.add support for PEM-encoded certificate.
Wenyi Xie (1):
CryptoPkg/BaseCryptLib: Support PEM certification
CryptoPkg/Library/BaseCryptLib/Pk/CryptX509.c | 33 ++++++++++++++++++--
1 file changed, 31 insertions(+), 2 deletions(-)
--
2.20.1.windows.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* [PATCH EDK2 v1 1/1] CryptoPkg/BaseCryptLib: Support PEM certification
2021-11-09 12:58 [PATCH EDK2 v1 0/1] CryptoPkg/BaseCryptLib: Support PEM certification wenyi,xie
@ 2021-11-09 12:58 ` wenyi,xie
0 siblings, 0 replies; 2+ messages in thread
From: wenyi,xie @ 2021-11-09 12:58 UTC (permalink / raw)
To: devel, jiewen.yao, jian.j.wang, xiaoyux.lu, guomin.jiang
Cc: songdongkuang, xiewenyi2, xujiaxia
As PEM-encoded certificate is also necessary, add
support for PEM-encoded certificate in
X509ConstructCertificate.
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Xiaoyu Lu <xiaoyux.lu@intel.com>
Cc: Guomin Jiang <guomin.jiang@intel.com>
Signed-off-by: Jiaxia Xu <xujiaxia@huawei.com>
Signed-off-by: Wenyi Xie <xiewenyi2@huawei.com>
---
CryptoPkg/Library/BaseCryptLib/Pk/CryptX509.c | 33 ++++++++++++++++++--
1 file changed, 31 insertions(+), 2 deletions(-)
diff --git a/CryptoPkg/Library/BaseCryptLib/Pk/CryptX509.c b/CryptoPkg/Library/BaseCryptLib/Pk/CryptX509.c
index b1393a89c5ab..db122cd574fa 100644
--- a/CryptoPkg/Library/BaseCryptLib/Pk/CryptX509.c
+++ b/CryptoPkg/Library/BaseCryptLib/Pk/CryptX509.c
@@ -9,6 +9,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include "InternalCryptLib.h"
#include <openssl/x509.h>
#include <openssl/rsa.h>
+#include <openssl/pem.h>
/**
Construct a X509 object from DER-encoded certificate data.
@@ -33,7 +34,12 @@ X509ConstructCertificate (
)
{
X509 *X509Cert;
+ BIO *BioCert;
CONST UINT8 *Temp;
+ BOOLEAN CertFlag;
+
+ BioCert = NULL;
+ CertFlag = TRUE;
//
// Check input parameters.
@@ -48,12 +54,35 @@ X509ConstructCertificate (
Temp = Cert;
X509Cert = d2i_X509 (NULL, &Temp, (long) CertSize);
if (X509Cert == NULL) {
- return FALSE;
+ BioCert = BIO_new (BIO_s_mem ());
+ if (BioCert == NULL) {
+ CertFlag = FALSE;
+ goto ON_EXIT;
+ }
+
+ if (BIO_write (BioCert, Temp, (UINT32) CertSize) <= 0) {
+ CertFlag = FALSE;
+ goto ON_EXIT;
+ }
+
+ //
+ // Read PEM-encoded X509 Certificate and Construct X509 object.
+ //
+ X509Cert = PEM_read_bio_X509 (BioCert, NULL, NULL, NULL);
+ if (X509Cert == NULL) {
+ CertFlag = FALSE;
+ goto ON_EXIT;
+ }
}
*SingleX509Cert = (UINT8 *) X509Cert;
- return TRUE;
+ON_EXIT:
+ if (BioCert != NULL) {
+ BIO_free (BioCert);
+ }
+
+ return CertFlag;
}
/**
--
2.20.1.windows.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-11-09 12:58 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-11-09 12:58 [PATCH EDK2 v1 0/1] CryptoPkg/BaseCryptLib: Support PEM certification wenyi,xie
2021-11-09 12:58 ` [PATCH EDK2 v1 1/1] " wenyi,xie
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox