diff options
author | Michael Brown <mcb30@ipxe.org> | 2020-12-09 16:19:03 +0000 |
---|---|---|
committer | Michael Brown <mcb30@ipxe.org> | 2020-12-09 16:45:50 +0000 |
commit | 3475f9162b84ce21327244ebce20ae29db6d7ac8 (patch) | |
tree | 39f7a31165e66cf82d92f5d8d536e9b18b248c76 /src/include/ipxe | |
parent | e3eedb0be581b7f3df70e8150c7adfcf275506b8 (diff) | |
download | ipxe-3475f9162b84ce21327244ebce20ae29db6d7ac8.tar.gz |
[x509] Make root of trust a reference-counted structure
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/include/ipxe')
-rw-r--r-- | src/include/ipxe/x509.h | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/src/include/ipxe/x509.h b/src/include/ipxe/x509.h index cac2f19f0..c703c8f10 100644 --- a/src/include/ipxe/x509.h +++ b/src/include/ipxe/x509.h @@ -340,8 +340,10 @@ struct x509_access_method { const struct asn1_cursor *raw ); }; -/** An X.509 root certificate store */ +/** An X.509 root certificate list */ struct x509_root { + /** Reference count */ + struct refcnt refcnt; /** Fingerprint digest algorithm */ struct digest_algorithm *digest; /** Number of certificates */ @@ -350,6 +352,28 @@ struct x509_root { const void *fingerprints; }; +/** + * Get reference to X.509 root certificate list + * + * @v root X.509 root certificate list + * @ret root X.509 root certificate list + */ +static inline __attribute__ (( always_inline )) struct x509_root * +x509_root_get ( struct x509_root *root ) { + ref_get ( &root->refcnt ); + return root; +} + +/** + * Drop reference to X.509 root certificate list + * + * @v root X.509 root certificate list + */ +static inline __attribute__ (( always_inline )) void +x509_root_put ( struct x509_root *root ) { + ref_put ( &root->refcnt ); +} + extern const char * x509_name ( struct x509_certificate *cert ); extern int x509_parse ( struct x509_certificate *cert, const struct asn1_cursor *raw ); @@ -391,6 +415,7 @@ extern int x509_check_time ( struct x509_certificate *cert, time_t time ); * @v cert X.509 certificate */ static inline void x509_invalidate ( struct x509_certificate *cert ) { + x509_root_put ( cert->root ); cert->root = NULL; cert->path_remaining = 0; } |