Annotation of 43BSDReno/kerberosIV/krb/add_ticket.c, revision 1.1

1.1     ! root        1: /*
        !             2:  * $Source: /usr/src/kerberosIV/krb/RCS/add_ticket.c,v $
        !             3:  * $Author: kfall $
        !             4:  *
        !             5:  * Copyright 1985, 1986, 1987, 1988 by the Massachusetts Institute
        !             6:  * of Technology.
        !             7:  *
        !             8:  * For copying and distribution information, please see the file
        !             9:  * <mit-copyright.h>.
        !            10:  */
        !            11: 
        !            12: #ifndef lint
        !            13: static char *rcsid_add_ticket_c =
        !            14: "$Header: /usr/src/kerberosIV/krb/RCS/add_ticket.c,v 1.1 90/06/25 20:54:59 kfall Exp $";
        !            15: #endif /* lint */
        !            16: 
        !            17: #include <mit-copyright.h>
        !            18: #include <krb.h>
        !            19: #include <prot.h>
        !            20: #include <strings.h>
        !            21: 
        !            22: /*
        !            23:  * This routine is now obsolete.  It used to be possible to request
        !            24:  * more than one ticket at a time from the authentication server, and
        !            25:  * it looks like this routine was used by the server to package the
        !            26:  * tickets to be returned to the client.
        !            27:  */
        !            28: 
        !            29: /*
        !            30:  * This routine adds a new ticket to the ciphertext to be returned to
        !            31:  * the client.  The routine takes the ciphertext (which doesn't get
        !            32:  * encrypted till later), the number of the ticket (i.e. 1st, 2nd,
        !            33:  * etc) the session key which goes in the ticket and is sent back to
        !            34:  * the user, the lifetime for the ticket, the service name, the
        !            35:  * instance, the realm, the key version number, and the ticket itself.
        !            36:  *
        !            37:  * This routine returns 0 (KSUCCESS) on success, and 1 (KFAILURE) on
        !            38:  * failure.  On failure, which occurs when there isn't enough room
        !            39:  * for the ticket, a 0 length ticket is added.
        !            40:  *
        !            41:  * Notes: This routine must be called with successive values of n.
        !            42:  * i.e. the ticket must be added in order.  The corresponding routine
        !            43:  * on the client side is extract ticket.
        !            44:  */
        !            45: 
        !            46: /* XXX they aren't all used; to avoid incompatible changes we will
        !            47:  * fool lint for the moment */
        !            48: /*ARGSUSED */
        !            49: add_ticket(cipher,n,session,lifetime,sname,instance,realm,kvno,ticket)
        !            50:     KTEXT cipher;              /* Ciphertext info for ticket */
        !            51:     char *sname;               /* Service name */
        !            52:     char *instance;            /* Instance */
        !            53:     int n;                     /* Relative position of this ticket */
        !            54:     char *session;             /* Session key for this tkt */
        !            55:     int lifetime;              /* Lifetime of this ticket */
        !            56:     char *realm;               /* Realm in which ticket is valid */
        !            57:     int kvno;                  /* Key version number of service key */
        !            58:     KTEXT ticket;              /* The ticket itself */
        !            59: {
        !            60: 
        !            61:     /* Note, the 42 is a temporary hack; it will have to be changed. */
        !            62: 
        !            63:     /* Begin check of ticket length */
        !            64:     if ((cipher->length + ticket->length + 4 + 42 +
        !            65:        (*(cipher->dat)+1-n)*(11+strlen(realm))) >
        !            66:        MAX_KTXT_LEN) {
        !            67:        bcopy(session,(char *)(cipher->dat+cipher->length),8);
        !            68:        *(cipher->dat+cipher->length+8) = (char) lifetime;
        !            69:        *(cipher->dat+cipher->length+9) = (char) kvno;
        !            70:        (void) strcpy((char *)(cipher->dat+cipher->length+10),realm);
        !            71:        cipher->length += 11 + strlen(realm);
        !            72:        *(cipher->dat+n) = 0;
        !            73:        return(KFAILURE);
        !            74:     }
        !            75:     /* End check of ticket length */
        !            76: 
        !            77:     /* Add the session key, lifetime, kvno, ticket to the ciphertext */
        !            78:     bcopy(session,(char *)(cipher->dat+cipher->length),8);
        !            79:     *(cipher->dat+cipher->length+8) = (char) lifetime;
        !            80:     *(cipher->dat+cipher->length+9) = (char) kvno;
        !            81:     (void) strcpy((char *)(cipher->dat+cipher->length+10),realm);
        !            82:     cipher->length += 11 + strlen(realm);
        !            83:     bcopy((char *)(ticket->dat),(char *)(cipher->dat+cipher->length),
        !            84:          ticket->length);
        !            85:     cipher->length += ticket->length;
        !            86: 
        !            87:     /* Set the ticket length at beginning of ciphertext */
        !            88:     *(cipher->dat+n) = ticket->length;
        !            89:     return(KSUCCESS);
        !            90: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.