2 Unix SMB/CIFS implementation.
6 Copyright (C) Andrew Tridgell 2001
7 Copyright (C) Jim McDonough <jmcd@us.ibm.com> 2002
8 Copyright (C) Luke Howard 2003
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2 of the License, or
13 (at your option) any later version.
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 #include "libcli/util/asn_1.h"
27 #include "auth/gensec/gensec.h"
30 generate a krb5 GSS-API wrapper packet given a ticket
32 DATA_BLOB gensec_gssapi_gen_krb5_wrap(TALLOC_CTX *mem_ctx, const DATA_BLOB *ticket, const uint8_t tok_id[2])
34 struct asn1_data data;
35 DATA_BLOB ret = data_blob(NULL,0);
43 asn1_push_tag(&data, ASN1_APPLICATION(0));
44 asn1_write_OID(&data, GENSEC_OID_KERBEROS5);
46 asn1_write(&data, tok_id, 2);
47 asn1_write(&data, ticket->data, ticket->length);
51 DEBUG(1,("Failed to build krb5 wrapper at offset %d\n", (int)data.ofs));
55 ret = data_blob_talloc(mem_ctx, data.data, data.length);
62 parse a krb5 GSS-API wrapper packet giving a ticket
64 BOOL gensec_gssapi_parse_krb5_wrap(TALLOC_CTX *mem_ctx, const DATA_BLOB *blob, DATA_BLOB *ticket, uint8_t tok_id[2])
67 struct asn1_data data;
70 asn1_load(&data, *blob);
71 asn1_start_tag(&data, ASN1_APPLICATION(0));
72 asn1_check_OID(&data, GENSEC_OID_KERBEROS5);
74 data_remaining = asn1_tag_remaining(&data);
76 if (data_remaining < 3) {
77 data.has_error = True;
79 asn1_read(&data, tok_id, 2);
81 *ticket = data_blob_talloc(mem_ctx, NULL, data_remaining);
82 asn1_read(&data, ticket->data, ticket->length);
87 ret = !data.has_error;
96 check a GSS-API wrapper packet givin an expected OID
98 BOOL gensec_gssapi_check_oid(const DATA_BLOB *blob, const char *oid)
101 struct asn1_data data;
103 asn1_load(&data, *blob);
104 asn1_start_tag(&data, ASN1_APPLICATION(0));
105 asn1_check_OID(&data, GENSEC_OID_KERBEROS5);
107 ret = !data.has_error;