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

1.1     ! root        1: /*
        !             2:  * $Source: /usr/src/kerberosIV/krb/RCS/create_ciph.c,v $
        !             3:  * $Author: kfall $
        !             4:  *
        !             5:  * Copyright 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_create_ciph_c =
        !            14: "$Header: /usr/src/kerberosIV/krb/RCS/create_ciph.c,v 4.9 90/06/25 20:55:25 kfall Exp $";
        !            15: #endif /* lint */
        !            16: 
        !            17: #include <mit-copyright.h>
        !            18: #include <des.h>
        !            19: #include <krb.h>
        !            20: #include <strings.h>
        !            21: 
        !            22: /*
        !            23:  * This routine is used by the authentication server to create
        !            24:  * a packet for its client, containing a ticket for the requested
        !            25:  * service (given in "tkt"), and some information about the ticket,
        !            26: #ifndef NOENCRYPTION
        !            27:  * all encrypted in the given key ("key").
        !            28: #endif
        !            29:  *
        !            30:  * Returns KSUCCESS no matter what.
        !            31:  *
        !            32:  * The length of the cipher is stored in c->length; the format of
        !            33:  * c->dat is as follows:
        !            34:  *
        !            35:  *                     variable
        !            36:  * type                        or constant        data
        !            37:  * ----                        -----------        ----
        !            38:  * 
        !            39:  * 
        !            40:  * 8 bytes             session         session key for client, service
        !            41:  * 
        !            42:  * string              service         service name
        !            43:  * 
        !            44:  * string              instance        service instance
        !            45:  * 
        !            46:  * string              realm           KDC realm
        !            47:  * 
        !            48:  * unsigned char       life            ticket lifetime
        !            49:  * 
        !            50:  * unsigned char       kvno            service key version number
        !            51:  * 
        !            52:  * unsigned char       tkt->length     length of following ticket
        !            53:  * 
        !            54:  * data                        tkt->dat        ticket for service
        !            55:  * 
        !            56:  * 4 bytes             kdc_time        KDC's timestamp
        !            57:  *
        !            58:  * <=7 bytes           null               null pad to 8 byte multiple
        !            59:  *
        !            60:  */
        !            61: 
        !            62: create_ciph(c, session, service, instance, realm, life, kvno, tkt,
        !            63:            kdc_time, key)
        !            64:     KTEXT           c;         /* Text block to hold ciphertext */
        !            65:     C_Block         session;   /* Session key to send to user */
        !            66:     char            *service;  /* Service name on ticket */
        !            67:     char            *instance; /* Instance name on ticket */
        !            68:     char            *realm;    /* Realm of this KDC */
        !            69:     unsigned long   life;      /* Lifetime of the ticket */
        !            70:     int             kvno;      /* Key version number for service */
        !            71:     KTEXT           tkt;       /* The ticket for the service */
        !            72:     unsigned long   kdc_time;  /* KDC time */
        !            73:     C_Block         key;       /* Key to encrypt ciphertext with */
        !            74: {
        !            75:     char            *ptr;
        !            76:     Key_schedule    key_s;
        !            77: 
        !            78:     ptr = (char *) c->dat;
        !            79: 
        !            80:     bcopy((char *) session, ptr, 8);
        !            81:     ptr += 8;
        !            82: 
        !            83:     (void) strcpy(ptr,service);
        !            84:     ptr += strlen(service) + 1;
        !            85: 
        !            86:     (void) strcpy(ptr,instance);
        !            87:     ptr += strlen(instance) + 1;
        !            88: 
        !            89:     (void) strcpy(ptr,realm);
        !            90:     ptr += strlen(realm) + 1;
        !            91: 
        !            92:     *(ptr++) = (unsigned char) life;
        !            93:     *(ptr++) = (unsigned char) kvno;
        !            94:     *(ptr++) = (unsigned char) tkt->length;
        !            95: 
        !            96:     bcopy((char *)(tkt->dat),ptr,tkt->length);
        !            97:     ptr += tkt->length;
        !            98: 
        !            99:     bcopy((char *) &kdc_time,ptr,4);
        !           100:     ptr += 4;
        !           101: 
        !           102:     /* guarantee null padded encrypted data to multiple of 8 bytes */
        !           103:     bzero(ptr, 7);
        !           104: 
        !           105:     c->length = (((ptr - (char *) c->dat) + 7) / 8) * 8;
        !           106: 
        !           107: #ifndef NOENCRYPTION
        !           108:     key_sched(key,key_s);
        !           109:     pcbc_encrypt((C_Block *)c->dat,(C_Block *)c->dat,
        !           110:                 (long) c->length,key_s,key,ENCRYPT);
        !           111: #endif /* NOENCRYPTION */
        !           112: 
        !           113:     return(KSUCCESS);
        !           114: }

unix.superglobalmegacorp.com

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