aboutsummaryrefslogtreecommitdiffstats
path: root/src/crypto/x509.c
diff options
context:
space:
mode:
authorMichael Brown <mcb30@ipxe.org>2012-05-08 10:57:50 +0100
committerMichael Brown <mcb30@ipxe.org>2012-05-08 12:49:01 +0100
commit99c798d87a94838be62976cb1632e7d0a9550df3 (patch)
tree1284efc5b8a511f820dc72f4dbfa0f14a114048b /src/crypto/x509.c
parent6c8fcd4bb31d2c4da90e94d78363182d1e92a6c7 (diff)
downloadipxe-99c798d87a94838be62976cb1632e7d0a9550df3.tar.gz
[crypto] Add x509_append_raw()
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/crypto/x509.c')
-rw-r--r--src/crypto/x509.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/crypto/x509.c b/src/crypto/x509.c
index 356b60a36..c83cd2777 100644
--- a/src/crypto/x509.c
+++ b/src/crypto/x509.c
@@ -1647,6 +1647,38 @@ int x509_append ( struct x509_chain *chain, struct x509_certificate *cert ) {
}
/**
+ * Append X.509 certificate to X.509 certificate chain
+ *
+ * @v chain X.509 certificate chain
+ * @v data Raw certificate data
+ * @v len Length of raw data
+ * @ret rc Return status code
+ */
+int x509_append_raw ( struct x509_chain *chain, const void *data,
+ size_t len ) {
+ struct x509_certificate *cert;
+ int rc;
+
+ /* Parse certificate */
+ if ( ( rc = x509_certificate ( data, len, &cert ) ) != 0 )
+ goto err_parse;
+
+ /* Append certificate to chain */
+ if ( ( rc = x509_append ( chain, cert ) ) != 0 )
+ goto err_append;
+
+ /* Drop reference to certificate */
+ x509_put ( cert );
+
+ return 0;
+
+ err_append:
+ x509_put ( cert );
+ err_parse:
+ return rc;
+}
+
+/**
* Validate X.509 certificate chain
*
* @v chain X.509 certificate chain