From 943d75b557a8bf857d651e8116a7368b9d284e41 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Thu, 15 Feb 2024 12:43:51 +0000 Subject: [crypto] Add x509_is_self_signed() helper function Signed-off-by: Michael Brown --- src/include/ipxe/x509.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/include/ipxe/x509.h') diff --git a/src/include/ipxe/x509.h b/src/include/ipxe/x509.h index 5cad4597d..d2ba49fbb 100644 --- a/src/include/ipxe/x509.h +++ b/src/include/ipxe/x509.h @@ -374,6 +374,16 @@ x509_root_put ( struct x509_root *root ) { ref_put ( &root->refcnt ); } +/** + * Check if X.509 certificate is self-signed + * + * @v cert X.509 certificate + * @ret is_self_signed X.509 certificate is self-signed + */ +static inline int x509_is_self_signed ( struct x509_certificate *cert ) { + return ( asn1_compare ( &cert->issuer.raw, &cert->subject.raw ) == 0 ); +} + extern const char * x509_name ( struct x509_certificate *cert ); extern int x509_parse ( struct x509_certificate *cert, const struct asn1_cursor *raw ); -- cgit