summaryrefslogtreecommitdiffstats
path: root/src/lib/gssapi/check_tok.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/gssapi/check_tok.c')
-rw-r--r--src/lib/gssapi/check_tok.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/src/lib/gssapi/check_tok.c b/src/lib/gssapi/check_tok.c
new file mode 100644
index 000000000..24073490a
--- /dev/null
+++ b/src/lib/gssapi/check_tok.c
@@ -0,0 +1,47 @@
+/*
+ * check_tok.c --- Read a GSS API token and do error checking
+ * checking on it.
+ *
+ * $Source$
+ * $Author$
+ * $Header$
+ *
+ * Copyright 1991 by the Massachusetts Institute of Technology.
+ * All Rights Reserved.
+ *
+ * For copying and distribution information, please see the file
+ * <krb5/copyright.h>.
+ *
+ */
+
+#include <gssapi.h>
+
+OM_uint32 gss_check_token(minor_status, input_token, mechanism, type)
+ OM_uint32 *minor_status;
+ gss_buffer_t input_token;
+ unsigned char mechanism;
+ unsigned char type;
+{
+ char *buf;
+
+ *minor_status = 0;
+
+ if (!input_token)
+ return(gss_make_ce(GSS_CE_CALL_INACCESSIBLE_READ));
+
+ if (input_token->length < 4)
+ return(gss_make_re(GSS_RE_DEFECTIVE_TOKEN));
+
+ buf = input_token->value;
+
+ if (buf[0] != GSS_API_IMPL_VERSION)
+ return(gss_make_re(GSS_RE_DEFECTIVE_TOKEN));
+
+ if (mechanism && (mechanism != buf[1]))
+ return(gss_make_re(GSS_RE_BAD_MECH));
+
+ if (type && (type != buf[2]))
+ return(gss_make_re(GSS_RE_FAILURE) | GSS_SS_UNSEQ_TOKEN);
+
+ return(GSS_S_COMPLETE);
+}