iPXE
|
Certificate validator. More...
#include <string.h>
#include <stdio.h>
#include <errno.h>
#include <ipxe/refcnt.h>
#include <ipxe/malloc.h>
#include <ipxe/interface.h>
#include <ipxe/xfer.h>
#include <ipxe/open.h>
#include <ipxe/iobuf.h>
#include <ipxe/xferbuf.h>
#include <ipxe/process.h>
#include <ipxe/x509.h>
#include <ipxe/settings.h>
#include <ipxe/dhcp.h>
#include <ipxe/base64.h>
#include <ipxe/crc32.h>
#include <ipxe/ocsp.h>
#include <ipxe/job.h>
#include <ipxe/validator.h>
#include <config/crypto.h>
Go to the source code of this file.
Data Structures | |
struct | validator_action |
A certificate validator action. More... | |
struct | validator |
A certificate validator. More... | |
Functions | |
FILE_LICENCE (GPL2_OR_LATER_OR_UBDL) | |
static const char * | validator_name (struct validator *validator) |
Get validator name (for debug messages) More... | |
static void | validator_free (struct refcnt *refcnt) |
Free certificate validator. More... | |
static void | validator_finished (struct validator *validator, int rc) |
Mark certificate validation as finished. More... | |
static int | validator_progress (struct validator *validator, struct job_progress *progress) |
Report job progress. More... | |
const struct setting crosscert_setting | __setting (SETTING_CRYPTO, crosscert) |
Cross-signed certificate source setting. More... | |
static void | validator_append (struct validator *validator, int rc) |
Append cross-signing certificates to certificate chain. More... | |
static int | validator_start_download (struct validator *validator, struct x509_link *link) |
Start download of cross-signing certificate. More... | |
static void | validator_ocsp_validate (struct validator *validator, int rc) |
Validate OCSP response. More... | |
static int | validator_start_ocsp (struct validator *validator, struct x509_certificate *cert, struct x509_certificate *issuer) |
Start OCSP check. More... | |
static void | validator_xfer_close (struct validator *validator, int rc) |
Close data transfer interface. More... | |
static int | validator_xfer_deliver (struct validator *validator, struct io_buffer *iobuf, struct xfer_metadata *meta) |
Receive data. More... | |
static void | validator_step (struct validator *validator) |
Certificate validation process. More... | |
int | create_validator (struct interface *job, struct x509_chain *chain, struct x509_root *root) |
Instantiate a certificate validator. More... | |
Variables | |
static struct interface_operation | validator_job_operations [] |
Certificate validator job control interface operations. More... | |
static struct interface_descriptor | validator_job_desc |
Certificate validator job control interface descriptor. More... | |
static const char | crosscert_default [] = CROSSCERT |
Default cross-signed certificate source. More... | |
static const struct validator_action | validator_crosscert |
Cross-signing certificate download validator action. More... | |
static const struct validator_action | validator_ocsp |
OCSP validator action. More... | |
static struct interface_operation | validator_xfer_operations [] |
Certificate validator data transfer interface operations. More... | |
static struct interface_descriptor | validator_xfer_desc |
Certificate validator data transfer interface descriptor. More... | |
static struct process_descriptor | validator_process_desc |
Certificate validator process descriptor. More... | |
Certificate validator.
Definition in file validator.c.
FILE_LICENCE | ( | GPL2_OR_LATER_OR_UBDL | ) |
|
static |
Get validator name (for debug messages)
validator | Certificate validator |
name | Validator name |
Definition at line 137 of file validator.c.
References validator::chain, x509_first(), and x509_name().
Referenced by create_validator(), validator_append(), validator_free(), validator_ocsp_validate(), validator_start_download(), validator_start_ocsp(), validator_step(), validator_xfer_close(), and validator_xfer_deliver().
|
static |
Free certificate validator.
refcnt | Reference count |
Definition at line 150 of file validator.c.
References validator::buffer, validator::chain, container_of, DBGC2, free, validator::ocsp, ocsp_put(), validator::root, validator_name(), x509_chain_put(), x509_root_put(), and xferbuf_free().
Referenced by create_validator().
|
static |
Mark certificate validation as finished.
validator | Certificate validator |
rc | Reason for finishing |
Definition at line 169 of file validator.c.
References intf_shutdown(), validator::job, validator::process, process_del(), rc, and validator::xfer.
Referenced by create_validator(), and validator_step().
|
static |
Report job progress.
validator | Certificate validator |
progress | Progress report to fill in |
ongoing_rc | Ongoing job status code (if known) |
Definition at line 192 of file validator.c.
References validator::action, validator::cert, job_progress::message, validator_action::name, snprintf(), and x509_name().
const struct setting crosscert_setting __setting | ( | SETTING_CRYPTO | , |
crosscert | |||
) |
Cross-signed certificate source setting.
|
static |
Append cross-signing certificates to certificate chain.
validator | Certificate validator |
rc | Completion status code |
rc | Return status code |
Definition at line 239 of file validator.c.
References asn1_enter(), ASN1_SET, asn1_skip_any(), assert(), validator::buffer, validator::cert, x509_link::cert, validator::chain, xfer_buffer::data, asn1_cursor::data, DBGC, DBGC_HDA, ENOMEM, x509_link::flags, xfer_buffer::len, asn1_cursor::len, link, validator::link, x509_chain::links, x509_link::list, list_for_each_entry_continue, NULL, validator::rc, rc, strerror(), validator_name(), x509_alloc_chain(), x509_append_raw(), x509_auto_append(), x509_chain_put(), x509_last(), X509_LINK_FL_CROSSED, x509_name(), and x509_truncate().
|
static |
Start download of cross-signing certificate.
validator | Certificate validator |
link | Link in certificate chain |
rc | Return status code |
Definition at line 360 of file validator.c.
References validator::action, base64_encode(), base64_encoded_len(), validator::cert, crc32_le(), crosscert_default, asn1_cursor::data, DBGC, EINVAL, ENOMEM, fetch_string_setting_copy(), free, intf_restart(), x509_certificate::issuer, len, asn1_cursor::len, link, validator::link, NULL, x509_issuer::raw, validator::rc, rc, snprintf(), strerror(), strlen(), validator_crosscert, validator_name(), x509_name(), validator::xfer, xfer_open_uri_string(), and zalloc().
Referenced by validator_step().
|
static |
Validate OCSP response.
validator | Certificate validator |
rc | Completion status code |
Definition at line 445 of file validator.c.
References validator::buffer, validator::cert, xfer_buffer::data, data, DBGC, len, xfer_buffer::len, NULL, validator::ocsp, ocsp_put(), ocsp_validate(), validator::rc, rc, strerror(), validator_name(), and x509_name().
|
static |
Start OCSP check.
validator | Certificate validator |
cert | Certificate to check |
issuer | Issuing certificate |
rc | Return status code |
Definition at line 502 of file validator.c.
References validator::action, assert(), validator::cert, DBGC, intf_restart(), NULL, validator::ocsp, ocsp_put(), validator::rc, rc, strerror(), ocsp_check::uri_string, validator_name(), validator_ocsp, x509_name(), validator::xfer, and xfer_open_uri_string().
Referenced by validator_step().
|
static |
Close data transfer interface.
validator | Certificate validator |
rc | Reason for close |
Definition at line 558 of file validator.c.
References validator::action, assert(), validator::buffer, DBGC2, validator_action::done, intf_restart(), NULL, validator::process, process_add(), rc, validator_name(), validator::xfer, and xferbuf_free().
Referenced by validator_xfer_deliver().
|
static |
Receive data.
validator | Certificate validator |
iobuf | I/O buffer |
meta | Data transfer metadata |
rc | Return status code |
Definition at line 584 of file validator.c.
References validator::buffer, DBGC, iob_disown, meta(), rc, strerror(), validator_name(), validator_xfer_close(), and xferbuf_deliver().
|
static |
Certificate validation process.
validator | Certificate validator |
Definition at line 623 of file validator.c.
References assert(), x509_link::cert, validator::chain, DBGC, link, x509_chain::links, list_for_each_entry, list_for_each_entry_continue_reverse, list_is_head_entry, NULL, ocsp_required(), validator::rc, rc, validator::root, strerror(), validator_finished(), validator_name(), validator_start_download(), validator_start_ocsp(), x509_is_self_signed(), x509_is_valid(), X509_LINK_FL_CROSSED, X509_LINK_FL_OCSPED, x509_name(), and x509_validate_chain().
int create_validator | ( | struct interface * | job, |
struct x509_chain * | chain, | ||
struct x509_root * | root | ||
) |
Instantiate a certificate validator.
job | Job control interface |
chain | X.509 certificate chain |
root | Root of trust, or NULL to use default |
rc | Return status code |
Definition at line 759 of file validator.c.
References validator::buffer, validator::chain, DBGC2, EINVAL, ENOMEM, intf_init(), intf_plug_plug(), validator::job, validator::process, process_init(), rc, ref_init, ref_put, validator::refcnt, root, validator::root, validator_finished(), validator_free(), validator_job_desc, validator_name(), validator_process_desc, validator_xfer_desc, x509_chain_get(), x509_root_get(), validator::xfer, xferbuf_malloc_init(), and zalloc().
Referenced by imgverify(), and tls_new_server_hello_done().
|
static |
Certificate validator job control interface operations.
Definition at line 206 of file validator.c.
|
static |
Certificate validator job control interface descriptor.
Definition at line 212 of file validator.c.
Referenced by create_validator().
|
static |
Default cross-signed certificate source.
Definition at line 230 of file validator.c.
Referenced by validator_start_download().
|
static |
Cross-signing certificate download validator action.
Definition at line 348 of file validator.c.
Referenced by validator_start_download().
|
static |
OCSP validator action.
Definition at line 489 of file validator.c.
Referenced by validator_start_ocsp().
|
static |
Certificate validator data transfer interface operations.
Definition at line 603 of file validator.c.
|
static |
Certificate validator data transfer interface descriptor.
Definition at line 609 of file validator.c.
Referenced by create_validator().
|
static |
Certificate validator process descriptor.
Definition at line 742 of file validator.c.
Referenced by create_validator().