{-------------------------------------------------------------------------------
Translated form headers/ssl3.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.]
-------------------------------------------------------------------------------}

  TSSL3_RECORD = record
  {r }atype                  : int;    { type of record }                  { int type;}
  {  }{ int state; }                   { any data in it? }                 { /* int state; */}
  {rw}length                 : uint;   { How many bytes available }        { unsigned int length;}
  {r }off                    : uint;   { read/write offset into 'buf' }    { unsigned int off;}
  {rw}data                   : PChar;  { pointer to the record data }      { unsigned char *data;}
  {rw}input                  : PChar;  { where the decode bytes are }      { unsigned char *input;}
  {rw}comp                   : PChar;  { only used with decompression }    { unsigned char *comp;}
  End;

  TSSL3_BUFFER = record
  {r }total                  : int;    { used in non-blocking writes }   { int total;}
  {r }wanted                 : int;    { how many more bytes we need }   { int wanted;}
  {rw}left                   : int;    { how many bytes left }           { int left;}
  {rw}offset                 : int;    { where to 'copy from' }          { int offset;}
  {rw}buf                    : PChar;  { SSL3_RT_MAX_PACKET_SIZE bytes } { unsigned char *buf;}
  End;

  TSSL3_COMPRESSION = record
      nothing                : int;              { int nothing; }
  End;

  TSSL3_CTX_tmp = record
    finish_md1               : Array[0..EVP_MAX_MD_SIZE-1] of char;      { unsigned char finish_md1[EVP_MAX_MD_SIZE]; }
    finish_md2               : Array[0..EVP_MAX_MD_SIZE-1] of char;      { unsigned char finish_md2[EVP_MAX_MD_SIZE]; }

    message_size             : ulong;            { unsigned long message_size; }
    message_type             : int;              { int message_type; }
    { used to hold the new cipher we are going to use }
    new_cipher               : PSSL_CIPHER;      { SSL_CIPHER *new_cipher; }
    dh                       : PDH;              { DH *dh; }
    { used when SSL_ST_FLUSH_DATA is entered }
    next_state               : int;              { int next_state; }
    reuse_message            : int;              { int reuse_message; }
    { used for certificate requests }
    cert_req                 : int;              { int cert_req; }
    ctype_num                : int;              { int ctype_num; }
    ctype                    : Array[0..SSL3_CT_NUMBER-1] of Char; { char ctype[SSL3_CT_NUMBER]; }
    ca_names                 : PSTACK;           { STACK *ca_names; }

    use_rsa_tmp              : int;              { int use_rsa_tmp; }

    key_block_length         : int;              { int key_block_length; }
    key_block                : PChar;            { unsigned char *key_block; }

    new_sym_enc              : PEVP_CIPHER;      { EVP_CIPHER *new_sym_enc; }
    new_hash                 : PEVP_MD;          { EVP_MD *new_hash; }
    new_compression          : PSSL_COMPRESSION; { SSL_COMPRESSION *new_compression; }
  End;

  TSSL3_CTX = record
    flags                    : long;             { long flags; }
    delay_buf_pop_ret        : int;              { int delay_buf_pop_ret; }

    read_sequence            : Array[0..7] of Char; { unsigned char read_sequence[8]; }
    read_mac_secret          : Array[0..EVP_MAX_MD_SIZE-1] of Char; { unsigned char read_mac_secret[EVP_MAX_MD_SIZE]; }
    write_sequence           : Array[0..7] of Char; { unsigned char write_sequence[8]; }
    write_mac_secret         : Array[0..EVP_MAX_MD_SIZE-1] of Char; { unsigned char write_mac_secret[EVP_MAX_MD_SIZE]; }

    server_random            : Array[0..SSL3_RANDOM_SIZE-1] of Char; {unsigned char server_random[SSL3_RANDOM_SIZE];}
    client_random            : Array[0..SSL3_RANDOM_SIZE-1] of Char; {unsigned char client_random[SSL3_RANDOM_SIZE];}

    rbuf                     : TSSL3_BUFFER; { read IO goes into here }           { SSL3_BUFFER rbuf;}
    wbuf                     : TSSL3_BUFFER; { write IO goes into here }          { SSL3_BUFFER wbuf;}
    rrec                     : TSSL3_RECORD; { each decoded record goes in here } { SSL3_RECORD rrec;}
    wrec                     : TSSL3_RECORD; { goes out from here }               { SSL3_RECORD wrec;}
                                             { Used by ssl3_read_n to point
                                               to input data packet }
    { partial write - check the numbers match }
    wnum                     : uint ;  { number of bytes sent so far } { unsigned int wnum; }
    wpend_tot                : int;    { number bytes written }        { int wpend_tot; }
    wpend_type               : int;                                    { int wpend_type; }
    wpend_ret                : int;    { number of bytes submitted }   { int wpend_ret; }
    wpend_buf                : PChar;                                  { char *wpend_buf; }

    { used during startup, digest all incoming/outgoing packets }
    finish_dgst1             : TEVP_MD_CTX;     {EVP_MD_CTX finish_dgst1;}
    finish_dgst2             : TEVP_MD_CTX;     {EVP_MD_CTX finish_dgst2;}

    { this is set whenerver we see a change_cipher_spec message
      come in when we are not looking for one }
    change_cipher_spec       : int;             {int change_cipher_spec;}

    warn_alert               : int;             {int warn_alert;}
    fatal_alert              : int;             {int fatal_alert;}
    { we alow one fatal and one warning alert to be outstanding,
      send close alert via the warning alert }
    alert_dispatch           : int;             {int alert_dispatch;}
    send_alert               : Array[0..1] of Char; {char send_alert[2];}

    tmp                      : TSSL3_CTX_tmp;
  End;
