*** empty log message ***
authorTheodore Tso <tytso@mit.edu>
Fri, 21 Aug 1992 17:04:14 +0000 (17:04 +0000)
committerTheodore Tso <tytso@mit.edu>
Fri, 21 Aug 1992 17:04:14 +0000 (17:04 +0000)
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@2368 dc483132-0cff-0310-8789-dd5450dbe970

src/lib/krb5/asn.1/kpwd2pwd.c [new file with mode: 0644]
src/lib/krb5/asn.1/kpwds2pwds.c [new file with mode: 0644]
src/lib/krb5/asn.1/pwd2kpwd.c [new file with mode: 0644]
src/lib/krb5/asn.1/pwds2kpwds.c [new file with mode: 0644]

diff --git a/src/lib/krb5/asn.1/kpwd2pwd.c b/src/lib/krb5/asn.1/kpwd2pwd.c
new file mode 100644 (file)
index 0000000..96e89d8
--- /dev/null
@@ -0,0 +1,94 @@
+/*
+ * $Source$
+ * $Author$
+ *
+ * Copyright 1989,1990 by the Massachusetts Institute of Technology.
+ * All Rights Reserved.
+ *
+ * Export of this software from the United States of America is assumed
+ *   to require a specific license from the United States Government.
+ *   It is the responsibility of any person or organization contemplating
+ *   export to obtain such a license before exporting.
+ * 
+ * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
+ * distribute this software and its documentation for any purpose and
+ * without fee is hereby granted, provided that the above copyright
+ * notice appear in all copies and that both that copyright notice and
+ * this permission notice appear in supporting documentation, and that
+ * the name of M.I.T. not be used in advertising or publicity pertaining
+ * to distribution of the software without specific, written prior
+ * permission.  M.I.T. makes no representations about the suitability of
+ * this software for any purpose.  It is provided "as is" without express
+ * or implied warranty.
+ * 
+ *
+ * Glue between Kerberos version and ISODE 6.0 version of structures.
+ */
+
+#if !defined(lint) && !defined(SABER)
+static char rcsid_kpwd2pwd[] =
+"$Id$";
+#endif /* lint || saber */
+
+#include <stdio.h>
+#include <krb5/krb5.h>
+
+#include <isode/psap.h>
+#include <krb5/asn1.h>
+#include "asn1glue.h"
+
+#include <krb5/ext-proto.h>
+
+#ifdef NEVERDEFINE
+/*
+ *     typedef struct _passwd_phrase_element {
+ *        krb5_data *passwd;
+ *        krb5_data *phrase;
+ *     } passwd_phrase_element;
+ *
+ *     struct type_KRB5_PasswdSequence {
+ *        struct qbuf *passwd;
+ *        struct qbuf *phrase;
+ *     };
+ *
+ *     struct qbuf {
+ *        struct qbuf *qb_forw;        /* doubly-linked list */
+ *        struct qbuf *qb_back;        /*   .. */
+ *
+ *        int      qb_len;             /* length of data */
+ *        char   *qb_data;             /* current pointer into data */
+ *        char    qb_base[1];          /* extensible... */
+ *     };
+ *
+ */
+#endif /* NEVERDEFINE */
+
+struct type_KRB5_PasswdSequence *
+krb5_pwd_seq2KRB5_PWD__SEQ(val, error)
+const register passwd_phrase_element *val;
+register int *error;
+{
+    register struct type_KRB5_PasswdSequence *retval;
+
+    if ((retval = (struct type_KRB5_PasswdSequence *) calloc(1,
+               sizeof(struct type_KRB5_PasswdSequence))) == NULL) {
+       com_err("kpwd2pwd", 0, "Unable to Allocate PasswdSequence");
+       *error = ENOMEM;
+       return(0);
+    }
+
+    retval->passwd = krb5_data2qbuf(val->passwd);
+    if (!retval->passwd) {
+       *error = ENOMEM;
+       errout:
+          free_KRB5_PasswdSequence(retval);
+          return(0);
+    }
+
+    retval->phrase = krb5_data2qbuf(val->phrase);
+    if (!retval->phrase) {
+       goto errout;
+    }
+
+    return(retval);
+}
diff --git a/src/lib/krb5/asn.1/kpwds2pwds.c b/src/lib/krb5/asn.1/kpwds2pwds.c
new file mode 100644 (file)
index 0000000..9bc17e5
--- /dev/null
@@ -0,0 +1,131 @@
+/*
+ * $Source$
+ * $Author$
+ *
+ * Copyright 1989,1990 by the Massachusetts Institute of Technology.
+ * All Rights Reserved.
+ *
+ * Export of this software from the United States of America is assumed
+ *   to require a specific license from the United States Government.
+ *   It is the responsibility of any person or organization contemplating
+ *   export to obtain such a license before exporting.
+ * 
+ * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
+ * distribute this software and its documentation for any purpose and
+ * without fee is hereby granted, provided that the above copyright
+ * notice appear in all copies and that both that copyright notice and
+ * this permission notice appear in supporting documentation, and that
+ * the name of M.I.T. not be used in advertising or publicity pertaining
+ * to distribution of the software without specific, written prior
+ * permission.  M.I.T. makes no representations about the suitability of
+ * this software for any purpose.  It is provided "as is" without express
+ * or implied warranty.
+ * 
+ *
+ * Glue between Kerberos version and ISODE 6.0 version of structures.
+ */
+
+#ifdef NEVERDEFINE
+/*
+ *     encode_generic will return krb_data in the form:
+ *             1 Byte (Integer) ==> Password Sequence Count (25)
+ *             5 * ADM_MAX_PW_ITERATIONS Sets:
+ *                     1 Byte (Integer) ==> Length of Passwd (8 - 255)
+ *                     8 - 255 Bytes (Character) ==> "Password"
+ *                     1 Byte (Integer) ==> Length of Phrase (8 - 255)
+ *                     8 - 255 Bytes (Character) ==> "Phrase"
+ *
+ *     typedef struct _passwd_phrase_element {
+ *        krb5_data passwd;
+ *        krb5_data phrase;
+ *     } passwd_phrase_element;
+ *
+ *     struct type_KRB5_PasswdData {
+ *        integer     passwd__sequence__count;
+ *                     /* SEQUENCE OF */
+ *        struct element_KRB5_12 {
+ *            struct type_KRB5_PasswdSequence *PasswdSequence;
+ *            struct element_KRB5_12 *next;
+ *        } *passwd__sequence;
+ *     };
+ *
+ *     struct type_KRB5_PasswdSequence {
+ *        struct qbuf *passwd;
+ *        struct qbuf *phrase;
+ *     };
+ */
+#endif /* NEVERDEFINE */
+
+#if !defined(lint) && !defined(SABER)
+static char rcsid_kpwds2pwds[] =
+"$Id$";
+#endif /* lint || saber */
+
+#include <stdio.h>
+#include <krb5/krb5.h>
+
+#include <isode/psap.h>
+#include <krb5/asn1.h>
+#include "asn1glue.h"
+
+#include <krb5/ext-proto.h>
+
+struct type_KRB5_PasswdData *
+krb5_pwd_data2KRB5_PWD__DATA(val, error)
+register krb5_pwd_data *val;
+register int *error;
+{
+    register struct type_KRB5_PasswdData *retval = 0;
+    register struct element_KRB5_12 *passwdseq = 0, *rv1 = 0, *rv2;
+    passwd_phrase_element **temp;
+    register int i;
+
+               /* Allocate PasswdData Structure */
+    if ((retval = (struct type_KRB5_PasswdData *) xcalloc(1, 
+               sizeof(*retval))) == NULL) {
+       *error = ENOMEM;
+       return(0);
+    }
+
+    retval->passwd__sequence__count = val->sequence_count;
+    
+    if (val->element) {
+       for ( i = 0, temp = (passwd_phrase_element **) val->element; 
+               *temp; 
+               temp++, i++, rv1 = rv2){
+           if ((rv2 = (struct element_KRB5_12 *) xcalloc(1, 
+                       sizeof(*rv2))) == NULL) {;
+               *error = ENOMEM;
+               errout:
+               free_KRB5_PasswdData(retval);
+               return(0);
+           }
+
+           if (rv1) rv1->next = rv2;
+
+           if (!passwdseq) {
+               passwdseq = rv2;
+           }
+
+           rv2->PasswdSequence = 
+               krb5_pwd_seq2KRB5_PWD__SEQ(val->element[i],
+               error);
+
+           if (!rv2->PasswdSequence) {
+               for (rv1 = passwdseq; rv1; rv1 = rv2) {
+                   if (rv1->PasswdSequence) 
+                       free_KRB5_PasswdSequence(rv1->PasswdSequence);
+
+                   rv2 = rv1->next;
+                   xfree(rv1);
+               }
+           goto errout;
+           }
+       }
+
+        retval->passwd__sequence = passwdseq;
+    } else 
+       retval->passwd__sequence = 0;
+
+    return(retval);
+}
diff --git a/src/lib/krb5/asn.1/pwd2kpwd.c b/src/lib/krb5/asn.1/pwd2kpwd.c
new file mode 100644 (file)
index 0000000..eb5bf39
--- /dev/null
@@ -0,0 +1,70 @@
+/*
+ * $Source$
+ * $Author$
+ *
+ * Copyright 1989,1990 by the Massachusetts Institute of Technology.
+ * All Rights Reserved.
+ *
+ * Export of this software from the United States of America is assumed
+ *   to require a specific license from the United States Government.
+ *   It is the responsibility of any person or organization contemplating
+ *   export to obtain such a license before exporting.
+ * 
+ * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
+ * distribute this software and its documentation for any purpose and
+ * without fee is hereby granted, provided that the above copyright
+ * notice appear in all copies and that both that copyright notice and
+ * this permission notice appear in supporting documentation, and that
+ * the name of M.I.T. not be used in advertising or publicity pertaining
+ * to distribution of the software without specific, written prior
+ * permission.  M.I.T. makes no representations about the suitability of
+ * this software for any purpose.  It is provided "as is" without express
+ * or implied warranty.
+ * 
+ *
+ * Glue between Kerberos version and ISODE 6.0 version of structures.
+ */
+
+#if !defined(lint) && !defined(SABER)
+static char rcsid_pwd2kpwd[] =
+"$Id$";
+#endif /* lint || saber */
+
+#include <krb5/krb5.h>
+
+/*#include <time.h> */
+#include <isode/psap.h>
+#include <krb5/asn1.h>
+#include "asn1glue.h"
+
+#include <krb5/ext-proto.h>
+
+/* ISODE defines max(a,b) */
+
+passwd_phrase_element *
+KRB5_PWD__SEQ2krb5_pwd_seq(val, error)
+const register struct type_KRB5_PasswdSequence *val;
+register int *error;
+{
+    register passwd_phrase_element *retval;
+
+    if ((retval = (passwd_phrase_element *) calloc(1, 
+               sizeof(*retval))) == (passwd_phrase_element *) 0) {
+       *error = ENOMEM;
+       return(0);
+    }
+
+    retval->passwd = qbuf2krb5_data(val->passwd, error);
+    if (!retval->passwd) {
+       xfree(retval);
+       return(0);
+    }
+
+    retval->phrase = qbuf2krb5_data(val->phrase, error);
+    if (!retval->phrase) {
+       xfree(retval);
+       return(0);
+    }
+
+    return(retval);
+}
diff --git a/src/lib/krb5/asn.1/pwds2kpwds.c b/src/lib/krb5/asn.1/pwds2kpwds.c
new file mode 100644 (file)
index 0000000..0a1b4bf
--- /dev/null
@@ -0,0 +1,94 @@
+/*
+ * $Source$
+ * $Author$
+ *
+ * Copyright 1989,1990 by the Massachusetts Institute of Technology.
+ * All Rights Reserved.
+ *
+ * Export of this software from the United States of America is assumed
+ *   to require a specific license from the United States Government.
+ *   It is the responsibility of any person or organization contemplating
+ *   export to obtain such a license before exporting.
+ * 
+ * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
+ * distribute this software and its documentation for any purpose and
+ * without fee is hereby granted, provided that the above copyright
+ * notice appear in all copies and that both that copyright notice and
+ * this permission notice appear in supporting documentation, and that
+ * the name of M.I.T. not be used in advertising or publicity pertaining
+ * to distribution of the software without specific, written prior
+ * permission.  M.I.T. makes no representations about the suitability of
+ * this software for any purpose.  It is provided "as is" without express
+ * or implied warranty.
+ * 
+ *
+ * Glue between Kerberos version and ISODE 6.0 version of structures.
+ */
+
+#if !defined(lint) && !defined(SABER)
+static char rcsid_pwds2kpwds[] =
+"$Id$";
+#endif /* lint || saber */
+
+#include <stdio.h>
+#include <krb5/krb5.h>
+
+#include <isode/psap.h>
+#include <krb5/asn1.h>
+#include "asn1glue.h"
+
+#include <krb5/ext-proto.h>
+
+krb5_pwd_data *
+KRB5_PWD__DATA2krb5_pwd_data(val, error)
+const register struct type_KRB5_PasswdData *val;
+register int *error;
+{
+    register krb5_pwd_data *retval;
+    register passwd_phrase_element **element;
+    register struct element_KRB5_12 *seq_ptr, *rv;
+    register int i;
+
+
+    if ((retval = (krb5_pwd_data *) calloc (1, sizeof(*retval))) == NULL) {
+       fprintf(stderr, "pwds2kpwds: Unable to allocate retval space\n");
+       *error = ENOMEM;
+       return(0);
+    }
+
+    retval->sequence_count = val->passwd__sequence__count;
+
+    seq_ptr = val->passwd__sequence;
+
+    for (i = 0, rv = seq_ptr; rv; i++, rv = rv->next);
+
+    /* Plus One for NULL Terminator */
+    if ((element = (passwd_phrase_element **) xcalloc(i + 1, 
+               sizeof(*element))) == NULL) {
+       fprintf(stderr, 
+               "pwds2kpwds: Unable to allocate passwd_phrase_element list\n");
+       *error = ENOMEM;
+       errout:
+           fprintf(stderr, "pwds2kpwds: Decode Failure\n");
+           krb5_free_pwd_data(retval);
+           return(0);
+    }
+
+    retval->element = element;
+
+    for (i = 0, rv = seq_ptr; rv; rv = rv->next, i++) {
+       element[i] = KRB5_PWD__SEQ2krb5_pwd_seq(rv->PasswdSequence,
+                       error);
+       if(!element[i]) {
+           while(i >= 0) {
+               krb5_free_pwd_sequences(element[i]);
+               i--;
+           }
+           xfree(element);
+           goto errout;
+       }
+    }
+
+
+    return(retval);
+}