CVE-2016-2110: auth/ntlmssp: implement new_spnego support including MIC generation...
[samba.git] / auth / ntlmssp / ntlmssp.h
index eb44913d8774fdbb3523088e6313b926259add15..2412768631287517b516aa7b1947ef82d76836d3 100644 (file)
@@ -22,8 +22,6 @@
 
 #include "../librpc/gen_ndr/ntlmssp.h"
 
-NTSTATUS gensec_ntlmssp_init(void);
-
 struct auth_context;
 struct auth_serversupplied_info;
 struct tsocket_address;
@@ -31,15 +29,6 @@ struct auth_user_info_dc;
 struct gensec_security;
 struct ntlmssp_state;
 
-struct gensec_ntlmssp_context {
-       /* For GENSEC users */
-       struct gensec_security *gensec_security;
-       void *server_returned_info;
-
-       /* used by both client and server implementation */
-       struct ntlmssp_state *ntlmssp_state;
-};
-
 /* NTLMSSP mode */
 enum ntlmssp_role
 {
@@ -73,7 +62,9 @@ struct ntlmssp_state
        bool unicode;
        bool use_ntlmv2;
        bool use_ccache;
+       bool resume_ccache;
        bool use_nt_response;  /* Set to 'False' to debug what happens when the NT response is omited */
+       bool allow_lm_response;/* The LM_RESPONSE code is not very secure... */
        bool allow_lm_key;     /* The LM_KEY code is not very secure... */
 
        const char *user;
@@ -81,9 +72,15 @@ struct ntlmssp_state
        uint8_t *nt_hash;
        uint8_t *lm_hash;
 
+       DATA_BLOB negotiate_blob;
+       DATA_BLOB challenge_blob;
+       bool new_spnego;
+       bool force_old_spnego;
+
        struct {
                const char *netbios_name;
                const char *netbios_domain;
+               struct AV_PAIR_LIST av_pair_list;
        } client;
 
        struct {
@@ -92,6 +89,8 @@ struct ntlmssp_state
                const char *netbios_domain;
                const char *dns_name;
                const char *dns_domain;
+               NTTIME challenge_endtime;
+               struct AV_PAIR_LIST av_pair_list;
        } server;
 
        DATA_BLOB internal_chal; /* Random challenge as supplied to the client for NTLM authentication */
@@ -101,59 +100,11 @@ struct ntlmssp_state
        DATA_BLOB nt_resp;
        DATA_BLOB session_key;
 
+       uint32_t conf_flags;
+       uint32_t required_flags;
        uint32_t neg_flags; /* the current state of negotiation with the NTLMSSP partner */
 
-       /**
-        * Private data for the callback functions
-        */
-       void *callback_private;
-
-       /**
-        * Callback to get the 'challenge' used for NTLM authentication.
-        *
-        * @param ntlmssp_state This structure
-        * @return 8 bytes of challenge data, determined by the server to be the challenge for NTLM authentication
-        *
-        */
-       NTSTATUS (*get_challenge)(const struct ntlmssp_state *ntlmssp_state,
-                                 uint8_t challenge[8]);
-
-       /**
-        * Callback to find if the challenge used by NTLM authentication may be modified
-        *
-        * The NTLM2 authentication scheme modifies the effective challenge, but this is not compatiable with the
-        * current 'security=server' implementation..
-        *
-        * @param ntlmssp_state This structure
-        * @return Can the challenge be set to arbitary values?
-        *
-        */
-       bool (*may_set_challenge)(const struct ntlmssp_state *ntlmssp_state);
-
-       /**
-        * Callback to set the 'challenge' used for NTLM authentication.
-        *
-        * The callback may use the void *auth_context to store state information, but the same value is always available
-        * from the DATA_BLOB chal on this structure.
-        *
-        * @param ntlmssp_state This structure
-        * @param challenge 8 bytes of data, agreed by the client and server to be the effective challenge for NTLM2 authentication
-        *
-        */
-       NTSTATUS (*set_challenge)(struct ntlmssp_state *ntlmssp_state, DATA_BLOB *challenge);
-
-       /**
-        * Callback to check the user's password.
-        *
-        * The callback must reads the feilds of this structure for the information it needs on the user
-        * @param ntlmssp_state This structure
-        * @param mem_ctx Talloc context for LM and NT session key to be returned on
-        * @param nt_session_key If an NT session key is returned by the authentication process, return it here
-        * @param lm_session_key If an LM session key is returned by the authentication process, return it here
-        *
-        */
-       NTSTATUS (*check_password)(struct ntlmssp_state *ntlmssp_state, TALLOC_CTX *mem_ctx,
-                                  DATA_BLOB *nt_session_key, DATA_BLOB *lm_session_key);
+       bool force_wrap_seal;
 
        union ntlmssp_crypt_state *crypt;
 };
@@ -186,54 +137,15 @@ NTSTATUS ntlmssp_unwrap(struct ntlmssp_state *ntlmssp_stae,
                        TALLOC_CTX *out_mem_ctx,
                        const DATA_BLOB *in,
                        DATA_BLOB *out);
+NTSTATUS ntlmssp_sign_reset(struct ntlmssp_state *ntlmssp_state,
+                           bool reset_seqnums);
 NTSTATUS ntlmssp_sign_init(struct ntlmssp_state *ntlmssp_state);
 
 bool ntlmssp_blob_matches_magic(const DATA_BLOB *blob);
-/* The following definitions come from ../source4/auth/ntlmssp/ntlmssp.c  */
-
-
-/**
- * Return the NTLMSSP master session key
- *
- * @param ntlmssp_state NTLMSSP State
- */
-NTSTATUS gensec_ntlmssp_magic(struct gensec_security *gensec_security,
-                             const DATA_BLOB *first_packet);
-bool gensec_ntlmssp_have_feature(struct gensec_security *gensec_security,
-                                uint32_t feature);
-NTSTATUS gensec_ntlmssp_session_key(struct gensec_security *gensec_security,
-                                   TALLOC_CTX *mem_ctx,
-                                   DATA_BLOB *session_key);
-NTSTATUS gensec_ntlmssp_start(struct gensec_security *gensec_security);
-
-/* The following definitions come from ../source4/auth/ntlmssp/ntlmssp_sign.c  */
-
-NTSTATUS gensec_ntlmssp_sign_packet(struct gensec_security *gensec_security,
-                                   TALLOC_CTX *sig_mem_ctx,
-                                   const uint8_t *data, size_t length,
-                                   const uint8_t *whole_pdu, size_t pdu_length,
-                                   DATA_BLOB *sig);
-NTSTATUS gensec_ntlmssp_check_packet(struct gensec_security *gensec_security,
-                                    const uint8_t *data, size_t length,
-                                    const uint8_t *whole_pdu, size_t pdu_length,
-                                    const DATA_BLOB *sig);
-NTSTATUS gensec_ntlmssp_seal_packet(struct gensec_security *gensec_security,
-                                   TALLOC_CTX *sig_mem_ctx,
-                                   uint8_t *data, size_t length,
-                                   const uint8_t *whole_pdu, size_t pdu_length,
-                                   DATA_BLOB *sig);
-NTSTATUS gensec_ntlmssp_unseal_packet(struct gensec_security *gensec_security,
-                                     uint8_t *data, size_t length,
-                                     const uint8_t *whole_pdu, size_t pdu_length,
-                                     const DATA_BLOB *sig);
-size_t gensec_ntlmssp_sig_size(struct gensec_security *gensec_security, size_t data_size) ;
-NTSTATUS gensec_ntlmssp_wrap(struct gensec_security *gensec_security,
-                            TALLOC_CTX *out_mem_ctx,
-                            const DATA_BLOB *in,
-                            DATA_BLOB *out);
-NTSTATUS gensec_ntlmssp_unwrap(struct gensec_security *gensec_security,
-                              TALLOC_CTX *out_mem_ctx,
-                              const DATA_BLOB *in,
-                              DATA_BLOB *out);
+
+/* The following definitions come from auth/ntlmssp/gensec_ntlmssp.c  */
 
 NTSTATUS gensec_ntlmssp_init(void);
+
+uint32_t gensec_ntlmssp_neg_flags(struct gensec_security *gensec_security);
+const char *gensec_ntlmssp_server_domain(struct gensec_security *gensec_security);