|
|
1.1 ! root 1: /* ! 2: * $Source: /usr/src/kerberosIV/krb/RCS/create_auth_reply.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_create_auth_reply_c = ! 14: "$Header: /usr/src/kerberosIV/krb/RCS/create_auth_reply.c,v 4.11 90/06/25 20:55:20 kfall Exp $"; ! 15: #endif /* lint */ ! 16: ! 17: #include <mit-copyright.h> ! 18: #include <des.h> ! 19: #include <krb.h> ! 20: #include <prot.h> ! 21: #include <strings.h> ! 22: ! 23: /* ! 24: * This routine is called by the Kerberos authentication server ! 25: * to create a reply to an authentication request. The routine ! 26: * takes the user's name, instance, and realm, the client's ! 27: * timestamp, the number of tickets, the user's key version ! 28: * number and the ciphertext containing the tickets themselves. ! 29: * It constructs a packet and returns a pointer to it. ! 30: * ! 31: * Notes: The packet returned by this routine is static. Thus, if you ! 32: * intend to keep the result beyond the next call to this routine, you ! 33: * must copy it elsewhere. ! 34: * ! 35: * The packet is built in the following format: ! 36: * ! 37: * variable ! 38: * type or constant data ! 39: * ---- ----------- ---- ! 40: * ! 41: * unsigned char KRB_PROT_VERSION protocol version number ! 42: * ! 43: * unsigned char AUTH_MSG_KDC_REPLY protocol message type ! 44: * ! 45: * [least significant HOST_BYTE_ORDER sender's (server's) byte ! 46: * bit of above field] order ! 47: * ! 48: * string pname principal's name ! 49: * ! 50: * string pinst principal's instance ! 51: * ! 52: * string prealm principal's realm ! 53: * ! 54: * unsigned long time_ws client's timestamp ! 55: * ! 56: * unsigned char n number of tickets ! 57: * ! 58: * unsigned long x_date expiration date ! 59: * ! 60: * unsigned char kvno master key version ! 61: * ! 62: * short w_1 cipher length ! 63: * ! 64: * --- cipher->dat cipher data ! 65: */ ! 66: ! 67: KTEXT ! 68: create_auth_reply(pname,pinst,prealm,time_ws,n,x_date,kvno,cipher) ! 69: char *pname; /* Principal's name */ ! 70: char *pinst; /* Principal's instance */ ! 71: char *prealm; /* Principal's authentication domain */ ! 72: long time_ws; /* Workstation time */ ! 73: int n; /* Number of tickets */ ! 74: unsigned long x_date; /* Principal's expiration date */ ! 75: int kvno; /* Principal's key version number */ ! 76: KTEXT cipher; /* Cipher text with tickets and ! 77: * session keys */ ! 78: { ! 79: static KTEXT_ST pkt_st; ! 80: KTEXT pkt = &pkt_st; ! 81: unsigned char *v = pkt->dat; /* Prot vers number */ ! 82: unsigned char *t = (pkt->dat+1); /* Prot message type */ ! 83: short w_l; /* Cipher length */ ! 84: ! 85: /* Create fixed part of packet */ ! 86: *v = (unsigned char) KRB_PROT_VERSION; ! 87: *t = (unsigned char) AUTH_MSG_KDC_REPLY; ! 88: *t |= HOST_BYTE_ORDER; ! 89: ! 90: if (n != 0) ! 91: *v = 3; ! 92: ! 93: /* Add the basic info */ ! 94: (void) strcpy((char *) (pkt->dat+2), pname); ! 95: pkt->length = 3 + strlen(pname); ! 96: (void) strcpy((char *) (pkt->dat+pkt->length),pinst); ! 97: pkt->length += 1 + strlen(pinst); ! 98: (void) strcpy((char *) (pkt->dat+pkt->length),prealm); ! 99: pkt->length += 1 + strlen(prealm); ! 100: /* Workstation timestamp */ ! 101: bcopy((char *) &time_ws, (char *) (pkt->dat+pkt->length), 4); ! 102: pkt->length += 4; ! 103: *(pkt->dat+(pkt->length)++) = (unsigned char) n; ! 104: /* Expiration date */ ! 105: bcopy((char *) &x_date, (char *) (pkt->dat+pkt->length),4); ! 106: pkt->length += 4; ! 107: ! 108: /* Now send the ciphertext and info to help decode it */ ! 109: *(pkt->dat+(pkt->length)++) = (unsigned char) kvno; ! 110: w_l = (short) cipher->length; ! 111: bcopy((char *) &w_l,(char *) (pkt->dat+pkt->length),2); ! 112: pkt->length += 2; ! 113: bcopy((char *) (cipher->dat), (char *) (pkt->dat+pkt->length), ! 114: cipher->length); ! 115: pkt->length += cipher->length; ! 116: ! 117: /* And return the packet */ ! 118: return pkt; ! 119: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.