]> asedeno.scripts.mit.edu Git - 1ts-debian.git/blob - zephyr/lib/ZFmtAuth.c
Initial revision
[1ts-debian.git] / zephyr / lib / ZFmtAuth.c
1 /* This file is part of the Project Athena Zephyr Notification System.
2  * It contains source for the ZFormatAuthenticNotice function.
3  *
4  *      Created by:     Robert French
5  *
6  *      $Id: ZFmtAuth.c,v 1.20 1999/01/22 23:19:06 ghudson Exp $
7  *
8  *      Copyright (c) 1987,1988 by the Massachusetts Institute of Technology.
9  *      For copying and distribution information, see the file
10  *      "mit-copyright.h". 
11  */
12
13 #ifndef lint
14 static char rcsid_ZFormatAuthenticNotice_c[] = "$Id: ZFmtAuth.c,v 1.20 1999/01/22 23:19:06 ghudson Exp $";
15 #endif
16
17 #include <internal.h>
18
19 #ifdef HAVE_KRB4
20 Code_t ZFormatAuthenticNotice(notice, buffer, buffer_len, len, session)
21     ZNotice_t *notice;
22     register char *buffer;
23     register int buffer_len;
24     int *len;
25     C_Block session;
26 {
27     ZNotice_t newnotice;
28     char *ptr;
29     int retval, hdrlen;
30
31     newnotice = *notice;
32     newnotice.z_auth = 1;
33     newnotice.z_authent_len = 0;
34     newnotice.z_ascii_authent = "";
35
36     if ((retval = Z_FormatRawHeader(&newnotice, buffer, buffer_len,
37                                     &hdrlen, &ptr, NULL)) != ZERR_NONE)
38         return (retval);
39
40 #ifdef NOENCRYPTION
41     newnotice.z_checksum = 0;
42 #else
43     newnotice.z_checksum =
44         (ZChecksum_t)des_quad_cksum(buffer, NULL, ptr - buffer, 0, session);
45 #endif
46     if ((retval = Z_FormatRawHeader(&newnotice, buffer, buffer_len,
47                                     &hdrlen, NULL, NULL)) != ZERR_NONE)
48         return (retval);
49
50     ptr = buffer+hdrlen;
51
52     if (newnotice.z_message_len+hdrlen > buffer_len)
53         return (ZERR_PKTLEN);
54
55     (void) memcpy(ptr, newnotice.z_message, newnotice.z_message_len);
56
57     *len = hdrlen+newnotice.z_message_len;
58
59     if (*len > Z_MAXPKTLEN)
60         return (ZERR_PKTLEN);
61
62     return (ZERR_NONE);
63 }
64 #endif