auth/gensec: remove unused gensec_[un]wrap_packets() hooks
[Samba.git] / auth / gensec / gensec_util.c
blob8ef4b252affa8936ef163556e7859b91f0b8a088
1 /*
2 Unix SMB/CIFS implementation.
4 Generic Authentication Interface
6 Copyright (C) Andrew Tridgell 2003
7 Copyright (C) Andrew Bartlett <abartlet@samba.org> 2004-2006
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 3 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program. If not, see <http://www.gnu.org/licenses/>.
23 #include "includes.h"
24 #include "auth/gensec/gensec.h"
25 #include "auth/gensec/gensec_internal.h"
26 #include "auth/common_auth.h"
27 #include "../lib/util/asn1.h"
29 NTSTATUS gensec_generate_session_info_pac(TALLOC_CTX *mem_ctx,
30 struct gensec_security *gensec_security,
31 struct smb_krb5_context *smb_krb5_context,
32 DATA_BLOB *pac_blob,
33 const char *principal_string,
34 const struct tsocket_address *remote_address,
35 struct auth_session_info **session_info)
37 uint32_t session_info_flags = 0;
39 if (gensec_security->want_features & GENSEC_FEATURE_UNIX_TOKEN) {
40 session_info_flags |= AUTH_SESSION_INFO_UNIX_TOKEN;
43 session_info_flags |= AUTH_SESSION_INFO_DEFAULT_GROUPS;
45 if (!pac_blob) {
46 if (gensec_setting_bool(gensec_security->settings, "gensec", "require_pac", false)) {
47 DEBUG(1, ("Unable to find PAC in ticket from %s, failing to allow access\n",
48 principal_string));
49 return NT_STATUS_ACCESS_DENIED;
51 DEBUG(1, ("Unable to find PAC for %s, resorting to local user lookup\n",
52 principal_string));
55 if (gensec_security->auth_context && gensec_security->auth_context->generate_session_info_pac) {
56 return gensec_security->auth_context->generate_session_info_pac(gensec_security->auth_context,
57 mem_ctx,
58 smb_krb5_context,
59 pac_blob,
60 principal_string,
61 remote_address,
62 session_info_flags,
63 session_info);
64 } else {
65 DEBUG(0, ("Cannot generate a session_info without the auth_context\n"));
66 return NT_STATUS_INTERNAL_ERROR;
71 magic check a GSS-API wrapper packet for an Kerberos OID
73 static bool gensec_gssapi_check_oid(const DATA_BLOB *blob, const char *oid)
75 bool ret = false;
76 struct asn1_data *data = asn1_init(NULL);
78 if (!data) return false;
80 if (!asn1_load(data, *blob)) goto err;
81 if (!asn1_start_tag(data, ASN1_APPLICATION(0))) goto err;
82 if (!asn1_check_OID(data, oid)) goto err;
84 ret = !data->has_error;
86 err:
88 asn1_free(data);
89 return ret;
92 /**
93 * Check if the packet is one for the KRB5 mechansim
95 * NOTE: This is a helper that can be employed by multiple mechanisms, do
96 * not make assumptions about the private_data
98 * @param gensec_security GENSEC state, unused
99 * @param in The request, as a DATA_BLOB
100 * @return Error, INVALID_PARAMETER if it's not a packet for us
101 * or NT_STATUS_OK if the packet is ok.
104 NTSTATUS gensec_magic_check_krb5_oid(struct gensec_security *unused,
105 const DATA_BLOB *blob)
107 if (gensec_gssapi_check_oid(blob, GENSEC_OID_KERBEROS5)) {
108 return NT_STATUS_OK;
109 } else {
110 return NT_STATUS_INVALID_PARAMETER;