remove duplicate statement
[openssl.git] / ssl / ssl.h
index e6244b0011dc33c4a5dfbca200bc7466cbc43016..e036390bc5caeb05405d63c8ab22f9ead2745d1c 100644 (file)
--- a/ssl/ssl.h
+++ b/ssl/ssl.h
@@ -468,6 +468,9 @@ typedef struct ssl_session_st
        char *psk_identity_hint;
        char *psk_identity;
 #endif
+       /* Used to indicate that session resumption is not allowed.
+        * Applications can also set this bit for a new session via
+        * not_resumable_session_cb to disable session caching and tickets. */
        int not_resumable;
 
        /* The cert is the certificate used to establish this connection */
@@ -811,6 +814,10 @@ struct ssl_ctx_st
 
        X509_VERIFY_PARAM *param;
 
+       /* Callback for disabling session caching and ticket support
+        * on a session basis, depending on the chosen cipher. */
+       int (*not_resumable_session_cb)(SSL *ssl, int is_forward_secure);
+
 #if 0
        int purpose;            /* Purpose setting */
        int trust;              /* Trust setting */
@@ -852,6 +859,25 @@ struct ssl_ctx_st
        /* draft-rescorla-tls-opaque-prf-input-00.txt information */
        int (*tlsext_opaque_prf_input_callback)(SSL *, void *peerinput, size_t len, void *arg);
        void *tlsext_opaque_prf_input_callback_arg;
+
+# ifndef OPENSSL_NO_NEXTPROTONEG
+       /* Next protocol negotiation information */
+       /* (for experimental NPN extension). */
+
+       /* For a server, this contains a callback function by which the set of
+        * advertised protocols can be provided. */
+       int (*next_protos_advertised_cb)(SSL *s, const unsigned char **buf,
+                                        unsigned int *len, void *arg);
+       void *next_protos_advertised_cb_arg;
+       /* For a client, this contains a callback function that selects the
+        * next protocol from the list provided by the server. */
+       int (*next_proto_select_cb)(SSL *s, unsigned char **out,
+                                   unsigned char *outlen,
+                                   const unsigned char *in,
+                                   unsigned int inlen,
+                                   void *arg);
+       void *next_proto_select_cb_arg;
+# endif
 #endif
 
 #ifndef OPENSSL_NO_PSK
@@ -923,6 +949,30 @@ int SSL_CTX_set_client_cert_engine(SSL_CTX *ctx, ENGINE *e);
 #endif
 void SSL_CTX_set_cookie_generate_cb(SSL_CTX *ctx, int (*app_gen_cookie_cb)(SSL *ssl, unsigned char *cookie, unsigned int *cookie_len));
 void SSL_CTX_set_cookie_verify_cb(SSL_CTX *ctx, int (*app_verify_cookie_cb)(SSL *ssl, unsigned char *cookie, unsigned int cookie_len));
+#ifndef OPENSSL_NO_NEXTPROTONEG
+void SSL_CTX_set_next_protos_advertised_cb(SSL_CTX *s,
+                                          int (*cb) (SSL *ssl,
+                                                     const unsigned char **out,
+                                                     unsigned int *outlen,
+                                                     void *arg), void *arg);
+void SSL_CTX_set_next_proto_select_cb(SSL_CTX *s,
+                                     int (*cb) (SSL *ssl, unsigned char **out,
+                                                unsigned char *outlen,
+                                                const unsigned char *in,
+                                                unsigned int inlen, void *arg),
+                                     void *arg);
+
+int SSL_select_next_proto(unsigned char **out, unsigned char *outlen,
+                         const unsigned char *in, unsigned int inlen,
+                         const unsigned char *client, unsigned int client_len);
+void SSL_get0_next_proto_negotiated(const SSL *s, const unsigned char **data,
+                                   unsigned *len);
+
+#define OPENSSL_NPN_UNSUPPORTED        0
+#define OPENSSL_NPN_NEGOTIATED 1
+#define OPENSSL_NPN_NO_OVERLAP 2
+
+#endif
 
 #ifndef OPENSSL_NO_PSK
 /* the maximum length of the buffer given to callbacks containing the
@@ -1007,12 +1057,14 @@ struct ssl_st
 
        int server;     /* are we the server side? - mostly used by SSL_clear*/
 
-       int new_session;/* 1 if we are to use a new session.
-                        * 2 if we are a server and are inside a handshake
-                        *   (i.e. not just sending a HelloRequest)
-                        * NB: For servers, the 'new' session may actually be a previously
-                        * cached session or even the previous session unless
-                        * SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION is set */
+       int new_session;/* Generate a new session or reuse an old one.
+                                        * NB: For servers, the 'new' session may actually be a previously
+                                        * cached session or even the previous session unless
+                                        * SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION is set */
+       int renegotiate;/* 1 if we are renegotiating.
+                                        * 2 if we are a server and are inside a handshake
+                                        *   (i.e. not just sending a HelloRequest) */
+
        int quiet_shutdown;/* don't send shutdown packets */
        int shutdown;   /* we have shut things down, 0x01 sent, 0x02
                         * for received */
@@ -1043,6 +1095,10 @@ struct ssl_st
 
        X509_VERIFY_PARAM *param;
 
+       /* Callback for disabling session caching and ticket support
+        * on a session basis, depending on the chosen cipher. */
+       int (*not_resumable_session_cb)(SSL *ssl, int is_forward_secure);
+
 #if 0
        int purpose;            /* Purpose setting */
        int trust;              /* Trust setting */
@@ -1179,6 +1235,19 @@ struct ssl_st
        void *tls_session_secret_cb_arg;
 
        SSL_CTX * initial_ctx; /* initial ctx, used to store sessions */
+
+#ifndef OPENSSL_NO_NEXTPROTONEG
+       /* Next protocol negotiation. For the client, this is the protocol that
+        * we sent in NextProtocol and is set when handling ServerHello
+        * extensions.
+        *
+        * For a server, this is the client's selected_protocol from
+        * NextProtocol and is set when handling the NextProtocol message,
+        * before the Finished message. */
+       unsigned char *next_proto_negotiated;
+       unsigned char next_proto_negotiated_len;
+#endif
+
 #define session_ctx initial_ctx
 #else
 #define session_ctx ctx
@@ -1419,6 +1488,7 @@ DECLARE_PEM_rw(SSL_SESSION, SSL_SESSION)
 #define SSL_CTRL_GET_RI_SUPPORT                        76
 #define SSL_CTRL_CLEAR_OPTIONS                 77
 #define SSL_CTRL_CLEAR_MODE                    78
+#define SSL_CTRL_SET_NOT_RESUMABLE_SESS_CB     79
 
 #define DTLSv1_get_timeout(ssl, arg) \
        SSL_ctrl(ssl,DTLS_CTRL_GET_TIMEOUT,0, (void *)arg)
@@ -1661,6 +1731,7 @@ STACK_OF(SSL_CIPHER) *SSL_get_ciphers(const SSL *s);
 
 int SSL_do_handshake(SSL *s);
 int SSL_renegotiate(SSL *s);
+int SSL_renegotiate_abbreviated(SSL *s);
 int SSL_renegotiate_pending(SSL *s);
 int SSL_shutdown(SSL *s);
 
@@ -1816,6 +1887,12 @@ int SSL_tls1_key_exporter(SSL *s, unsigned char *label, int label_len,
                            unsigned char *context, int context_len,
                            unsigned char *out, int olen);
 
+void SSL_CTX_set_not_resumable_session_callback(SSL_CTX *ctx,
+       int (*cb)(SSL *ssl, int is_forward_secure));
+
+void SSL_set_not_resumable_session_callback(SSL *ssl,
+       int (*cb)(SSL *ssl, int is_forward_secure));
+
 /* BEGIN ERROR CODES */
 /* The following lines are auto generated by the script mkerr.pl. Any changes
  * made after this point may be overwritten when the script is next run.
@@ -1910,6 +1987,7 @@ void ERR_load_SSL_strings(void);
 #define SSL_F_SSL3_GET_KEY_EXCHANGE                     141
 #define SSL_F_SSL3_GET_MESSAGE                          142
 #define SSL_F_SSL3_GET_NEW_SESSION_TICKET               283
+#define SSL_F_SSL3_GET_NEXT_PROTO                       304
 #define SSL_F_SSL3_GET_RECORD                           143
 #define SSL_F_SSL3_GET_SERVER_CERTIFICATE               144
 #define SSL_F_SSL3_GET_SERVER_DONE                      145
@@ -2107,6 +2185,8 @@ void ERR_load_SSL_strings(void);
 #define SSL_R_EXCESSIVE_MESSAGE_SIZE                    152
 #define SSL_R_EXTRA_DATA_IN_MESSAGE                     153
 #define SSL_R_GOT_A_FIN_BEFORE_A_CCS                    154
+#define SSL_R_GOT_NEXT_PROTO_BEFORE_A_CCS               346
+#define SSL_R_GOT_NEXT_PROTO_WITHOUT_EXTENSION          347
 #define SSL_R_HTTPS_PROXY_REQUEST                       155
 #define SSL_R_HTTP_REQUEST                              156
 #define SSL_R_ILLEGAL_PADDING                           283