From 99c798d87a94838be62976cb1632e7d0a9550df3 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Tue, 8 May 2012 10:57:50 +0100 Subject: [crypto] Add x509_append_raw() Signed-off-by: Michael Brown --- src/include/ipxe/x509.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/include') diff --git a/src/include/ipxe/x509.h b/src/include/ipxe/x509.h index b9db20479..78b180c99 100644 --- a/src/include/ipxe/x509.h +++ b/src/include/ipxe/x509.h @@ -261,6 +261,20 @@ x509_first ( struct x509_chain *chain ) { return ( link ? link->cert : NULL ); } +/** + * Get last certificate in X.509 certificate chain + * + * @v chain X.509 certificate chain + * @ret cert X.509 certificate, or NULL + */ +static inline __attribute__ (( always_inline )) struct x509_certificate * +x509_last ( struct x509_chain *chain ) { + struct x509_link *link; + + link = list_last_entry ( &chain->links, struct x509_link, list ); + return ( link ? link->cert : NULL ); +} + /** An X.509 extension */ struct x509_extension { /** Name */ @@ -319,6 +333,8 @@ extern int x509_certificate ( const void *data, size_t len, extern struct x509_chain * x509_alloc_chain ( void ); extern int x509_append ( struct x509_chain *chain, struct x509_certificate *cert ); +extern int x509_append_raw ( struct x509_chain *chain, const void *data, + size_t len ); extern int x509_validate_chain ( struct x509_chain *chain, time_t time, struct x509_root *root ); -- cgit v1.2.3-55-g7522