fixups for body encoding/decoding
authorJohn Kohl <jtkohl@mit.edu>
Wed, 10 Oct 1990 16:43:45 +0000 (16:43 +0000)
committerJohn Kohl <jtkohl@mit.edu>
Wed, 10 Oct 1990 16:43:45 +0000 (16:43 +0000)
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@1220 dc483132-0cff-0310-8789-dd5450dbe970

src/lib/krb5/asn.1/ktgrq2tgrq.c
src/lib/krb5/asn.1/tgrq2ktgrq.c

index 0bd1ffc64a73937896040728ce9f2cd44072bdfe..0fad014ff4bd9d4c9070457e18333a6d7a954d8a 100644 (file)
@@ -28,98 +28,87 @@ static char rcsid_ktgrq2tgrq_c[] =
 
 /* ISODE defines max(a,b) */
 
-struct type_KRB5_TGS__REQ *
-krb5_kdc_req2KRB5_TGS__REQ(val, error)
+struct type_KRB5_KDC__REQ__BODY *
+krb5_kdc_req2KRB5_KDC__REQ__BODY(val, error)
 const register krb5_kdc_req *val;
 register int *error;
 {
-    register struct type_KRB5_TGS__REQ *retval;
-    retval = (struct type_KRB5_TGS__REQ *)xmalloc(sizeof(*retval));
+    register struct type_KRB5_KDC__REQ__BODY *retval;
+    
+    retval = krb5_kdc_req2KRB5_KDC__REQ__BODY(val, error);
     if (!retval) {
        *error = ENOMEM;
        return(0);
     }
-    xbzero(retval, sizeof(*retval));
 
-    retval->pvno = KRB5_PVNO;
-    retval->msg__type = val->msg_type;
-    retval->padata__type = val->padata_type;
-    retval->padata = krb5_data2qbuf(&(val->padata));
-    if (!retval->padata) {
-       xfree(retval);
-       *error = ENOMEM;
-       return(0);
-    }
-    retval->req__body->kdc__options =
+    retval->kdc__options =
        krb5_kdcoptions2KRB5_KDCOptions(val->kdc_options,
                                        error);
-    if (!retval->req__body->kdc__options) {
+    if (!retval->kdc__options) {
     errout:
-       free_KRB5_TGS__REQ(retval);
+       free_KRB5_KDC__REQ__BODY(retval);
        return(0);
     }
     if (val->client) {
-       retval->req__body->cname =
+       retval->cname =
            krb5_principal2KRB5_PrincipalName(val->client, error);
-       if (!retval->req__body->cname) {
+       if (!retval->cname) {
            goto errout;
        }
     }    
-    retval->req__body->realm = krb5_data2qbuf(val->server[0]);
-    if (!retval->req__body->realm) {
+    retval->realm = krb5_data2qbuf(val->server[0]);
+    if (!retval->realm) {
        *error = ENOMEM;
        goto errout;
     }
-    retval->req__body->sname = krb5_principal2KRB5_PrincipalName(val->server,
-                                                                error);
-    if (!retval->req__body->sname) {
+    retval->sname = krb5_principal2KRB5_PrincipalName(val->server, error);
+    if (!retval->sname) {
        goto errout;
     }
-    retval->req__body->from = unix2gentime(val->from, error);
-    if (!retval->req__body->from) {
+    retval->from = unix2gentime(val->from, error);
+    if (!retval->from) {
        goto errout;
     }
-    retval->req__body->till = unix2gentime(val->till, error);
-    if (!retval->req__body->till) {
+    retval->till = unix2gentime(val->till, error);
+    if (!retval->till) {
        goto errout;
     }
     if (val->kdc_options & KDC_OPT_RENEWABLE) {
-       retval->req__body->rtime = unix2gentime(val->rtime, error);
-       if (!retval->req__body->rtime) {
+       retval->rtime = unix2gentime(val->rtime, error);
+       if (!retval->rtime) {
            goto errout;
        }
     }
-    retval->req__body->ctime = unix2gentime(val->ctime, error);
-    if (!retval->req__body->ctime) {
+    retval->ctime = unix2gentime(val->ctime, error);
+    if (!retval->ctime) {
        goto errout;
     }
-    retval->req__body->nonce = val->nonce;
-    retval->req__body->etype = val->etype;
+    retval->nonce = val->nonce;
+    retval->etype = val->etype;
  
     if (val->addresses) {
-       retval->req__body->addresses =
+       retval->addresses =
            krb5_address2KRB5_HostAddresses(val->addresses, error);
-       if (!retval->req__body->addresses) {
+       if (!retval->addresses) {
            goto errout;
        }
     }
     if (val->authorization_data) {
-       retval->req__body->authorization__data =
+       retval->authorization__data =
            krb5_authdata2KRB5_AuthorizationData(val->authorization_data,
                                                 error);
-       if (!retval->req__body->authorization__data)
+       if (!retval->authorization__data)
            goto errout;
     }
     if (val->second_ticket) {
-       struct element_KRB5_9 *adtk;
+       struct element_KRB5_6 *adtk;
        krb5_ticket * const *temp;
        register int i;
 
        /* count elements */
        for (i = 0, temp = val->second_ticket; *temp; temp++,i++);
 
-       adtk = (struct element_KRB5_9 *)xmalloc(sizeof(*retval) +
+       adtk = (struct element_KRB5_6 *)xmalloc(sizeof(*retval) +
                                                max(0,i-1)*sizeof(adtk->Ticket));
        if (!adtk) {
            *error = ENOMEM;
@@ -139,7 +128,37 @@ register int *error;
                goto errout;
            }
        }
-       retval->req__body->additional__tickets = adtk;
+       retval->additional__tickets = adtk;
+    }
+    return retval;
+}
+
+struct type_KRB5_TGS__REQ *
+krb5_kdc_req2KRB5_TGS__REQ(val, error)
+const register krb5_kdc_req *val;
+register int *error;
+{
+    register struct type_KRB5_TGS__REQ *retval;
+    retval = (struct type_KRB5_TGS__REQ *)xmalloc(sizeof(*retval));
+    if (!retval) {
+       *error = ENOMEM;
+       return(0);
+    }
+    xbzero(retval, sizeof(*retval));
+    retval->pvno = KRB5_PVNO;
+    retval->msg__type = val->msg_type;
+    retval->padata__type = val->padata_type;
+    retval->padata = krb5_data2qbuf(&(val->padata));
+    if (!retval->padata) {
+       xfree(retval);
+       *error = ENOMEM;
+       return(0);
+    }
+    retval->req__body = krb5_kdc_req2KRB5_KDC__REQ__BODY(val, error);
+    if (!retval->req__body) {
+       xfree(retval);
+       return(0);
     }
     return(retval);
 }
index e9f464196484738d695717ec0a3afd07af268cbe..d8433beeea16c2855bc75f463343f79a8e79549d 100644 (file)
@@ -29,12 +29,11 @@ static char rcsid_tgrq2ktgrq_c[] =
 /* ISODE defines max(a,b) */
 
 krb5_kdc_req *
-KRB5_TGS__REQ2krb5_kdc_req(val, error)
-const register struct type_KRB5_TGS__REQ *val;
+KRB5_KDC__REQ__BODY2krb5_kdc_req(val, error)
+const register struct type_KRB5_KDC__REQ__BODY *val;
 register int *error;
 {
     register krb5_kdc_req *retval;
-    krb5_data *temp;
 
     retval = (krb5_kdc_req *)xmalloc(sizeof(*retval));
     if (!retval) {
@@ -43,81 +42,69 @@ register int *error;
     }
     xbzero(retval, sizeof(*retval));
 
-    retval->msg_type = val->msg__type;
-    retval->padata_type = val->padata__type;
-    if (val->padata) {
-       temp = qbuf2krb5_data(val->padata, error);
-       if (temp) {
-           retval->padata = *temp;
-           xfree(temp);
-       } else {
-           goto errout;
-       }
-    }  
-
     retval->kdc_options =
-       KRB5_KDCOptions2krb5_kdcoptions(val->req__body->kdc__options,
+       KRB5_KDCOptions2krb5_kdcoptions(val->kdc__options,
                                        error);
     if (*error) {
     errout:
        krb5_free_kdc_req(retval);
        return(0);
     }
-    if (val->req__body->cname)
+    if (val->cname)
        retval->client =
-           KRB5_PrincipalName2krb5_principal(val->req__body->cname,
-                                             val->req__body->realm,
+           KRB5_PrincipalName2krb5_principal(val->cname,
+                                             val->realm,
                                              error);
-    retval->server = KRB5_PrincipalName2krb5_principal(val->req__body->sname,
-                                                      val->req__body->realm,
+    retval->server = KRB5_PrincipalName2krb5_principal(val->sname,
+                                                      val->realm,
                                                       error);
     if (!retval->server) {
        goto errout;
     }
-    retval->from = gentime2unix(val->req__body->from, error);
+    retval->from = gentime2unix(val->from, error);
     if (*error) {
        goto errout;
     }
-    retval->till = gentime2unix(val->req__body->till, error);
+    retval->till = gentime2unix(val->till, error);
     if (*error) {
        goto errout;
     }
     if (retval->kdc_options & KDC_OPT_RENEWABLE) {
-       retval->rtime = gentime2unix(val->req__body->rtime, error);
+       retval->rtime = gentime2unix(val->rtime, error);
        if (*error) {
            goto errout;
        }
     }
-    retval->ctime = gentime2unix(val->req__body->ctime, error);
+    retval->ctime = gentime2unix(val->ctime, error);
     if (*error) {
        goto errout;
     }
-    retval->nonce = val->req__body->nonce;
+    retval->nonce = val->nonce;
 
-    retval->etype = val->req__body->etype;
+    retval->etype = val->etype;
 
 
-    if (val->req__body->addresses) {
+    if (val->addresses) {
        retval->addresses =
-           KRB5_HostAddresses2krb5_address(val->req__body->addresses, error);
+           KRB5_HostAddresses2krb5_address(val->addresses, error);
        if (!retval->addresses) {
            goto errout;
        }
     }
-    if (val->req__body->authorization__data) {
+    if (val->authorization__data) {
        retval->authorization_data =
-           KRB5_AuthorizationData2krb5_authdata(val->req__body->
+           KRB5_AuthorizationData2krb5_authdata(val->
                                                 authorization__data,
                                                 error);
        if (*error)
            goto errout;
     }
-    if (val->req__body->additional__tickets) {
+    if (val->additional__tickets) {
        register krb5_ticket **aticks;
-        register struct element_KRB5_9 *tptr;
+        register struct element_KRB5_6 *tptr;
        register int i;
 
-       tptr = val->req__body->additional__tickets;
+       tptr = val->additional__tickets;
        /* plus one for null terminator */
        aticks = (krb5_ticket **) xcalloc(tptr->nelem + 1,
                                          sizeof(*aticks));
@@ -133,5 +120,31 @@ register int *error;
        }
        retval->second_ticket = aticks;
     }
+    return retval;
+}
+
+krb5_kdc_req *
+KRB5_TGS__REQ2krb5_kdc_req(val, error)
+const register struct type_KRB5_TGS__REQ *val;
+register int *error;
+{
+    register krb5_kdc_req *retval;
+    krb5_data *temp;
+
+    if (!(retval = KRB5_KDC__REQ__BODY2krb5_kdc_req(val->req__body, error)))
+       return retval;
+
+    retval->msg_type = val->msg__type;
+    retval->padata_type = val->padata__type;
+    if (val->padata) {
+       temp = qbuf2krb5_data(val->padata, error);
+       if (temp) {
+           retval->padata = *temp;
+           xfree(temp);
+       } else {
+           krb5_free_kdc_req(retval);
+           return(0);
+       }
+    }  
     return(retval);
 }