-typedef struct ssl3_state_st {
- long flags;
- size_t read_mac_secret_size;
- unsigned char read_mac_secret[EVP_MAX_MD_SIZE];
- size_t write_mac_secret_size;
- unsigned char write_mac_secret[EVP_MAX_MD_SIZE];
- unsigned char server_random[SSL3_RANDOM_SIZE];
- unsigned char client_random[SSL3_RANDOM_SIZE];
- /* flags for countermeasure against known-IV weakness */
- int need_empty_fragments;
- int empty_fragment_done;
- /* used during startup, digest all incoming/outgoing packets */
- BIO *handshake_buffer;
- /*
- * When handshake digest is determined, buffer is hashed and
- * freed and MD_CTX for the required digest is stored here.
- */
- EVP_MD_CTX *handshake_dgst;
- /*
- * Set whenever an expected ChangeCipherSpec message is processed.
- * Unset when the peer's Finished message is received.
- * Unexpected ChangeCipherSpec messages trigger a fatal alert.
- */
- int change_cipher_spec;
- int warn_alert;
- int fatal_alert;
- /*
- * we allow one fatal and one warning alert to be outstanding, send close
- * alert via the warning alert
- */
- int alert_dispatch;
- unsigned char send_alert[2];
- /*
- * This flag is set when we should renegotiate ASAP, basically when there
- * is no more data in the read or write buffers
- */
- int renegotiate;
- int total_renegotiations;
- int num_renegotiations;
- int in_read_app_data;
- struct {
- /* actually only need to be 16+20 for SSLv3 and 12 for TLS */
- unsigned char finish_md[EVP_MAX_MD_SIZE * 2];
- size_t finish_md_len;
- unsigned char peer_finish_md[EVP_MAX_MD_SIZE * 2];
- size_t peer_finish_md_len;
- size_t message_size;
- int message_type;
- /* used to hold the new cipher we are going to use */
- const SSL_CIPHER *new_cipher;
-# if !defined(OPENSSL_NO_EC) || !defined(OPENSSL_NO_DH)
- EVP_PKEY *pkey; /* holds short lived DH/ECDH key */
-# endif
- /* used for certificate requests */
- int cert_req;
- /* Certificate types in certificate request message. */
- uint8_t *ctype;
- size_t ctype_len;
- /* Certificate authorities list peer sent */
- STACK_OF(X509_NAME) *peer_ca_names;
- size_t key_block_length;
- unsigned char *key_block;
- const EVP_CIPHER *new_sym_enc;
- const EVP_MD *new_hash;
- int new_mac_pkey_type;
- size_t new_mac_secret_size;
-# ifndef OPENSSL_NO_COMP
- const SSL_COMP *new_compression;
-# else
- char *new_compression;
-# endif
- int cert_request;
- /* Raw values of the cipher list from a client */
- unsigned char *ciphers_raw;
- size_t ciphers_rawlen;
- /* Temporary storage for premaster secret */
- unsigned char *pms;
- size_t pmslen;
-# ifndef OPENSSL_NO_PSK
- /* Temporary storage for PSK key */
- unsigned char *psk;
- size_t psklen;
-# endif
- /* Signature algorithm we actually use */
- const SIGALG_LOOKUP *sigalg;
- /* Pointer to certificate we use */
- CERT_PKEY *cert;
- /*
- * signature algorithms peer reports: e.g. supported signature
- * algorithms extension for server or as part of a certificate
- * request for client.
- * Keep track of the algorithms for TLS and X.509 usage separately.
- */
- uint16_t *peer_sigalgs;
- uint16_t *peer_cert_sigalgs;
- /* Size of above arrays */
- size_t peer_sigalgslen;
- size_t peer_cert_sigalgslen;
- /* Sigalg peer actually uses */
- const SIGALG_LOOKUP *peer_sigalg;
- /*
- * Set if corresponding CERT_PKEY can be used with current
- * SSL session: e.g. appropriate curve, signature algorithms etc.
- * If zero it can't be used at all.
- */
- uint32_t valid_flags[SSL_PKEY_NUM];
- /*
- * For servers the following masks are for the key and auth algorithms
- * that are supported by the certs below. For clients they are masks of
- * *disabled* algorithms based on the current session.
- */
- uint32_t mask_k;
- uint32_t mask_a;
- /*
- * The following are used by the client to see if a cipher is allowed or
- * not. It contains the minimum and maximum version the client's using
- * based on what it knows so far.
- */
- int min_ver;
- int max_ver;
- } tmp;
-
- /* Connection binding to prevent renegotiation attacks */
- unsigned char previous_client_finished[EVP_MAX_MD_SIZE];
- size_t previous_client_finished_len;
- unsigned char previous_server_finished[EVP_MAX_MD_SIZE];
- size_t previous_server_finished_len;
- int send_connection_binding; /* TODOEKR */
-
-# ifndef OPENSSL_NO_NEXTPROTONEG
- /*
- * Set if we saw the Next Protocol Negotiation extension from our peer.
- */
- int npn_seen;
-# endif
-
- /*
- * ALPN information (we are in the process of transitioning from NPN to
- * ALPN.)
- */
-
- /*
- * In a server these point to the selected ALPN protocol after the
- * ClientHello has been processed. In a client these contain the protocol
- * that the server selected once the ServerHello has been processed.
- */
- unsigned char *alpn_selected;
- size_t alpn_selected_len;
- /* used by the server to know what options were proposed */
- unsigned char *alpn_proposed;
- size_t alpn_proposed_len;
- /* used by the client to know if it actually sent alpn */
- int alpn_sent;
-
-# ifndef OPENSSL_NO_EC
- /*
- * This is set to true if we believe that this is a version of Safari
- * running on OS X 10.6 or newer. We wish to know this because Safari on
- * 10.8 .. 10.8.3 has broken ECDHE-ECDSA support.
- */
- char is_probably_safari;
-# endif /* !OPENSSL_NO_EC */
-
- /* For clients: peer temporary key */
-# if !defined(OPENSSL_NO_EC) || !defined(OPENSSL_NO_DH)
- /* The group_id for the DH/ECDH key */
- uint16_t group_id;
- EVP_PKEY *peer_tmp;
-# endif
-
-} SSL3_STATE;
-