s3:ntlmssp Move ntlmssp_sign.c from source3 to common code.
authorAndrew Bartlett <abartlet@samba.org>
Tue, 25 May 2010 10:58:52 +0000 (20:58 +1000)
committerGünther Deschner <gd@samba.org>
Mon, 31 May 2010 13:11:36 +0000 (15:11 +0200)
This needs a small re-arrangement of the supporting code.

Andrew Bartlett

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Signed-off-by: Günther Deschner <gd@samba.org>
libcli/auth/ntlmssp.c [new file with mode: 0644]
libcli/auth/ntlmssp.h
libcli/auth/ntlmssp_private.h [new file with mode: 0644]
libcli/auth/ntlmssp_sign.c [moved from source3/libsmb/ntlmssp_sign.c with 99% similarity]
source3/Makefile.in
source3/include/proto.h
source3/libsmb/ntlmssp.c

diff --git a/libcli/auth/ntlmssp.c b/libcli/auth/ntlmssp.c
new file mode 100644 (file)
index 0000000..1be764e
--- /dev/null
@@ -0,0 +1,76 @@
+/*
+   Unix SMB/Netbios implementation.
+   Version 3.0
+   handle NLTMSSP, server side
+
+   Copyright (C) Andrew Tridgell      2001
+   Copyright (C) Andrew Bartlett 2001-2003
+   Copyright (C) Andrew Bartlett 2005 (Updated from gensec).
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "includes.h"
+#include "../libcli/auth/ntlmssp.h"
+#include "../libcli/auth/ntlmssp_private.h"
+
+/**
+ * Print out the NTLMSSP flags for debugging
+ * @param neg_flags The flags from the packet
+ */
+void debug_ntlmssp_flags(uint32_t neg_flags)
+{
+       DEBUG(3,("Got NTLMSSP neg_flags=0x%08x\n", neg_flags));
+
+       if (neg_flags & NTLMSSP_NEGOTIATE_UNICODE)
+               DEBUGADD(4, ("  NTLMSSP_NEGOTIATE_UNICODE\n"));
+       if (neg_flags & NTLMSSP_NEGOTIATE_OEM)
+               DEBUGADD(4, ("  NTLMSSP_NEGOTIATE_OEM\n"));
+       if (neg_flags & NTLMSSP_REQUEST_TARGET)
+               DEBUGADD(4, ("  NTLMSSP_REQUEST_TARGET\n"));
+       if (neg_flags & NTLMSSP_NEGOTIATE_SIGN)
+               DEBUGADD(4, ("  NTLMSSP_NEGOTIATE_SIGN\n"));
+       if (neg_flags & NTLMSSP_NEGOTIATE_SEAL)
+               DEBUGADD(4, ("  NTLMSSP_NEGOTIATE_SEAL\n"));
+       if (neg_flags & NTLMSSP_NEGOTIATE_DATAGRAM)
+               DEBUGADD(4, ("  NTLMSSP_NEGOTIATE_DATAGRAM\n"));
+       if (neg_flags & NTLMSSP_NEGOTIATE_LM_KEY)
+               DEBUGADD(4, ("  NTLMSSP_NEGOTIATE_LM_KEY\n"));
+       if (neg_flags & NTLMSSP_NEGOTIATE_NETWARE)
+               DEBUGADD(4, ("  NTLMSSP_NEGOTIATE_NETWARE\n"));
+       if (neg_flags & NTLMSSP_NEGOTIATE_NTLM)
+               DEBUGADD(4, ("  NTLMSSP_NEGOTIATE_NTLM\n"));
+       if (neg_flags & NTLMSSP_NEGOTIATE_OEM_DOMAIN_SUPPLIED)
+               DEBUGADD(4, ("  NTLMSSP_NEGOTIATE_OEM_DOMAIN_SUPPLIED\n"));
+       if (neg_flags & NTLMSSP_NEGOTIATE_OEM_WORKSTATION_SUPPLIED)
+               DEBUGADD(4, ("  NTLMSSP_NEGOTIATE_OEM_WORKSTATION_SUPPLIED\n"));
+       if (neg_flags & NTLMSSP_NEGOTIATE_THIS_IS_LOCAL_CALL)
+               DEBUGADD(4, ("  NTLMSSP_NEGOTIATE_THIS_IS_LOCAL_CALL\n"));
+       if (neg_flags & NTLMSSP_NEGOTIATE_ALWAYS_SIGN)
+               DEBUGADD(4, ("  NTLMSSP_NEGOTIATE_ALWAYS_SIGN\n"));
+       if (neg_flags & NTLMSSP_REQUEST_NON_NT_SESSION_KEY)
+               DEBUGADD(4, ("  NTLMSSP_REQUEST_NON_NT_SESSION_KEY\n"));
+       if (neg_flags & NTLMSSP_NEGOTIATE_NTLM2)
+               DEBUGADD(4, ("  NTLMSSP_NEGOTIATE_NTLM2\n"));
+       if (neg_flags & NTLMSSP_NEGOTIATE_TARGET_INFO)
+               DEBUGADD(4, ("  NTLMSSP_NEGOTIATE_TARGET_INFO\n"));
+       if (neg_flags & NTLMSSP_NEGOTIATE_VERSION)
+               DEBUGADD(4, ("  NTLMSSP_NEGOTIATE_VERSION\n"));
+       if (neg_flags & NTLMSSP_NEGOTIATE_128)
+               DEBUGADD(4, ("  NTLMSSP_NEGOTIATE_128\n"));
+       if (neg_flags & NTLMSSP_NEGOTIATE_KEY_EXCH)
+               DEBUGADD(4, ("  NTLMSSP_NEGOTIATE_KEY_EXCH\n"));
+       if (neg_flags & NTLMSSP_NEGOTIATE_56)
+               DEBUGADD(4, ("  NTLMSSP_NEGOTIATE_56\n"));
+}
index 97192b8c6feba8eed0b7f9a4f4c5abf6d056f2f5..d0a282c35096759b9d152e618e1aa2f2c7b8ebe1 100644 (file)
@@ -137,3 +137,25 @@ struct ntlmssp_state
 
        union ntlmssp_crypt_state *crypt;
 };
 
        union ntlmssp_crypt_state *crypt;
 };
+
+/* The following definitions come from libcli/auth/ntlmssp_sign.c  */
+
+NTSTATUS ntlmssp_sign_packet(struct ntlmssp_state *ntlmssp_state,
+                            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 ntlmssp_check_packet(struct ntlmssp_state *ntlmssp_state,
+                             const uint8_t *data, size_t length,
+                             const uint8_t *whole_pdu, size_t pdu_length,
+                             const DATA_BLOB *sig) ;
+NTSTATUS ntlmssp_seal_packet(struct ntlmssp_state *ntlmssp_state,
+                            TALLOC_CTX *sig_mem_ctx,
+                            uint8_t *data, size_t length,
+                            const uint8_t *whole_pdu, size_t pdu_length,
+                            DATA_BLOB *sig);
+NTSTATUS ntlmssp_unseal_packet(struct ntlmssp_state *ntlmssp_state,
+                              uint8_t *data, size_t length,
+                              const uint8_t *whole_pdu, size_t pdu_length,
+                              const DATA_BLOB *sig);
+NTSTATUS ntlmssp_sign_init(struct ntlmssp_state *ntlmssp_state);
diff --git a/libcli/auth/ntlmssp_private.h b/libcli/auth/ntlmssp_private.h
new file mode 100644 (file)
index 0000000..0f0c7db
--- /dev/null
@@ -0,0 +1,25 @@
+/*
+ *  Unix SMB/CIFS implementation.
+ *  Version 3.0
+ *  NTLMSSP Signing routines
+ *  Copyright (C) Andrew Bartlett 2003-2005
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+/* For structures internal to the NTLMSSP implementation that should not be exposed */
+
+/* The following definitions come from libcli/auth/ntlmssp.c  */
+
+void debug_ntlmssp_flags(uint32_t neg_flags);
similarity index 99%
rename from source3/libsmb/ntlmssp_sign.c
rename to libcli/auth/ntlmssp_sign.c
index 8ae244b70b7d85014bea945db50bdd2c1c835cf9..61b52c6a6174391e724d475576c1af4c0be61c7a 100644 (file)
@@ -25,6 +25,7 @@
 #include "../lib/crypto/arcfour.h"
 #include "../lib/crypto/hmacmd5.h"
 #include "../lib/crypto/crc32.h"
 #include "../lib/crypto/arcfour.h"
 #include "../lib/crypto/hmacmd5.h"
 #include "../lib/crypto/crc32.h"
+#include "../libcli/auth/ntlmssp_private.h"
 
 #define CLI_SIGN "session key to client-to-server signing key magic constant"
 #define CLI_SEAL "session key to client-to-server sealing key magic constant"
 
 #define CLI_SIGN "session key to client-to-server signing key magic constant"
 #define CLI_SEAL "session key to client-to-server sealing key magic constant"
index f411eeef8a205cb174d9532e066ebd1fdfaa2fd2..b8c13cadbe932289a1f60557ff829cb2fab1cd02 100644 (file)
@@ -485,7 +485,8 @@ LIBSMB_ERR_OBJ = $(LIBSMB_ERR_OBJ0) $(LIBSMB_ERR_OBJ1) \
 LIBSMB_OBJ0 = \
               ../libcli/auth/ntlm_check.o \
               libsmb/ntlmssp.o \
 LIBSMB_OBJ0 = \
               ../libcli/auth/ntlm_check.o \
               libsmb/ntlmssp.o \
-              libsmb/ntlmssp_sign.o \
+              ../libcli/auth/ntlmssp.o \
+              ../libcli/auth/ntlmssp_sign.o \
               $(LIBNDR_NTLMSSP_OBJ) \
               ../libcli/auth/ntlmssp_ndr.o
 
               $(LIBNDR_NTLMSSP_OBJ) \
               ../libcli/auth/ntlmssp_ndr.o
 
index 472e1793cafbf778a9d3bd069c63c25f341e428f..cae51e5ee3d501e99ae733fac915b9a20b6ad6df 100644 (file)
@@ -3135,7 +3135,6 @@ NTSTATUS nt_status_squash(NTSTATUS nt_status);
 
 /* The following definitions come from libsmb/ntlmssp.c  */
 
 
 /* The following definitions come from libsmb/ntlmssp.c  */
 
-void debug_ntlmssp_flags(uint32 neg_flags);
 NTSTATUS ntlmssp_set_username(struct ntlmssp_state *ntlmssp_state, const char *user) ;
 NTSTATUS ntlmssp_set_hashes(struct ntlmssp_state *ntlmssp_state,
                            const uint8_t lm_hash[16],
 NTSTATUS ntlmssp_set_username(struct ntlmssp_state *ntlmssp_state, const char *user) ;
 NTSTATUS ntlmssp_set_hashes(struct ntlmssp_state *ntlmssp_state,
                            const uint8_t lm_hash[16],
@@ -3161,28 +3160,6 @@ NTSTATUS ntlmssp_client_start(TALLOC_CTX *mem_ctx,
                              bool use_ntlmv2,
                              struct ntlmssp_state **_ntlmssp_state);
 
                              bool use_ntlmv2,
                              struct ntlmssp_state **_ntlmssp_state);
 
-/* The following definitions come from libsmb/ntlmssp_sign.c  */
-
-NTSTATUS ntlmssp_sign_packet(struct ntlmssp_state *ntlmssp_state,
-                            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 ntlmssp_check_packet(struct ntlmssp_state *ntlmssp_state,
-                             const uint8_t *data, size_t length,
-                             const uint8_t *whole_pdu, size_t pdu_length,
-                             const DATA_BLOB *sig) ;
-NTSTATUS ntlmssp_seal_packet(struct ntlmssp_state *ntlmssp_state,
-                            TALLOC_CTX *sig_mem_ctx,
-                            uint8_t *data, size_t length,
-                            const uint8_t *whole_pdu, size_t pdu_length,
-                            DATA_BLOB *sig);
-NTSTATUS ntlmssp_unseal_packet(struct ntlmssp_state *ntlmssp_state,
-                              uint8_t *data, size_t length,
-                              const uint8_t *whole_pdu, size_t pdu_length,
-                              const DATA_BLOB *sig);
-NTSTATUS ntlmssp_sign_init(struct ntlmssp_state *ntlmssp_state);
-
 /* The following definitions come from libsmb/passchange.c  */
 
 NTSTATUS remote_password_change(const char *remote_machine, const char *user_name, 
 /* The following definitions come from libsmb/passchange.c  */
 
 NTSTATUS remote_password_change(const char *remote_machine, const char *user_name, 
index 7095426cabf1bb07e29016a68ed68786eb66d426..1d475172fe80c8a1d7e48e95745d8e50ebd0ccde 100644 (file)
@@ -23,6 +23,7 @@
 
 #include "includes.h"
 #include "../libcli/auth/ntlmssp.h"
 
 #include "includes.h"
 #include "../libcli/auth/ntlmssp.h"
+#include "../libcli/auth/ntlmssp_private.h"
 #include "../libcli/auth/libcli_auth.h"
 #include "../librpc/gen_ndr/ndr_ntlmssp.h"
 #include "../libcli/auth/ntlmssp_ndr.h"
 #include "../libcli/auth/libcli_auth.h"
 #include "../librpc/gen_ndr/ndr_ntlmssp.h"
 #include "../libcli/auth/ntlmssp_ndr.h"
@@ -59,57 +60,6 @@ static const struct ntlmssp_callbacks {
 };
 
 
 };
 
 
-/**
- * Print out the NTLMSSP flags for debugging
- * @param neg_flags The flags from the packet
- */
-
-void debug_ntlmssp_flags(uint32_t neg_flags)
-{
-       DEBUG(3,("Got NTLMSSP neg_flags=0x%08x\n", neg_flags));
-
-       if (neg_flags & NTLMSSP_NEGOTIATE_UNICODE)
-               DEBUGADD(4, ("  NTLMSSP_NEGOTIATE_UNICODE\n"));
-       if (neg_flags & NTLMSSP_NEGOTIATE_OEM)
-               DEBUGADD(4, ("  NTLMSSP_NEGOTIATE_OEM\n"));
-       if (neg_flags & NTLMSSP_REQUEST_TARGET)
-               DEBUGADD(4, ("  NTLMSSP_REQUEST_TARGET\n"));
-       if (neg_flags & NTLMSSP_NEGOTIATE_SIGN)
-               DEBUGADD(4, ("  NTLMSSP_NEGOTIATE_SIGN\n"));
-       if (neg_flags & NTLMSSP_NEGOTIATE_SEAL)
-               DEBUGADD(4, ("  NTLMSSP_NEGOTIATE_SEAL\n"));
-       if (neg_flags & NTLMSSP_NEGOTIATE_DATAGRAM)
-               DEBUGADD(4, ("  NTLMSSP_NEGOTIATE_DATAGRAM\n"));
-       if (neg_flags & NTLMSSP_NEGOTIATE_LM_KEY)
-               DEBUGADD(4, ("  NTLMSSP_NEGOTIATE_LM_KEY\n"));
-       if (neg_flags & NTLMSSP_NEGOTIATE_NETWARE)
-               DEBUGADD(4, ("  NTLMSSP_NEGOTIATE_NETWARE\n"));
-       if (neg_flags & NTLMSSP_NEGOTIATE_NTLM)
-               DEBUGADD(4, ("  NTLMSSP_NEGOTIATE_NTLM\n"));
-       if (neg_flags & NTLMSSP_NEGOTIATE_OEM_DOMAIN_SUPPLIED)
-               DEBUGADD(4, ("  NTLMSSP_NEGOTIATE_OEM_DOMAIN_SUPPLIED\n"));
-       if (neg_flags & NTLMSSP_NEGOTIATE_OEM_WORKSTATION_SUPPLIED)
-               DEBUGADD(4, ("  NTLMSSP_NEGOTIATE_OEM_WORKSTATION_SUPPLIED\n"));
-       if (neg_flags & NTLMSSP_NEGOTIATE_THIS_IS_LOCAL_CALL)
-               DEBUGADD(4, ("  NTLMSSP_NEGOTIATE_THIS_IS_LOCAL_CALL\n"));
-       if (neg_flags & NTLMSSP_NEGOTIATE_ALWAYS_SIGN)
-               DEBUGADD(4, ("  NTLMSSP_NEGOTIATE_ALWAYS_SIGN\n"));
-       if (neg_flags & NTLMSSP_REQUEST_NON_NT_SESSION_KEY)
-               DEBUGADD(4, ("  NTLMSSP_REQUEST_NON_NT_SESSION_KEY\n"));
-       if (neg_flags & NTLMSSP_NEGOTIATE_NTLM2)
-               DEBUGADD(4, ("  NTLMSSP_NEGOTIATE_NTLM2\n"));
-       if (neg_flags & NTLMSSP_NEGOTIATE_TARGET_INFO)
-               DEBUGADD(4, ("  NTLMSSP_NEGOTIATE_TARGET_INFO\n"));
-       if (neg_flags & NTLMSSP_NEGOTIATE_VERSION)
-               DEBUGADD(4, ("  NTLMSSP_NEGOTIATE_VERSION\n"));
-       if (neg_flags & NTLMSSP_NEGOTIATE_128)
-               DEBUGADD(4, ("  NTLMSSP_NEGOTIATE_128\n"));
-       if (neg_flags & NTLMSSP_NEGOTIATE_KEY_EXCH)
-               DEBUGADD(4, ("  NTLMSSP_NEGOTIATE_KEY_EXCH\n"));
-       if (neg_flags & NTLMSSP_NEGOTIATE_56)
-               DEBUGADD(4, ("  NTLMSSP_NEGOTIATE_56\n"));
-}
-
 /**
  * Default challenge generation code.
  *
 /**
  * Default challenge generation code.
  *