auth/gensec: introduce gensec_internal.h
authorStefan Metzmacher <metze@samba.org>
Mon, 5 Aug 2013 05:12:01 +0000 (07:12 +0200)
committerStefan Metzmacher <metze@samba.org>
Sat, 10 Aug 2013 07:19:02 +0000 (09:19 +0200)
We should treat most gensec related structures private.

It's a long way, but this is a start.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
24 files changed:
auth/gensec/gensec.c
auth/gensec/gensec.h
auth/gensec/gensec_internal.h [new file with mode: 0644]
auth/gensec/gensec_start.c
auth/gensec/gensec_util.c
auth/gensec/spnego.c
auth/ntlmssp/gensec_ntlmssp.c
auth/ntlmssp/gensec_ntlmssp_server.c
auth/ntlmssp/ntlmssp.c
auth/ntlmssp/ntlmssp_client.c
auth/ntlmssp/ntlmssp_server.c
source3/libads/authdata.c
source3/librpc/crypto/gse.c
source3/libsmb/ntlmssp_wrap.c
source3/utils/ntlm_auth.c
source4/auth/gensec/cyrus_sasl.c
source4/auth/gensec/gensec_gssapi.c
source4/auth/gensec/gensec_krb5.c
source4/auth/gensec/pygensec.c
source4/auth/gensec/schannel.c
source4/ldap_server/ldap_backend.c
source4/libcli/ldap/ldap_bind.c
source4/torture/auth/ntlmssp.c
source4/utils/ntlm_auth.c

index 9a8f0ef15ac1ac7ed85422a7cb3e6952037138f5..d364a344a999bb99848fb01e7dcddaaf94ff2444 100644 (file)
@@ -26,6 +26,7 @@
 #include "lib/tsocket/tsocket.h"
 #include "lib/util/tevent_ntstatus.h"
 #include "auth/gensec/gensec.h"
+#include "auth/gensec/gensec_internal.h"
 #include "librpc/rpc/dcerpc.h"
 
 /*
index c080861664d244b7a253d574a6dd74f805f149a1..5d39d8188fac4ca68ba6a83646d33c01268ecb9a 100644 (file)
@@ -76,6 +76,7 @@ struct gensec_settings;
 struct tevent_context;
 struct tevent_req;
 struct smb_krb5_context;
+struct tsocket_address;
 
 struct gensec_settings {
        struct loadparm_context *lp_ctx;
@@ -93,106 +94,13 @@ struct gensec_settings {
        const char *server_netbios_name;
 };
 
-struct gensec_security_ops {
-       const char *name;
-       const char *sasl_name;
-       uint8_t auth_type;  /* 0 if not offered on DCE-RPC */
-       const char **oid;  /* NULL if not offered by SPNEGO */
-       NTSTATUS (*client_start)(struct gensec_security *gensec_security);
-       NTSTATUS (*server_start)(struct gensec_security *gensec_security);
-       /**
-          Determine if a packet has the right 'magic' for this mechanism
-       */
-       NTSTATUS (*magic)(struct gensec_security *gensec_security,
-                         const DATA_BLOB *first_packet);
-       NTSTATUS (*update)(struct gensec_security *gensec_security, TALLOC_CTX *out_mem_ctx,
-                          struct tevent_context *ev,
-                          const DATA_BLOB in, DATA_BLOB *out);
-       NTSTATUS (*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 (*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);
-       size_t   (*sig_size)(struct gensec_security *gensec_security, size_t data_size);
-       size_t   (*max_input_size)(struct gensec_security *gensec_security);
-       size_t   (*max_wrapped_size)(struct gensec_security *gensec_security);
-       NTSTATUS (*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 (*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);
-       NTSTATUS (*wrap)(struct gensec_security *gensec_security,
-                                 TALLOC_CTX *mem_ctx,
-                                 const DATA_BLOB *in,
-                                 DATA_BLOB *out);
-       NTSTATUS (*unwrap)(struct gensec_security *gensec_security,
-                          TALLOC_CTX *mem_ctx,
-                          const DATA_BLOB *in,
-                          DATA_BLOB *out);
-       NTSTATUS (*wrap_packets)(struct gensec_security *gensec_security,
-                                TALLOC_CTX *mem_ctx,
-                                const DATA_BLOB *in,
-                                DATA_BLOB *out,
-                                size_t *len_processed);
-       NTSTATUS (*unwrap_packets)(struct gensec_security *gensec_security,
-                                  TALLOC_CTX *mem_ctx,
-                                  const DATA_BLOB *in,
-                                  DATA_BLOB *out,
-                                  size_t *len_processed);
-       NTSTATUS (*packet_full_request)(struct gensec_security *gensec_security,
-                                       DATA_BLOB blob, size_t *size);
-       NTSTATUS (*session_key)(struct gensec_security *gensec_security, TALLOC_CTX *mem_ctx,
-                               DATA_BLOB *session_key);
-       NTSTATUS (*session_info)(struct gensec_security *gensec_security, TALLOC_CTX *mem_ctx,
-                                struct auth_session_info **session_info);
-       void (*want_feature)(struct gensec_security *gensec_security,
-                                   uint32_t feature);
-       bool (*have_feature)(struct gensec_security *gensec_security,
-                                   uint32_t feature);
-       NTTIME (*expire_time)(struct gensec_security *gensec_security);
-       bool enabled;
-       bool kerberos;
-       enum gensec_priority priority;
-};
-
-struct gensec_security_ops_wrapper {
-       const struct gensec_security_ops *op;
-       const char *oid;
-};
+struct gensec_security_ops;
+struct gensec_security_ops_wrapper;
 
 #define GENSEC_INTERFACE_VERSION 0
 
-struct gensec_security {
-       const struct gensec_security_ops *ops;
-       void *private_data;
-       struct cli_credentials *credentials;
-       struct gensec_target target;
-       enum gensec_role gensec_role;
-       bool subcontext;
-       uint32_t want_features;
-       uint32_t max_update_size;
-       uint8_t dcerpc_auth_level;
-       struct tsocket_address *local_addr, *remote_addr;
-       struct gensec_settings *settings;
-
-       /* When we are a server, this may be filled in to provide an
-        * NTLM authentication backend, and user lookup (such as if no
-        * PAC is found) */
-       struct auth4_context *auth_context;
-};
-
 /* this structure is used by backends to determine the size of some critical types */
-struct gensec_critical_sizes {
-       int interface_version;
-       int sizeof_gensec_security_ops;
-       int sizeof_gensec_security;
-};
+struct gensec_critical_sizes;
 const struct gensec_critical_sizes *gensec_interface_version(void);
 
 /* Socket wrapper */
diff --git a/auth/gensec/gensec_internal.h b/auth/gensec/gensec_internal.h
new file mode 100644 (file)
index 0000000..41b6f0d
--- /dev/null
@@ -0,0 +1,127 @@
+/*
+   Unix SMB/CIFS implementation.
+
+   Generic Authentication Interface
+
+   Copyright (C) Andrew Tridgell 2003
+   Copyright (C) Andrew Bartlett <abartlet@samba.org> 2004-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/>.
+*/
+
+#ifndef __GENSEC_INTERNAL_H__
+#define __GENSEC_INTERNAL_H__
+
+struct gensec_security;
+
+struct gensec_security_ops {
+       const char *name;
+       const char *sasl_name;
+       uint8_t auth_type;  /* 0 if not offered on DCE-RPC */
+       const char **oid;  /* NULL if not offered by SPNEGO */
+       NTSTATUS (*client_start)(struct gensec_security *gensec_security);
+       NTSTATUS (*server_start)(struct gensec_security *gensec_security);
+       /**
+          Determine if a packet has the right 'magic' for this mechanism
+       */
+       NTSTATUS (*magic)(struct gensec_security *gensec_security,
+                         const DATA_BLOB *first_packet);
+       NTSTATUS (*update)(struct gensec_security *gensec_security, TALLOC_CTX *out_mem_ctx,
+                          struct tevent_context *ev,
+                          const DATA_BLOB in, DATA_BLOB *out);
+       NTSTATUS (*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 (*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);
+       size_t   (*sig_size)(struct gensec_security *gensec_security, size_t data_size);
+       size_t   (*max_input_size)(struct gensec_security *gensec_security);
+       size_t   (*max_wrapped_size)(struct gensec_security *gensec_security);
+       NTSTATUS (*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 (*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);
+       NTSTATUS (*wrap)(struct gensec_security *gensec_security,
+                                 TALLOC_CTX *mem_ctx,
+                                 const DATA_BLOB *in,
+                                 DATA_BLOB *out);
+       NTSTATUS (*unwrap)(struct gensec_security *gensec_security,
+                          TALLOC_CTX *mem_ctx,
+                          const DATA_BLOB *in,
+                          DATA_BLOB *out);
+       NTSTATUS (*wrap_packets)(struct gensec_security *gensec_security,
+                                TALLOC_CTX *mem_ctx,
+                                const DATA_BLOB *in,
+                                DATA_BLOB *out,
+                                size_t *len_processed);
+       NTSTATUS (*unwrap_packets)(struct gensec_security *gensec_security,
+                                  TALLOC_CTX *mem_ctx,
+                                  const DATA_BLOB *in,
+                                  DATA_BLOB *out,
+                                  size_t *len_processed);
+       NTSTATUS (*packet_full_request)(struct gensec_security *gensec_security,
+                                       DATA_BLOB blob, size_t *size);
+       NTSTATUS (*session_key)(struct gensec_security *gensec_security, TALLOC_CTX *mem_ctx,
+                               DATA_BLOB *session_key);
+       NTSTATUS (*session_info)(struct gensec_security *gensec_security, TALLOC_CTX *mem_ctx,
+                                struct auth_session_info **session_info);
+       void (*want_feature)(struct gensec_security *gensec_security,
+                                   uint32_t feature);
+       bool (*have_feature)(struct gensec_security *gensec_security,
+                                   uint32_t feature);
+       NTTIME (*expire_time)(struct gensec_security *gensec_security);
+       bool enabled;
+       bool kerberos;
+       enum gensec_priority priority;
+};
+
+struct gensec_security_ops_wrapper {
+       const struct gensec_security_ops *op;
+       const char *oid;
+};
+
+struct gensec_security {
+       const struct gensec_security_ops *ops;
+       void *private_data;
+       struct cli_credentials *credentials;
+       struct gensec_target target;
+       enum gensec_role gensec_role;
+       bool subcontext;
+       uint32_t want_features;
+       uint32_t max_update_size;
+       uint8_t dcerpc_auth_level;
+       struct tsocket_address *local_addr, *remote_addr;
+       struct gensec_settings *settings;
+
+       /* When we are a server, this may be filled in to provide an
+        * NTLM authentication backend, and user lookup (such as if no
+        * PAC is found) */
+       struct auth4_context *auth_context;
+};
+
+/* this structure is used by backends to determine the size of some critical types */
+struct gensec_critical_sizes {
+       int interface_version;
+       int sizeof_gensec_security_ops;
+       int sizeof_gensec_security;
+};
+
+#endif /* __GENSEC_H__ */
index c2cfa1c3759fe90eb45c65a391966dbb5ff75a79..34029f5d88f88eaca4b6de8069f0c284b79a339c 100644 (file)
@@ -27,6 +27,7 @@
 #include "librpc/rpc/dcerpc.h"
 #include "auth/credentials/credentials.h"
 #include "auth/gensec/gensec.h"
+#include "auth/gensec/gensec_internal.h"
 #include "lib/param/param.h"
 #include "lib/util/tsort.h"
 #include "lib/util/samba_modules.h"
index 64952b198374ef66d09ff084661c7dbd3d8551a4..568128add153327b82086aeee0d6307ef1b920d7 100644 (file)
@@ -22,6 +22,7 @@
 
 #include "includes.h"
 #include "auth/gensec/gensec.h"
+#include "auth/gensec/gensec_internal.h"
 #include "auth/common_auth.h"
 #include "../lib/util/asn1.h"
 
index da1fc0ecde50599adeff73bb5be6bfa6a49290c6..38a45f8bdca5ec179eef32942e5ccc740ebd5ec2 100644 (file)
@@ -27,6 +27,7 @@
 #include "librpc/gen_ndr/ndr_dcerpc.h"
 #include "auth/credentials/credentials.h"
 #include "auth/gensec/gensec.h"
+#include "auth/gensec/gensec_internal.h"
 #include "param/param.h"
 #include "lib/util/asn1.h"
 
index 9e1d8a839e82057eb22c9a45f2cf29eddf415d0f..654c0e3cba3370f9b512fcfa70a6a870f395d8fc 100644 (file)
@@ -22,6 +22,7 @@
 #include "includes.h"
 #include "auth/ntlmssp/ntlmssp.h"
 #include "auth/gensec/gensec.h"
+#include "auth/gensec/gensec_internal.h"
 #include "auth/ntlmssp/ntlmssp_private.h"
 
 NTSTATUS gensec_ntlmssp_magic(struct gensec_security *gensec_security,
index f4dfab3856663194f28ada54e722623491755cf6..69c56fbbfbb04295a9069dc95bc3438a0c0b931c 100644 (file)
@@ -31,6 +31,7 @@
 #include "../libcli/auth/libcli_auth.h"
 #include "../lib/crypto/crypto.h"
 #include "auth/gensec/gensec.h"
+#include "auth/gensec/gensec_internal.h"
 #include "auth/common_auth.h"
 #include "param/param.h"
 
index 1a2d662439075597e4417c7cfcbfc914160e8804..916b376b1111e1e47c9c1175a168b32de281902d 100644 (file)
@@ -29,6 +29,7 @@ struct auth_session_info;
 #include "../libcli/auth/libcli_auth.h"
 #include "librpc/gen_ndr/ndr_dcerpc.h"
 #include "auth/gensec/gensec.h"
+#include "auth/gensec/gensec_internal.h"
 
 /**
  * Callbacks for NTLMSSP - for both client and server operating modes
index fc66a8d8e33b402885be7a32d52a58adf4db9227..f99257d7312ed82432a5dda755e7e53641a91ece 100644 (file)
@@ -29,6 +29,7 @@ struct auth_session_info;
 #include "../libcli/auth/libcli_auth.h"
 #include "auth/credentials/credentials.h"
 #include "auth/gensec/gensec.h"
+#include "auth/gensec/gensec_internal.h"
 #include "param/param.h"
 #include "auth/ntlmssp/ntlmssp_private.h"
 #include "../librpc/gen_ndr/ndr_ntlmssp.h"
index 57179e1dcae4679e594947b1735bd8049a1ddc6a..2f3f0bb723f8107c133e4ed02f2895dce3666cff 100644 (file)
@@ -28,6 +28,7 @@
 #include "../libcli/auth/libcli_auth.h"
 #include "../lib/crypto/crypto.h"
 #include "auth/gensec/gensec.h"
+#include "auth/gensec/gensec_internal.h"
 #include "auth/common_auth.h"
 
 /**
index 2c667a66bcd3dcea68c0dda7991ddb4cdf768313..582917da010cfddca9b6cdea01bcad11a2da0ef0 100644 (file)
@@ -30,6 +30,7 @@
 #include "lib/param/param.h"
 #include "librpc/crypto/gse.h"
 #include "auth/gensec/gensec.h"
+#include "auth/gensec/gensec_internal.h" /* TODO: remove this */
 #include "../libcli/auth/spnego.h"
 
 #ifdef HAVE_KRB5
index 11a545727b74c3f1c7eaf3a96653b09766632b68..8db3cdd227aa442fbaec84e7741d83736cfa0775 100644 (file)
@@ -26,6 +26,7 @@
 #include "libads/kerberos_proto.h"
 #include "auth/common_auth.h"
 #include "auth/gensec/gensec.h"
+#include "auth/gensec/gensec_internal.h"
 #include "auth/credentials/credentials.h"
 #include "../librpc/gen_ndr/dcerpc.h"
 
index 9ce4b12645b873ae95c3bab6edd4db988660eee1..46f68aede79271e189a883e06f4e411d6fd64cc4 100644 (file)
@@ -23,6 +23,7 @@
 #include "auth/ntlmssp/ntlmssp_private.h"
 #include "auth_generic.h"
 #include "auth/gensec/gensec.h"
+#include "auth/gensec/gensec_internal.h"
 #include "auth/credentials/credentials.h"
 #include "librpc/rpc/dcerpc.h"
 #include "lib/param/param.h"
index 8f51a1a0b3206423530c363483c5dc93563131fe..9e0d7b812b05b8ea69a7bd02efbf2aeac582f7ed 100644 (file)
@@ -32,6 +32,7 @@
 #include "../libcli/auth/spnego.h"
 #include "auth/ntlmssp/ntlmssp.h"
 #include "auth/gensec/gensec.h"
+#include "auth/gensec/gensec_internal.h"
 #include "auth/credentials/credentials.h"
 #include "librpc/crypto/gse.h"
 #include "smb_krb5.h"
index 2e733bfe0b9f76f7b9083d999093dc254ceb6536..08dccd6f5d1c1547b46fa438197e100cf14601ad 100644 (file)
@@ -23,6 +23,7 @@
 #include "lib/tsocket/tsocket.h"
 #include "auth/credentials/credentials.h"
 #include "auth/gensec/gensec.h"
+#include "auth/gensec/gensec_internal.h"
 #include "auth/gensec/gensec_proto.h"
 #include "auth/gensec/gensec_toplevel_proto.h"
 #include <sasl/sasl.h>
index 3e35cae28c228576a05041f7a415fcd2a89cb591..c384914f922ae3ddbccff0f8b05eb1234ad35550 100644 (file)
@@ -34,6 +34,7 @@
 #include "auth/credentials/credentials.h"
 #include "auth/credentials/credentials_krb5.h"
 #include "auth/gensec/gensec.h"
+#include "auth/gensec/gensec_internal.h"
 #include "auth/gensec/gensec_proto.h"
 #include "auth/gensec/gensec_toplevel_proto.h"
 #include "param/param.h"
index fbec64c4ea8b00b6ebcf5f57d5082d8a03f7932e..ecc33319b9a661942b489d9f6891f170db5b80f3 100644 (file)
@@ -34,6 +34,7 @@
 #include "auth/credentials/credentials_krb5.h"
 #include "auth/kerberos/kerberos_credentials.h"
 #include "auth/gensec/gensec.h"
+#include "auth/gensec/gensec_internal.h"
 #include "auth/gensec/gensec_proto.h"
 #include "auth/gensec/gensec_toplevel_proto.h"
 #include "param/param.h"
index 02e5ae28cec1d4551d7a9fcee16ec7f6559a722b..fd6daff3d67c118726041018cc6d591f94bf4e09 100644 (file)
@@ -20,6 +20,7 @@
 #include "includes.h"
 #include "param/pyparam.h"
 #include "auth/gensec/gensec.h"
+#include "auth/gensec/gensec_internal.h" /* TODO: remove this */
 #include "auth/credentials/pycredentials.h"
 #include "libcli/util/pyerrors.h"
 #include "python/modules.h"
index e67432c0fdac3dcd36c88907942476a3eb8b3cb3..eb2e100e2e526719d57671d27685a2609b127503 100644 (file)
@@ -25,6 +25,7 @@
 #include "auth/auth.h"
 #include "auth/credentials/credentials.h"
 #include "auth/gensec/gensec.h"
+#include "auth/gensec/gensec_internal.h"
 #include "auth/gensec/gensec_proto.h"
 #include "../libcli/auth/schannel.h"
 #include "librpc/gen_ndr/dcerpc.h"
index f415e9bf62a8c2dfebb6a2467ea611d6f8aefa67..42185316da0addfeef1d7d0a117c5dbf363bec82 100644 (file)
@@ -23,6 +23,7 @@
 #include "../lib/util/dlinklist.h"
 #include "auth/credentials/credentials.h"
 #include "auth/gensec/gensec.h"
+#include "auth/gensec/gensec_internal.h" /* TODO: remove this */
 #include "param/param.h"
 #include "smbd/service_stream.h"
 #include "dsdb/samdb/samdb.h"
index b355e18e0d31ba9b50e74dc396a5d84720d91fc1..f0a498b62099c751d5c7fcc67bd459ca6a0ea6ca 100644 (file)
@@ -27,6 +27,7 @@
 #include "libcli/ldap/ldap_client.h"
 #include "lib/tls/tls.h"
 #include "auth/gensec/gensec.h"
+#include "auth/gensec/gensec_internal.h" /* TODO: remove this */
 #include "auth/gensec/gensec_socket.h"
 #include "auth/credentials/credentials.h"
 #include "lib/stream/packet.h"
index bdaa65b9af027d518d6702a0d03aab6c52841ecc..45e58890eb6bff861bf1a858bb9115d8a15ab82a 100644 (file)
@@ -19,6 +19,7 @@
 
 #include "includes.h"
 #include "auth/gensec/gensec.h"
+#include "auth/gensec/gensec_internal.h"
 #include "auth/ntlmssp/ntlmssp.h"
 #include "auth/ntlmssp/ntlmssp_private.h"
 #include "lib/cmdline/popt_common.h"
index 136e2387edd70659bd208dcacf0db8947d5d8274..1e2feb0bc19c7e9d88532e3ee3d2355c9822f7d6 100644 (file)
@@ -27,6 +27,7 @@
 #include <ldb.h>
 #include "auth/credentials/credentials.h"
 #include "auth/gensec/gensec.h"
+#include "auth/gensec/gensec_internal.h" /* TODO: remove this */
 #include "auth/auth.h"
 #include "librpc/gen_ndr/ndr_netlogon.h"
 #include "auth/auth_sam.h"