iPXE
Functions
validator.h File Reference

Certificate validator. More...

#include <ipxe/interface.h>
#include <ipxe/x509.h>

Go to the source code of this file.

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
int create_validator (struct interface *job, struct x509_chain *chain)
 Instantiate a certificate validator.

Detailed Description

Certificate validator.

Definition in file validator.h.


Function Documentation

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )
int create_validator ( struct interface job,
struct x509_chain chain 
)

Instantiate a certificate validator.

Parameters:
jobJob control interface
chainX.509 certificate chain
Return values:
rcReturn status code

Definition at line 541 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, validator_finished(), validator_free(), x509_chain_get(), validator::xfer, and zalloc().

Referenced by imgverify(), and tls_new_server_hello_done().

                                                                         {
        struct validator *validator;
        int rc;

        /* Sanity check */
        if ( ! chain ) {
                rc = -EINVAL;
                goto err_sanity;
        }

        /* Allocate and initialise structure */
        validator = zalloc ( sizeof ( *validator ) );
        if ( ! validator ) {
                rc = -ENOMEM;
                goto err_alloc;
        }
        ref_init ( &validator->refcnt, validator_free );
        intf_init ( &validator->job, &validator_job_desc,
                    &validator->refcnt );
        intf_init ( &validator->xfer, &validator_xfer_desc,
                    &validator->refcnt );
        process_init ( &validator->process, &validator_process_desc,
                       &validator->refcnt );
        validator->chain = x509_chain_get ( chain );
        xferbuf_malloc_init ( &validator->buffer );

        /* Attach parent interface, mortalise self, and return */
        intf_plug_plug ( &validator->job, job );
        ref_put ( &validator->refcnt );
        DBGC2 ( validator, "VALIDATOR %p validating X509 chain %p\n",
                validator, validator->chain );
        return 0;

        validator_finished ( validator, rc );
        ref_put ( &validator->refcnt );
 err_alloc:
 err_sanity:
        return rc;
}