summaryrefslogtreecommitdiff
path: root/source4/auth/gensec
diff options
context:
space:
mode:
authorSimo Sorce <idra@samba.org>2012-03-31 21:48:06 -0400
committerAndreas Schneider <asn@samba.org>2012-04-12 12:06:43 +0200
commit3fd6deda7d440b579950ab6d0e2407d755ac70ad (patch)
treeee14c11dfb88b808e257267d52a8ed3dc5ea4637 /source4/auth/gensec
parentd857e393ac870f71943fc6b099e494f45afb6b48 (diff)
downloadsamba-3fd6deda7d440b579950ab6d0e2407d755ac70ad.tar.gz
samba-3fd6deda7d440b579950ab6d0e2407d755ac70ad.tar.bz2
samba-3fd6deda7d440b579950ab6d0e2407d755ac70ad.zip
auth-krb: Make functions static.
The remaining gssapi_parse functions were used exclusively in gensec_krb5. Move them there and make them static. Signed-off-by: Andreas Schneider <asn@samba.org>
Diffstat (limited to 'source4/auth/gensec')
-rw-r--r--source4/auth/gensec/gensec_krb5.c71
1 files changed, 71 insertions, 0 deletions
diff --git a/source4/auth/gensec/gensec_krb5.c b/source4/auth/gensec/gensec_krb5.c
index 9939105ad5..ca933f5b0f 100644
--- a/source4/auth/gensec/gensec_krb5.c
+++ b/source4/auth/gensec/gensec_krb5.c
@@ -39,6 +39,7 @@
#include "param/param.h"
#include "auth/auth_sam_reply.h"
#include "lib/util/util_net.h"
+#include "../lib/util/asn1.h"
_PUBLIC_ NTSTATUS gensec_krb5_init(void);
@@ -392,6 +393,76 @@ static NTSTATUS gensec_fake_gssapi_krb5_client_start(struct gensec_security *gen
return gensec_krb5_common_client_start(gensec_security, true);
}
+
+/*
+ generate a krb5 GSS-API wrapper packet given a ticket
+*/
+static DATA_BLOB gensec_gssapi_gen_krb5_wrap(TALLOC_CTX *mem_ctx, const DATA_BLOB *ticket, const uint8_t tok_id[2])
+{
+ struct asn1_data *data;
+ DATA_BLOB ret;
+
+ data = asn1_init(mem_ctx);
+ if (!data || !ticket->data) {
+ return data_blob(NULL,0);
+ }
+
+ asn1_push_tag(data, ASN1_APPLICATION(0));
+ asn1_write_OID(data, GENSEC_OID_KERBEROS5);
+
+ asn1_write(data, tok_id, 2);
+ asn1_write(data, ticket->data, ticket->length);
+ asn1_pop_tag(data);
+
+ if (data->has_error) {
+ DEBUG(1,("Failed to build krb5 wrapper at offset %d\n", (int)data->ofs));
+ asn1_free(data);
+ return data_blob(NULL,0);
+ }
+
+ ret = data_blob_talloc(mem_ctx, data->data, data->length);
+ asn1_free(data);
+
+ return ret;
+}
+
+/*
+ parse a krb5 GSS-API wrapper packet giving a ticket
+*/
+static bool gensec_gssapi_parse_krb5_wrap(TALLOC_CTX *mem_ctx, const DATA_BLOB *blob, DATA_BLOB *ticket, uint8_t tok_id[2])
+{
+ bool ret;
+ struct asn1_data *data = asn1_init(mem_ctx);
+ int data_remaining;
+
+ if (!data) {
+ return false;
+ }
+
+ asn1_load(data, *blob);
+ asn1_start_tag(data, ASN1_APPLICATION(0));
+ asn1_check_OID(data, GENSEC_OID_KERBEROS5);
+
+ data_remaining = asn1_tag_remaining(data);
+
+ if (data_remaining < 3) {
+ data->has_error = true;
+ } else {
+ asn1_read(data, tok_id, 2);
+ data_remaining -= 2;
+ *ticket = data_blob_talloc(mem_ctx, NULL, data_remaining);
+ asn1_read(data, ticket->data, ticket->length);
+ }
+
+ asn1_end_tag(data);
+
+ ret = !data->has_error;
+
+ asn1_free(data);
+
+ return ret;
+}
+
/**
* Next state function for the Krb5 GENSEC mechanism
*