*** empty log message ***
authorJohn Kohl <jtkohl@mit.edu>
Thu, 17 May 1990 13:08:49 +0000 (13:08 +0000)
committerJohn Kohl <jtkohl@mit.edu>
Thu, 17 May 1990 13:08:49 +0000 (13:08 +0000)
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@871 dc483132-0cff-0310-8789-dd5450dbe970

src/lib/krb5/krb/rd_req_sim.c [new file with mode: 0644]

diff --git a/src/lib/krb5/krb/rd_req_sim.c b/src/lib/krb5/krb/rd_req_sim.c
new file mode 100644 (file)
index 0000000..49d8ca2
--- /dev/null
@@ -0,0 +1,98 @@
+/*
+ * $Source$
+ * $Author$
+ *
+ * Copyright 1990 by the Massachusetts Institute of Technology.
+ *
+ * For copying and distribution information, please see the file
+ * <krb5/mit-copyright.h>.
+ *
+ * krb5_rd_req_simple()
+ */
+
+#if !defined(lint) && !defined(SABER)
+static char rd_req_sim_c[] =
+"$Id$";
+#endif /* !lint & !SABER */
+
+#include <krb5/copyright.h>
+#include <krb5/krb5.h>
+#include <krb5/krb5_err.h>
+#include <krb5/isode_err.h>
+#include <errno.h>
+
+#include <krb5/asn1.h>
+#include <krb5/ext-proto.h>
+
+/*
+ Parses a KRB_AP_REQ message, returning its contents.
+
+ server specifies the expected server's name for the ticket.
+
+ sender_addr specifies the address(es) expected to be present in the
+ ticket.
+
+ A replay cache name derived from the first component of the service name
+ is used.
+
+ The default key store is consulted to find the service key.
+
+ authdat->ticket and authdat->authenticator are set to allocated storage
+ structures; the caller should free them when finished.
+
+ returns system errors, encryption errors, replay errors
+ */
+
+krb5_error_code
+krb5_rd_req_simple(inbuf, server, sender_addr, authdat)
+const krb5_data *inbuf;
+const krb5_principal server;
+const krb5_address *sender_addr;
+krb5_tkt_authent *authdat;
+{
+    krb5_error_code retval;
+    krb5_ap_req *request;
+    krb5_rcache rcache;
+
+    if (!krb5_is_ap_req(inbuf))
+       return KRB5KRB_AP_ERR_MSG_TYPE;
+    if (retval = decode_krb5_ap_req(inbuf, &request)) {
+       switch (retval) {
+       case ISODE_50_LOCAL_ERR_BADMSGTYPE:
+           return KRB5KRB_AP_ERR_BADVERSION; /* XXX ? */
+       default:
+           return(retval);
+       }
+    }
+    if (rcache = (krb5_rcache) malloc(sizeof(*rcache))) {
+       if (!(retval = krb5_rc_resolve_type(&rcache, "dfl"))) {
+           char *cachename;
+           extern krb5_deltat krb5_clockskew;
+
+           if (cachename = malloc(server[1]->length+1+3)) {
+               strcpy(cachename, "rc_");
+               strncat(cachename, server[1]->data, server[1]->length);
+               cachename[server[1]->length+3] = '\0';
+
+               if (!(retval = krb5_rc_resolve(rcache, cachename))) {
+                   if (!((retval = krb5_rc_recover(rcache)) &&
+                         (retval = krb5_rc_initialize(rcache,
+                                                      krb5_clockskew)))) {
+                       retval = krb5_rd_req_decoded(request, server,
+                                                    sender_addr, 0,
+                                                    0, 0, rcache, authdat);
+                       krb5_rc_close(rcache);
+                   }
+               }
+               free(cachename);
+           } else
+               retval = ENOMEM;
+       }
+       xfree(rcache);
+    } else
+       retval = ENOMEM;
+    krb5_free_ap_req(request);
+
+    return retval;
+}
+