{-------------------------------------------------------------------------------
Translated form headers/x509v_t.h

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
      THIS ISN'T COMPLETE TRANSLATION OF C++ HEADERS AND NEVER WILL BE.

  FOR COPYRIGHT OF ORIGINAL ERIC YOUNG SOFTWARE LOOK AT FILES IN HEADER FOLDER.
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

      Copyright (C) 1998 by Jan Tomasek <xtomasej@fel.cvut.cz>
      All rights reserved.

      This library is free for commercial and non-commercial use as long as
      the following conditions are aheared to.  The following conditions
      apply to all code found in this distribution.  The documentation
      included with this distribution is covered by the same copyright terms.

      Copyright remains Jan Tomasek's, and as such any Copyright notices in
      the code are not to be removed.
      If this package is used in a product, Jan Tomasek should be given
      attribution as the author of the parts of the library used.
      This can be in the form of a textual message at program startup or
      in documentation (online or textual) provided with the package.

      Redistribution and use in source and binary forms, with or without
      modification, are permitted provided that the following conditions
      are met:
      1. Redistributions of source code must retain the copyright
         notice, this list of conditions and the following disclaimer.
      2. Redistributions in binary form must reproduce the above copyright
         notice, this list of conditions and the following disclaimer in the
         documentation and/or other materials provided with the distribution.
      3. All advertising materials mentioning features or use of this software
         must display the following acknowledgement:
             "This product includes software written by
              Jan Tomasek <xtomasej@fel.cvut.cz>"

      THIS SOFTWARE IS PROVIDED BY JAN TOMASEK ``AS IS'' AND
      ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
      IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
      ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
      FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
      DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
      OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
      HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
      LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
      OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
      SUCH DAMAGE.

      The licence and distribution terms for any publically available version or
      derivative of this code cannot be changed.  i.e. this code cannot simply
      be copied and put under another distribution licence
      [including the GNU Public Licence.]
-------------------------------------------------------------------------------}
  PX509_STORE = ^TX509_STORE;
  PX509_STORE_CTX =^TX509_STORE_CTX;

{ This is used to hold everything.  It is used for all certificate
  validation.  Once we have a certificate chain, the 'verify'
  function is then called to actually check the cert chain. }
  TX509_STORE = record
    {The following is a cache of trusted certs }
    cache            : int;              {int cache;      /* if true, stash any hits */}
                                         {#ifdef HEADER_LHASH_H}
    certs            : PLHASH;           {    LHASH *certs;   /* cached certs; */}
                                         {#else}
                                         {    char *certs;}
                                         {#endif}
    {These are external lookup methods }
    get_cert_methods : PSTACK;           {STACK *get_cert_methods;/* X509_LOOKUP */}
    verify           : func;             {int (*verify)();        /* called to verify a certificate */}
    verify_cb        : func;             {int (*verify_cb)();     /* error callback */}

    app_data         : PChar;            {char *app_data;}
    references       : int;              {int references;}
    depth            : int;              {int depth;              /* how deep to look */}
  end;

{ This is a temporary used when processing cert chains.  Since the
  gathering of the cert chain can take some time (and have to be
  'retried', this needs to be kept and passed around. }
  TX509_STORE_CTX = record
    ctx             : PX509_STORE;          {X509_STORE *ctx;                                                    }
    current_method  : int;                  {int current_method;     /* used when looking up certs */            }

    { The following are set by the caller }
    cert            : PX509;                {X509 *cert;             /* The cert to check */                     }
    untrusted       : PSTACK;               {STACK *untrusted;       /* chain of X509s - untrusted - passed in */}

    { The following is built up }
    depth           : int;                  {int depth;              /* how far to go looking up certs */        }
    valid           : int;                  {int valid;              /* if 0, rebuild chain */                   }
    last_untrusted  : int;                  {int last_untrusted;     /* index of last untrusted cert */          }
    chain           : PSTACK;               {STACK *chain;           /* chain of X509s - built up and trusted */ }

    { When something goes wrong, this is why }
    error_depth     : int;                  {int error_depth;                                                    }
    error           : int;                  {int error;                                                          }
    current_cert    : PX509;                {X509 *current_cert;                                                 }

    app_data        : Pchar;                {char *app_data;                                                     }
  End;

